public SonarUpgradeHandler(SubRoot cyclops) : base(TechType.CyclopsSonarModule, cyclops) { cySonar = base.Cyclops?.gameObject?.GetComponentInChildren <SubControl>()?.gameObject.GetComponent <CySonarComponent>(); cyButton = base.Cyclops?.gameObject?.GetComponentInChildren <CyclopsSonarButton>(); this.MaxCount = MaxUpgrades; OnFinishedUpgrades = () => { bool hasUpgrade = base.HasUpgrade; // Vanilla behavior that toggles the sonar button base.Cyclops.sonarUpgrade = hasUpgrade; // New behavior that toggles the near field sonar map this.CySonar?.SetMapState(hasUpgrade); if (hasUpgrade && this.CyButton != null) { // 1 sonar module = 5 seconds (vanilla) // 2 sonar modules = 3.9 seconds float pinginterval = 6.1f - 1.1f * this.Count; this.CyButton.pingIterationDuration = pinginterval; } }; }
public void ChangeSonarMode(NitroxId id, bool isOn) { GameObject cyclops = NitroxIdentifier.RequireObjectFrom(id); CyclopsSonarButton sonar = cyclops.GetComponentInChildren <CyclopsSonarButton>(); if (sonar != null) { using (packetSender.Suppress <CyclopsChangeSonarMode>()) { // At this moment the code is "non functional" as for some reason changing the sprite will never happen // Also setting sonar as active will never work MethodInfo sonarSetActiveInfo = sonar.GetType().GetMethod("set_sonarActive", BindingFlags.NonPublic | BindingFlags.Instance); if (sonarSetActiveInfo != null) { sonarSetActiveInfo.Invoke(sonar, new object[] { isOn }); } if (isOn) { sonar.image.sprite = sonar.activeSprite; } else { sonar.image.sprite = sonar.inactiveSprite; } } } }
private static void Postfix(CyclopsSonarButton __instance) { if (__instance.active) { HandReticle_LateUpdate.activateCyclopsCrosshair = true; } }
public static void Postfix(CyclopsSonarButton __instance) { NitroxId id = NitroxIdentifier.GetId(__instance.subRoot.gameObject); bool activeSonar = Traverse.Create(__instance).Field("sonarActive").GetValue <bool>(); NitroxServiceLocator.LocateService <Cyclops>().BroadcastChangeSonarState(id, activeSonar); }
public static void Postfix(CyclopsSonarButton __instance) { NitroxId id = NitroxEntity.GetId(__instance.subRoot.gameObject); bool activeSonar = __instance.sonarActive; NitroxServiceLocator.LocateService <Cyclops>().BroadcastChangeSonarState(id, activeSonar); }
public override void Process(CyclopsActivateSonar sonarPacket) { GameObject cyclops = GuidHelper.RequireObjectFrom(sonarPacket.Guid); CyclopsSonarButton sonar = cyclops.RequireComponentInChildren <CyclopsSonarButton>(); using (packetSender.Suppress <CyclopsActivateSonar>()) { // At this moment the code is "non functional" as for some reason changing the sprite will never happen // Also setting sonar as active will never work MethodInfo sonarSetActiveInfo = sonar.GetType().GetMethod("set_sonarActive", BindingFlags.NonPublic | BindingFlags.Instance); if (sonarSetActiveInfo != null) { sonarSetActiveInfo.Invoke(sonar, new object[] { sonarPacket.Active }); } if (sonarPacket.Active) { sonar.image.sprite = sonar.activeSprite; } else { sonar.image.sprite = sonar.inactiveSprite; } } }
public static void Postfix(CyclopsSonarButton __instance) { string guid = GuidHelper.GetGuid(__instance.subRoot.gameObject); bool activeSonar = Traverse.Create(__instance).Field("sonarActive").GetValue <bool>(); NitroxServiceLocator.LocateService <Cyclops>().ActivateSonar(guid, activeSonar); }
public override void Process(CyclopsSonarPing sonarPacket) { GameObject cyclops = GuidHelper.RequireObjectFrom(sonarPacket.Guid); CyclopsSonarButton sonar = cyclops.RequireComponentInChildren <CyclopsSonarButton>(); using (packetSender.Suppress <CyclopsSonarPing>()) { sonar.ReflectionCall("SonarPing"); } }
public void SonarPing(NitroxId id) { GameObject cyclops = NitroxIdentifier.RequireObjectFrom(id); CyclopsSonarButton sonar = cyclops.GetComponentInChildren <CyclopsSonarButton>(); if (sonar != null) { using (packetSender.Suppress <CyclopsSonarPing>()) { sonar.ReflectionCall("SonarPing"); } } }
public void ChangeSonarMode(NitroxId id, bool isOn) { GameObject cyclops = NitroxEntity.RequireObjectFrom(id); CyclopsSonarButton sonar = cyclops.GetComponentInChildren <CyclopsSonarButton>(); if (sonar != null) { using (packetSender.Suppress <CyclopsChangeSonarMode>()) { // At this moment the code is "non functional" as for some reason changing the sprite will never happen // Also setting sonar as active will never work sonar.sonarActive = isOn; sonar.image.sprite = isOn ? sonar.activeSprite : sonar.inactiveSprite; } } }
// Send ping to other players public static void Postfix(CyclopsSonarButton __instance) { NitroxId id = NitroxIdentifier.GetId(__instance.subRoot.gameObject); NitroxServiceLocator.LocateService <Cyclops>().BroadcastSonarPing(id); }
// Send ping to other players public static void Postfix(CyclopsSonarButton __instance) { string guid = GuidHelper.GetGuid(__instance.subRoot.gameObject); NitroxServiceLocator.LocateService <Cyclops>().SonarPing(guid); }
public static void Prefix(CyclopsSonarButton __instance) { currentCyclopsId = NitroxEntity.GetId(__instance.subRoot.gameObject); }
public static void Postfix(CyclopsSonarButton __instance) { NitroxId id = NitroxEntity.GetId(__instance.subRoot.gameObject); Resolve <Cyclops>().BroadcastChangeSonarState(id, __instance.sonarActive); }
// Send ping to other players public static void Postfix(CyclopsSonarButton __instance) { NitroxId id = NitroxEntity.GetId(__instance.subRoot.gameObject); Resolve <Cyclops>().BroadcastSonarPing(id); }