public override void Process(CyclopsBeginSilentRunning packet) { Optional <GameObject> opCyclops = GuidHelper.GetObjectFrom(packet.Guid); if (opCyclops.IsPresent()) { CyclopsSilentRunningAbilityButton ability = opCyclops.Get().GetComponentInChildren <CyclopsSilentRunningAbilityButton>(); if (ability != null) { using (packetSender.Suppress <CyclopsBeginSilentRunning>()) { ability.subRoot.BroadcastMessage("RigForSilentRunning"); ability.InvokeRepeating("SilentRunningIteration", 0f, ability.silentRunningIteration); } } else { Console.WriteLine("Could not begin silent running because CyclopsSilentRunningAbilityButton was not found on the cyclops " + packet.Guid); } } else { Console.WriteLine("Could not find cyclops with guid " + packet.Guid + " to begin silent running."); } }
public void ChangeSilentRunning(NitroxId id, bool isOn) { GameObject cyclops = NitroxIdentifier.RequireObjectFrom(id); CyclopsSilentRunningAbilityButton ability = cyclops.RequireComponentInChildren <CyclopsSilentRunningAbilityButton>(); using (packetSender.Suppress <CyclopsChangeSilentRunning>()) { if ((bool)ability.ReflectionGet("active") != isOn) { Log.Debug("Set silent running to " + isOn + " for " + id); ability.ReflectionSet("active", isOn); if (isOn) { ability.image.sprite = ability.activeSprite; ability.subRoot.BroadcastMessage("RigForSilentRunning"); ability.InvokeRepeating("SilentRunningIteration", 0f, ability.silentRunningIteration); } else { ability.image.sprite = ability.inactiveSprite; ability.subRoot.BroadcastMessage("SecureFromSilentRunning"); ability.CancelInvoke("SilentRunningIteration"); } } } }
public override void Process(CyclopsBeginSilentRunning packet) { GameObject cyclops = GuidHelper.RequireObjectFrom(packet.Guid); CyclopsSilentRunningAbilityButton ability = cyclops.RequireComponentInChildren <CyclopsSilentRunningAbilityButton>(); using (packetSender.Suppress <CyclopsBeginSilentRunning>()) { ability.subRoot.BroadcastMessage("RigForSilentRunning"); ability.InvokeRepeating("SilentRunningIteration", 0f, ability.silentRunningIteration); } }
static void Postfix(CyclopsSilentRunningAbilityButton __instance) { if (__instance.active) { float rawEnergyCost = Mathf.Max(CyclopsSettings.silentRunningEnergyConsumption * __instance.subRoot.noiseManager.GetNoisePercent() * 2, CyclopsSettings.silentRunningEnergyConsumption * 0.01f); float energyCost = DayNightCycle.main.deltaTime * rawEnergyCost; if (!__instance.subRoot.powerRelay.ConsumeEnergy(energyCost, out _)) { __instance.TurnOffSilentRunning(); } } }
public override void Process(CyclopsChangeSilentRunning packet) { GameObject cyclops = GuidHelper.RequireObjectFrom(packet.Guid); CyclopsSilentRunningAbilityButton ability = cyclops.RequireComponentInChildren <CyclopsSilentRunningAbilityButton>(); using (packetSender.Suppress <CyclopsChangeSilentRunning>()) { ability.ReflectionSet("active", packet.IsOn); if (packet.IsOn) { ability.image.sprite = ability.activeSprite; ability.subRoot.BroadcastMessage("RigForSilentRunning"); ability.InvokeRepeating("SilentRunningIteration", 0f, ability.silentRunningIteration); } else { ability.image.sprite = ability.inactiveSprite; ability.subRoot.BroadcastMessage("SecureFromSilentRunning"); ability.CancelInvoke("SilentRunningIteration"); } } }
public static void Postfix(CyclopsSilentRunningAbilityButton __instance) { string guid = GuidHelper.GetGuid(__instance.subRoot.gameObject); NitroxServiceLocator.LocateService <Cyclops>().BroadcastChangeSilentRunning(guid, true); }
public static void Postfix(CyclopsSilentRunningAbilityButton __instance) { NitroxId id = NitroxEntity.GetId(__instance.subRoot.gameObject); NitroxServiceLocator.LocateService <Cyclops>().BroadcastChangeSilentRunning(id, true); }
public static void Postfix(CyclopsSilentRunningAbilityButton __instance) { String guid = GuidHelper.GetGuid(__instance.subRoot.gameObject); Multiplayer.Logic.Cyclops.BeginSilentRunning(guid); }