public static void Postfix(CyclopsLightingPanel __instance, bool __state)
 {
     if (__state != __instance.floodlightsOn)
     {
         string guid = GuidHelper.GetGuid(__instance.cyclopsRoot.gameObject);
         NitroxServiceLocator.LocateService <Cyclops>().BroadcastToggleFloodLights(guid, __instance.floodlightsOn);
     }
 }
 public static void Postfix(CyclopsLightingPanel __instance, bool __state)
 {
     if (__state != __instance.lightingOn)
     {
         NitroxId id = NitroxEntity.GetId(__instance.cyclopsRoot.gameObject);
         NitroxServiceLocator.LocateService <Cyclops>().BroadcastToggleInternalLight(id, __instance.lightingOn);
     }
 }
 public static void Postfix(CyclopsLightingPanel __instance, bool __state)
 {
     if (__state != __instance.lightingOn)
     {
         string guid = GuidHelper.GetGuid(__instance.cyclopsRoot.gameObject);
         Multiplayer.Logic.Cyclops.ToggleInternalLight(guid, __instance.lightingOn);
     }
 }
 public static void Postfix(CyclopsLightingPanel __instance, bool __state)
 {
     if (__state != __instance.floodlightsOn)
     {
         NitroxId id = NitroxIdentifier.GetId(__instance.cyclopsRoot.gameObject);
         NitroxServiceLocator.LocateService <Cyclops>().BroadcastToggleFloodLights(id, __instance.floodlightsOn);
     }
 }
 static void Postfix(CyclopsLightingPanel __instance)
 {
     __instance.lightingOn    = false;
     __instance.floodlightsOn = false;
     __instance.cyclopsRoot.ForceLightingState(false);
     __instance.SetExternalLighting(false);
     __instance.UpdateLightingButtons();
 }
 public static void Postfix(CyclopsLightingPanel __instance, bool __state)
 {
     if (__state != __instance.lightingOn)
     {
         string guid = GuidHelper.GetGuid(__instance.cyclopsRoot.gameObject);
         NitroxServiceLocator.LocateService <Cyclops>().ToggleInternalLight(guid, __instance.lightingOn);
     }
 }
예제 #7
0
 public static void Postfix(CyclopsLightingPanel __instance, bool __state)
 {
     if (__state != __instance.floodlightsOn)
     {
         String guid = GuidHelper.GetGuid(__instance.cyclopsRoot.gameObject);
         Multiplayer.Logic.Cyclops.ToggleFloodLights(guid, __instance.floodlightsOn);
     }
 }
 static void Postfix(CyclopsLightingPanel __instance)
 {
     if (__instance.prevPowerRelayState && __instance.floodlightsOn)
     {
         float energyCost = DayNightCycle.main.deltaTime * CyclopsSettings.floodLightEnergyConsumption;
         __instance.cyclopsRoot.powerRelay.ConsumeEnergy(energyCost, out _);
     }
 }
 //Fixed toggle lights bug with multiple Cyclops.
 static bool Prefix(CyclopsLightingPanel __instance)
 {
     if (Player.main.currentSub != __instance.cyclopsRoot)
     {
         return(false);
     }
     return(true);
 }
 //Restores previous floodlight
 static bool Prefix(CyclopsLightingPanel __instance)
 {
     if (CyclopsLightingPanel_TempTurnOffFloodlights_Patch.previous)
     {
         __instance.ToggleFloodlights();
     }
     return(false);
 }
 //Really turns off floodlight to avoid energy consumption
 static bool Prefix(CyclopsLightingPanel __instance)
 {
     previous = __instance.floodlightsOn;
     if (__instance.floodlightsOn)
     {
         __instance.ToggleFloodlights();
     }
     return(false);
 }
예제 #12
0
        public static bool Prefix(CyclopsLightingPanel __instance)
        {
            // Suppress powered on if a cyclops´s floodlight is set to false
            GameObject   gameObject = __instance.gameObject;
            NitroxId     id         = NitroxIdentifier.GetId(gameObject);
            CyclopsModel model      = NitroxServiceLocator.LocateService <Vehicles>().GetVehicles <CyclopsModel>(id);

            return(model.FloodLightsOn);
        }
 //Swaps the lighting buttons to make more sense.
 static void Postfix(CyclopsLightingPanel __instance)
 {
     if (CyclopsSettings.swapLightButtons)
     {
         __instance.uiPanel.transform.localRotation = new Quaternion(0, -1.0f, 0, 0);
     }
     else
     {
         __instance.uiPanel.transform.localRotation = new Quaternion(0, 0, 0, 0);
     }
 }
