Skip to content

Commit

Permalink
Fix escapePod metadata handling when playing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannify committed Jan 13, 2025
1 parent 350cf74 commit 834e8c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace NitroxClient.GameLogic.Spawning.Metadata.Processor;

public class EscapePodMetadataProcessor : EntityMetadataProcessor<EscapePodMetadata>
{
// For metadata changes outside initial sync we only care about broken -> repaired
public override void ProcessMetadata(GameObject gameObject, EscapePodMetadata metadata)
{
if (!gameObject.TryGetComponent(out EscapePod pod))
Expand All @@ -14,31 +15,30 @@ public override void ProcessMetadata(GameObject gameObject, EscapePodMetadata me
return;
}

if (!pod.radioSpawner.spawnedObj.TryGetComponent(out Radio radio))
{
Log.Error($"[{nameof(EscapePodMetadataProcessor)}] Could not get Radio from EscapePod.");
return;
}

bool repairedSomething = false;
if (!pod.liveMixin.IsFullHealth() && metadata.PodRepaired)
{
pod.OnRepair(); // Only plays visuals and sounds
repairedSomething = true;
pod.liveMixin.health = pod.liveMixin.maxHealth;
pod.healthScalar = 1;
pod.damageEffectsShowing = true;
pod.UpdateDamagedEffects();
pod.OnRepair();
}

if (!radio.liveMixin.IsFullHealth() && metadata.RadioRepaired)
if (!pod.radioSpawner.spawnedObj.TryGetComponent(out Radio radio))
{
radio.OnRepair(); // Only plays visuals and sounds
repairedSomething = true;
Log.Error($"[{nameof(EscapePodMetadataProcessor)}] Could not get Radio from EscapePod.");
return;
}

if (repairedSomething)
if (!radio.liveMixin.IsFullHealth() && metadata.RadioRepaired)
{
ProcessInitialSyncMetadata(pod, radio, metadata);
radio.liveMixin.AddHealth(radio.liveMixin.maxHealth);
}
}

/// <summary>
/// Applies repaired state without animations and minimal audio playback
/// </summary>
public static void ProcessInitialSyncMetadata(EscapePod pod, Radio radio, EscapePodMetadata metadata)
{
if (metadata.PodRepaired)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ private static bool IsRemoteCinematicReady(uGUI_SceneIntro uGuiSceneIntro)
return true;
}

if (GameModeUtils.currentGameMode.HasFlag(GameModeOption.Creative))
// Skipping intro if creative like in normal SN or in debug configuration
if (!NitroxEnvironment.IsReleaseMode ||
GameModeUtils.currentGameMode.HasFlag(GameModeOption.Creative))
{
SkipLocalCinematic(uGuiSceneIntro); // Skipping intro if Creative like in normal SN
SkipLocalCinematic(uGuiSceneIntro);
return false;
}

Expand Down Expand Up @@ -206,7 +208,10 @@ public static void SkipLocalCinematic(uGUI_SceneIntro uGuiSceneIntro)
uGuiSceneIntro.Stop(true);

radioLiveMixin.health = radioHealthBefore;
Object.Destroy(radioLiveMixin.loopingDamageEffectObj);
if (radioLiveMixin.IsFullHealth())
{
Object.Destroy(radioLiveMixin.loopingDamageEffectObj);
}

Transform introFireHolder = EscapePod.main.transform.Find("Intro");
if (introFireHolder) // Can be null if called very early
Expand Down

0 comments on commit 834e8c0

Please sign in to comment.