-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Last minute additions #2217
base: master
Are you sure you want to change the base?
Last minute additions #2217
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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 KeypadMetadataExtractor : EntityMetadataExtractor<KeypadDoorConsole, KeypadMetadata> | ||
{ | ||
public override KeypadMetadata Extract(KeypadDoorConsole keypadDoorConsole) | ||
{ | ||
string pathToRoot = string.Empty; | ||
|
||
if (keypadDoorConsole.root) | ||
{ | ||
pathToRoot = keypadDoorConsole.gameObject.GetHierarchyPath(keypadDoorConsole.root); | ||
} | ||
|
||
return new(keypadDoorConsole.unlocked, pathToRoot); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
using System; | ||
using System; | ||
using System.Runtime.Serialization; | ||
using BinaryPack.Attributes; | ||
|
||
namespace NitroxModel.DataStructures.GameLogic.Entities.Metadata | ||
namespace NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
|
||
[Serializable] | ||
[DataContract] | ||
public class KeypadMetadata : EntityMetadata | ||
{ | ||
[Serializable] | ||
[DataContract] | ||
public class KeypadMetadata : EntityMetadata | ||
{ | ||
[DataMember(Order = 1)] | ||
public bool Unlocked { get; } | ||
[DataMember(Order = 1)] | ||
public bool Unlocked { get; } | ||
|
||
[IgnoreConstructor] | ||
protected KeypadMetadata() | ||
{ | ||
// Constructor for serialization. Has to be "protected" for json serialization. | ||
} | ||
[DataMember(Order = 2)] | ||
public string PathFromRoot { get; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really a metadata ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This metadata is applied to an object which doesn't necessarily hold the KeypadDoorConsole component. Thus we need a way to find the component, which varies from one prefab to another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not do this by extracting it from the object it's on rather than using the path? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GetComponentInChildren is quite costy and might pick the wrong door is there are two available in the children |
||
|
||
[IgnoreConstructor] | ||
protected KeypadMetadata() | ||
{ | ||
// Constructor for serialization. Has to be "protected" for json serialization. | ||
} | ||
|
||
public KeypadMetadata(bool unlocked) | ||
{ | ||
Unlocked = unlocked; | ||
} | ||
public KeypadMetadata(bool unlocked, string pathFromRoot) | ||
{ | ||
Unlocked = unlocked; | ||
PathFromRoot = pathFromRoot; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"[KeypadMetadata isOpen: {Unlocked}]"; | ||
} | ||
public override string ToString() | ||
{ | ||
return $"[{nameof(KeypadMetadata)} Unlocked: {Unlocked}, PathFromRoot: {PathFromRoot}]"; | ||
} | ||
} |
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.
You should be using dependency injection, this will generate a warning from our analyzers
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.
It won't work in this static context
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.
Terrain is already being required inside Mutiplayer mb, so static can be removed