forked from SubnauticaNitrox/Nitrox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeypadMetadataProcessor.cs
More file actions
39 lines (33 loc) · 1.26 KB
/
KeypadMetadataProcessor.cs
File metadata and controls
39 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using NitroxClient.GameLogic.Spawning.Metadata.Processor.Abstract;
using NitroxModel.DataStructures.GameLogic.Entities.Metadata;
using UnityEngine;
namespace NitroxClient.GameLogic.Spawning.Metadata.Processor;
public class KeypadMetadataProcessor : EntityMetadataProcessor<KeypadMetadata>
{
public override void ProcessMetadata(GameObject gameObject, KeypadMetadata metadata)
{
GameObject keypadObject = gameObject;
if (metadata.PathFromRoot.Length > 0)
{
Transform child = gameObject.transform.Find(metadata.PathFromRoot);
if (!child)
{
Log.Error($"Could not find child at path \"{child}\" from {gameObject}");
return;
}
keypadObject = child.gameObject;
}
if (!keypadObject.TryGetComponent(out KeypadDoorConsole keypadDoorConsole))
{
Log.Error($"Could not find {nameof(KeypadDoorConsole)} on {gameObject}");
return;
}
keypadDoorConsole.unlocked = metadata.Unlocked;
if (metadata.Unlocked)
{
keypadDoorConsole.keypadUI.SetActive(false);
keypadDoorConsole.unlockIcon.SetActive(true);
keypadDoorConsole.AcceptNumberField();
}
}
}