-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix escape pod status on joining and repairing it #2257
Draft
Jannify
wants to merge
10
commits into
SubnauticaNitrox:master
Choose a base branch
from
Jannify:fixBrokenEscapePod
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ff12bf9
Remove not used field in EscapePodWorldEntity
Jannify d5c16e0
Apply current coding standard to touched code
Jannify e42b758
Fix joining singleplayer not possible
Jannify d70fea6
Add debug drawer for UWE.Event<T>
Jannify 0035aad
Fix EscapePod lighting being wrong when joining
Jannify 072b5e5
Refactor and fix EscapePodMetadata handling
Jannify e4ee3ec
Fix smoke being visible on joining
Jannify 350cf74
Fix escapePod sparks in intro cinematic and black smoke
Jannify 834e8c0
Fix escapePod metadata handling when playing
Jannify 9bae0b7
Address requested changes
Jannify File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
NitroxClient/Debuggers/Drawer/Subnautica/UWEEventDrawer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UWE; | ||
|
||
namespace NitroxClient.Debuggers.Drawer.Subnautica; | ||
|
||
public class UWEEventDrawer : IDrawer<Event<float>>, IDrawer<Event<PowerRelay>> | ||
{ | ||
private const float LABEL_WIDTH = 250; | ||
|
||
public void Draw(Event<float> uweEvent) => UWEEventDrawer.Draw(uweEvent); | ||
public void Draw(Event<PowerRelay> uweEvent) => UWEEventDrawer.Draw(uweEvent); | ||
|
||
private static void Draw<T>(Event<T> uweEvent) | ||
{ | ||
using GUILayout.VerticalScope scope = new(); | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Triggering", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
uweEvent.triggering = NitroxGUILayout.BoolField(uweEvent.triggering); | ||
} | ||
|
||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("Handlers", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
DrawUweEventHandlerList(uweEvent.handlers); | ||
} | ||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("ToRemove", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
DrawUweEventHandlerList(uweEvent.toRemove); | ||
} | ||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
GUILayout.Label("HandlersToTrigger", NitroxGUILayout.DrawerLabel, GUILayout.Width(LABEL_WIDTH)); | ||
NitroxGUILayout.Separator(); | ||
DrawUweEventHandlerList(uweEvent.handlersToTrigger); | ||
} | ||
} | ||
|
||
private static void DrawUweEventHandlerList<T>(ICollection<Event<T>.Handler> uweEventHandlerList) | ||
{ | ||
if (uweEventHandlerList == null) | ||
{ | ||
GUILayout.Label("null", NitroxGUILayout.DrawerLabel); | ||
return; | ||
} | ||
|
||
if (uweEventHandlerList.Count == 0) | ||
{ | ||
GUILayout.Label("empty", NitroxGUILayout.DrawerLabel); | ||
return; | ||
} | ||
|
||
foreach (Event<T>.Handler uweEventHandler in uweEventHandlerList) | ||
{ | ||
using (new GUILayout.HorizontalScope()) | ||
{ | ||
NitroxGUILayout.Separator(); | ||
if (uweEventHandler == null) | ||
{ | ||
GUILayout.Label("Handler was null", NitroxGUILayout.DrawerLabel); | ||
continue; | ||
} | ||
|
||
string labelText = uweEventHandler.obj ? $"{uweEventHandler.obj.GetType().Name}." : string.Empty; | ||
labelText += uweEventHandler.function; | ||
GUILayout.Label(labelText, NitroxGUILayout.DrawerLabel); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
NitroxClient/GameLogic/Spawning/Metadata/Extractor/EscapePodMetadataExtractor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using NitroxClient.GameLogic.Spawning.Metadata.Extractor.Abstract; | ||
using NitroxClient.Unity.Helper; | ||
using NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
|
||
namespace NitroxClient.GameLogic.Spawning.Metadata.Extractor; | ||
|
||
public class EscapePodMetadataExtractor : EntityMetadataExtractor<EscapePod, EscapePodMetadata> | ||
{ | ||
public override EscapePodMetadata Extract(EscapePod entity) | ||
{ | ||
Radio radio = entity.radioSpawner.spawnedObj.RequireComponent<Radio>(); | ||
return new EscapePodMetadata(entity.liveMixin.IsFullHealth(), radio.liveMixin.IsFullHealth()); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
NitroxClient/GameLogic/Spawning/Metadata/Processor/EscapePodMetadataProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using NitroxClient.GameLogic.Spawning.Metadata.Processor.Abstract; | ||
using NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
using UnityEngine; | ||
|
||
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)) | ||
{ | ||
Log.Error($"[{nameof(EscapePodMetadataProcessor)}] Could not get the EscapePod component from the provided gameobject."); | ||
return; | ||
} | ||
|
||
if (!pod.liveMixin.IsFullHealth() && metadata.PodRepaired) | ||
{ | ||
pod.liveMixin.health = pod.liveMixin.maxHealth; | ||
pod.healthScalar = 1; | ||
pod.damageEffectsShowing = true; | ||
pod.UpdateDamagedEffects(); | ||
pod.OnRepair(); | ||
} | ||
|
||
if (!pod.radioSpawner.spawnedObj.TryGetComponent(out Radio radio)) | ||
{ | ||
Log.Error($"[{nameof(EscapePodMetadataProcessor)}] Could not get Radio from EscapePod."); | ||
return; | ||
} | ||
|
||
if (!radio.liveMixin.IsFullHealth() && metadata.RadioRepaired) | ||
{ | ||
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) | ||
{ | ||
pod.liveMixin.health = pod.liveMixin.maxHealth; | ||
pod.healthScalar = 1; | ||
pod.damageEffectsShowing = true; // Needs to be set to true for UpdateDamagedEffects() to function | ||
pod.UpdateDamagedEffects(); | ||
pod.vfxSpawner.SpawnManual(); // Spawn vfx to instantly disable it so no smoke is fading after player has joined | ||
pod.vfxSpawner.spawnedObj.SetActive(false); | ||
pod.lightingController.SnapToState(0); | ||
} | ||
else | ||
{ | ||
IntroLifepodDirector introLifepodDirector = pod.GetComponent<IntroLifepodDirector>(); | ||
introLifepodDirector.OnProtoDeserializeObjectTree(null); | ||
introLifepodDirector.ToggleActiveObjects(false); | ||
pod.lightingController.SnapToState(2); | ||
} | ||
|
||
if (metadata.RadioRepaired) | ||
{ | ||
radio.liveMixin.health = radio.liveMixin.maxHealth; | ||
if (radio.liveMixin.loopingDamageEffectObj) | ||
{ | ||
Object.Destroy(radio.liveMixin.loopingDamageEffectObj); | ||
} | ||
} | ||
else | ||
{ | ||
pod.DamageRadio(); | ||
} | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
NitroxClient/GameLogic/Spawning/Metadata/Processor/RepairedComponentMetadataProcessor.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
UweEventDrawer
as it's 3+ letter acronym.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this but I think we should be consistent. In this file we have GUI did we want to change that as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we could, yes I think so. But that's a Unity type. Renaming external types would be too tedious for maintaining a naming convention imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the naming from the namspace uwe gave us. There it is ALl uppercase.