using NitroxClient.GameLogic.Spawning.Metadata.Extractor.Abstract; using NitroxClient.Unity.Helper; using NitroxModel.DataStructures.GameLogic.Entities.Metadata; using UnityEngine; using static NitroxClient.GameLogic.Spawning.Metadata.Extractor.CyclopsMetadataExtractor; namespace NitroxClient.GameLogic.Spawning.Metadata.Extractor; public class CyclopsMetadataExtractor : EntityMetadataExtractor { public override CyclopsMetadata Extract(CyclopsGameObject cyclops) { GameObject gameObject = cyclops.GameObject; CyclopsSilentRunningAbilityButton silentRunning = gameObject.RequireComponentInChildren(true); CyclopsEngineChangeState engineState = gameObject.RequireComponentInChildren(true); bool engineShuttingDown = (engineState.motorMode.engineOn && engineState.invalidButton); bool engineOn = (engineState.startEngine || engineState.motorMode.engineOn) && !engineShuttingDown; CyclopsShieldButton shield = gameObject.GetComponentInChildren(true); bool shieldOn = (shield) ? shield.active : false; CyclopsSonarButton sonarButton = gameObject.GetComponentInChildren(true); bool sonarOn = (sonarButton) ? sonarButton._sonarActive : false; CyclopsMotorMode.CyclopsMotorModes motorMode = engineState.motorMode.cyclopsMotorMode; LiveMixin liveMixin = gameObject.RequireComponentInChildren(); float health = liveMixin.health; SubRoot subRoot = gameObject.RequireComponentInChildren(); bool isDestroyed = subRoot.subDestroyed || health <= 0f; return new(silentRunning.active, shieldOn, sonarOn, engineOn, (int)motorMode, health, isDestroyed); } public struct CyclopsGameObject { public GameObject GameObject { get; set; } } }