예제 #14
0
        // To globally sync all of the light controller in the current cyclops
        private static void UpdateAllLightControllers(CyclopsLightingPanel controller)
        {
            var lightSource    = controller.floodlightsHolder.transform.GetChild(0).gameObject; // reads the first floodlight
            var lightingPanels = controller.cyclopsRoot.GetComponentsInChildren <CyclopsLightingPanel>();

            foreach (var lightingPanel in lightingPanels)
            {
                lightingPanel.lightingOn    = controller.cyclopsRoot.subLightsOn;
                lightingPanel.floodlightsOn = lightSource.activeSelf; // checks if the floodlight is active
                lightingPanel.UpdateLightingButtons();                // to sync the buttons images with the new lightingOn and floodlightOn values
            }
        }
        public override void Process(CyclopsToggleFloodLights lightingPacket)
        {
            GameObject           cyclops  = GuidHelper.RequireObjectFrom(lightingPacket.Guid);
            CyclopsLightingPanel lighting = cyclops.RequireComponentInChildren <CyclopsLightingPanel>();

            if (lighting.floodlightsOn != lightingPacket.IsOn)
            {
                using (packetSender.Suppress <CyclopsToggleFloodLights>())
                {
                    lighting.ToggleFloodlights();
                }
            }
        }
예제 #16
0
        public static bool Prefix(CyclopsLightingPanel __instance)
        {
            // Suppress powered on if a cyclops´s floodlight is set to false
            GameObject gameObject         = __instance.gameObject.transform.parent.gameObject; // GO = LightsControl, Parent = main cyclops game object
            NitroxId   id                 = NitroxEntity.GetId(gameObject);
            Optional <CyclopsModel> model = NitroxServiceLocator.LocateService <Vehicles>().TryGetVehicle <CyclopsModel>(id);

            if (!model.HasValue)
            {
                Log.Error($"{nameof(CyclopsLightingPanel_OnSubConstructionComplete_Patch)}: Could not find {nameof(CyclopsModel)} by Nitrox id {id}.\nGO containing wrong id: {__instance.GetHierarchyPath()}");
                return(false);
            }

            return(model.Value.FloodLightsOn);
        }
예제 #17
0
        public void SetInternalLighting(NitroxId id, bool isOn)
        {
            GameObject           cyclops  = NitroxIdentifier.RequireObjectFrom(id);
            CyclopsLightingPanel lighting = cyclops.RequireComponentInChildren <CyclopsLightingPanel>();

            if (lighting.lightingOn != isOn)
            {
                using (packetSender.Suppress <CyclopsToggleInternalLighting>())
                {
                    lighting.lightingOn = !lighting.lightingOn;
                    lighting.cyclopsRoot.ForceLightingState(lighting.lightingOn);
                    FMODAsset asset = (!lighting.lightingOn) ? lighting.vn_lightsOff : lighting.vn_lightsOn;
                    FMODUWE.PlayOneShot(asset, lighting.transform.position, 1f);
                    lighting.ReflectionCall("UpdateLightingButtons");
                }
            }
        }
예제 #18
0
        public void SetFloodLighting(NitroxId id, bool isOn)
        {
            GameObject           cyclops  = NitroxIdentifier.RequireObjectFrom(id);
            CyclopsLightingPanel lighting = cyclops.RequireComponentInChildren <CyclopsLightingPanel>();

            if (lighting.floodlightsOn != isOn)
            {
                using (packetSender.Suppress <CyclopsToggleFloodLights>())
                {
                    lighting.floodlightsOn = !lighting.floodlightsOn;
                    lighting.ReflectionCall("SetExternalLighting", false, false, new object[] { lighting.floodlightsOn });
                    FMODAsset asset = (!lighting.floodlightsOn) ? lighting.vn_floodlightsOff : lighting.vn_floodlightsOn;
                    FMODUWE.PlayOneShot(asset, lighting.transform.position, 1f);
                    lighting.ReflectionCall("UpdateLightingButtons");
                }
            }
        }
        public override void Process(CyclopsToggleInternalLighting lightingPacket)
        {
            Optional <GameObject> opCyclops = GuidHelper.GetObjectFrom(lightingPacket.Guid);

            if (opCyclops.IsPresent())
            {
                CyclopsLightingPanel lighting = opCyclops.Get().GetComponentInChildren <CyclopsLightingPanel>();

                if (lighting.lightingOn != lightingPacket.IsOn)
                {
                    using (packetSender.Suppress <CyclopsToggleInternalLighting>())
                    {
                        lighting.ToggleInternalLighting();
                    }
                }
            }
            else
            {
                Console.WriteLine("Could not find cyclops with guid " + lightingPacket.Guid + " to change internal lighting");
            }
        }
예제 #20
0
 private static void ToggleLightsPostfix(CyclopsLightingPanel __instance)
 {
     UpdateAllLightControllers(__instance);
 }
 public static bool Prefix(CyclopsLightingPanel __instance, out bool __state)
 {
     __state = __instance.lightingOn;
     return(true);
 }
 static void Prefix(CyclopsLightingPanel __instance)
 {
     __instance.lightingOn    = false;
     __instance.floodlightsOn = false;
 }