private void SwitchLampOff(Renderer renderer, Light reactorRodLight, bool noSound = false)
        {
            if (isOn)
            {
                // Save current reactor rod intensity
                savedGlowColor = renderer.material.GetColor("_GlowColor");
                // Save current lamp intensity
                savedIntensity = reactorRodLight.intensity;
                // Save current lamp range
                savedRange = reactorRodLight.range;

                // Disable emission
                renderer.material.DisableKeyword("MARMO_EMISSION");
                // Disable reactor rod intensity
                renderer.material.SetColor("_GlowColor", Color.black);
                // Disable lamp itensity
                reactorRodLight.intensity = 0.0f;
                // Disable lamp range
                reactorRodLight.range = 0.0f;

                // Play sound
#pragma warning disable CS0618
                if (!noSound)
                {
                    FMODUWE.PlayOneShot("event:/sub/cyclops/lights_off", MainCamera.camera.transform.position, 1f);
                }
#pragma warning restore CS0618

                isOn = false;
            }
        }
Example #2
0
        private void SwitchLampOff(Renderer renderer, Light reactorRodLight, bool noSound = false)
        {
            if (isOn)
            {
                // Save current reactor rod intensity
                savedGlowColor = renderer.material.GetColor("_GlowColor");
                // Save current lamp intensity
                savedIntensity = reactorRodLight.intensity;
                // Save current lamp range
                savedRange = reactorRodLight.range;

                // Disable emission
                renderer.material.DisableKeyword("MARMO_GLOW");
                // Disable reactor rod intensity
                renderer.material.SetColor("_GlowColor", Color.black);
                renderer.material.SetFloat("_EnableGlow", 0);
                renderer.material.SetFloat("_Shininess", 0.0f);
                // Disable lamp itensity
                reactorRodLight.intensity = 0.0f;
                // Disable lamp range
                reactorRodLight.range = 0.0f;

                // Play sound
                if (!noSound)
                {
                    FMODUWE.PlayOneShot(_lightsOffAsset, MainCamera.camera.transform.position, 1f);
                }

                isOn = false;
            }
        }
Example #3
0
        private void PlaySound(string eventPath)
        {
            Camera camera = Camera.main;

            if (!camera)
            {
                Log.InGame("Camera.main not found");
                return;
            }
            Vector3 position = camera.transform.position + new Vector3(distance, 0, 0);

            if (!eventInstancesByPath.TryGetValue(eventPath, out EventInstance instance))
            {
                instance = FMODUWE.GetEvent(eventPath);
                eventInstancesByPath.Add(eventPath, instance);
            }
            else
            {
                instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
            }

            instance.setVolume(volume);
            instance.set3DAttributes(position.To3DAttributes());
            instance.setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 0f);
            instance.setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, 100f);
            instance.start();
            instance.release();
        }
Example #4
0
        public override bool OnRightHandHeld()
        {
            bool canUse = this.energyMixin.charge > 0f;

            if (canUse && nextFire < Time.time && ready)
            {
                if (charge >= 1)
                {
                    nextFire = Time.time + 0.2f;
                    charge   = 0f;
                    Shoot();
                    FMODUWE.PlayOneShot(shootSound, transform.position, 1f);
                    muzzleFlash.Play();
                    chargeSparks.Stop();
                    flash.intensity = 2f;

                    energyMixin.ConsumeEnergy(50f);
                }
                else
                {
                    if (!chargeSparks.isPlaying)
                    {
                        chargeSparks.Play();
                    }
                    charge += 0.03f;
                }
            }
            return(true);
        }
Example #5
0
        private static void SurvivalPatchings(IDictionary <TechType, List <Action> > dictionary, GameObject obj, ref bool result)
        {
            TechType tt = CraftData.GetTechType(obj);

            if (dictionary.TryGetValue(tt, out List <Action> action))
            {
                action.ForEach((x) => x.Invoke());
                result = true;
            }
            if (result)
            {
#if SUBNAUTICA
#pragma warning disable CS0618 // Type or member is obsolete and yet IS still used by Subnautica itself.
                string sound = CraftData.GetUseEatSound(tt);
                if (!string.IsNullOrEmpty(sound))
                {
                    FMODUWE.PlayOneShot(sound, Player.main.transform.position); // only play the sound if its useable
                }
#pragma warning restore CS0618
#elif BELOWZERO
                FMODAsset asset = Player.main.GetUseSound(TechData.GetSoundType(tt));
                if (asset != null)
                {
                    FMODUWE.PlayOneShot(asset, Player.main.transform.position); // only play the sound if its useable
                }
#endif
            }
        }
        public override void Process(PlayFMODAsset packet)
        {
            EventInstance instance = FMODUWE.GetEvent(packet.AssetPath);

            instance.setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 1f);
            instance.setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, packet.Radius);
            instance.setVolume(packet.Volume);
            instance.set3DAttributes(packet.Position.ToUnity().To3DAttributes());
            instance.start();
            instance.release();
        }
Example #7
0
        public void PlayCustomLoopingEmitter(string path)
        {
            FMOD_CustomLoopingEmitter loopingEmitter = loopingEmitters[path].Key;
            EventInstance             eventInstance  = FMODUWE.GetEvent(path);

            eventInstance.set3DAttributes(loopingEmitter.transform.To3DAttributes());
            eventInstance.setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 1f);
            eventInstance.setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, loopingEmitters[path].Value);
            eventInstance.start();
            eventInstance.release();
            timeLastStopSoundField.SetValue(loopingEmitter, Time.time);
        }
Example #8
0
        public void Update()
        {
            if (shark.GetPilotingMode())
            {
                if (shark.boostCharge == 1 && shark.boostChargeDelta > 0f)
                {
                    FMODUWE.PlayOneShot(shark.chargeFinished, transform.position, 0.5f);
                }
                else if (shark.boostChargeDelta > 0f)
                {
                    if (!shark.chargeUp.playing)
                    {
                        shark.chargeUp.Play();
                    }
                }
                else
                {
                    if (shark.chargeUp.playing)
                    {
                        shark.chargeUp.Stop();
                    }
                }

                shark.normalMove.SetParameterValue("rpm", Vector3.ClampMagnitude(GameInput.GetMoveDirection(), 1f).magnitude / 2f);
                if (!shark.normalMove.playing)
                {
                    shark.normalMove.Play();
                }

                if (shark.isBoosting)
                {
                    if (!shark.boost.playing)
                    {
                        shark.boost.Play();
                    }
                    shark.normalMove.SetParameterValue("rpm", 0f);
                }
                else
                {
                    if (shark.boost.playing)
                    {
                        shark.boost.Stop();
                    }
                }
            }
            else
            {
                shark.normalMove.Stop();
                shark.boost.Stop();
                shark.chargeUp.Stop();
            }
        }
Example #9
0
        public override void Process(PlayFMODAsset packet)
        {
            EventInstance instance = FMODUWE.GetEvent(packet.AssetPath);

            instance.setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 1f);
            instance.setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, packet.Radius);
            // Volume is a scalar, is should be limited to 0 and we don't need more than 100% volume (i.e. 1.0).
            // See docs: https://fmod.com/resources/documentation-api?version=2.00&page=studio-api-eventinstance.html#studio_eventinstance_setvolume
            instance.setVolume(Mathf.Clamp01(packet.Volume));
            instance.set3DAttributes(packet.Position.ToUnity().To3DAttributes());
            instance.start();
            instance.release();
        }
Example #10
0
        public static bool Prefix(ref Survival __instance, ref bool __result, GameObject useObj)
        {
            bool prefixFlag = true;

            if (useObj != null)
            {
                TechType      techType      = CraftData.GetTechType(useObj);
                NitrogenLevel nitrogenLevel = null;
                bool          nFlag         = false;

                if (Player.main.gameObject.GetComponent <NitrogenLevel>() != null)
                {
                    nitrogenLevel = Player.main.gameObject.GetComponent <NitrogenLevel>();
                    if (nitrogenLevel.safeNitrogenDepth >= 10f)
                    {
                        nFlag = true;
                    }
                }

                if (techType == TechType.FirstAidKit)
                {
                    if (Player.main.GetComponent <LiveMixin>().AddHealth(50f) > 0.1f)
                    {
                        prefixFlag = false;
                        __result   = true;
                    }

                    if (nFlag)
                    {
                        if (nitrogenLevel.safeNitrogenDepth > 10f)
                        {
                            nitrogenLevel.safeNitrogenDepth -= 10f;
                        }
                        else
                        {
                            nitrogenLevel.safeNitrogenDepth = 0f;
                        }

                        prefixFlag = false;
                        __result   = true;
                    }

                    if (__result)
                    {
                        string useEatSound = CraftData.GetUseEatSound(techType);
                        FMODUWE.PlayOneShot(useEatSound, Player.main.transform.position, 1f);
                    }
                }
            }
            return(prefixFlag);
        }
        /// <summary>
        /// Plays the door open/close sound clip
        /// </summary>
        /// <param name="doorState"></param>
        internal void PlayDoorSoundClip(bool doorState)
        {
            if (!_allowedToPlaySounds)
            {
                return;
            }
            FMODAsset asset = !doorState ? _doorOpen : _doorClose;

            if (!(asset != null))
            {
                return;
            }
            FMODUWE.PlayOneShot(asset, _transform.position, 1f);
        }
Example #12
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");
                }
            }
        }
Example #13
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");
                }
            }
        }
Example #14
0
        public static IEnumerator releaseAllEventInstances(string eventPath, int waitFramesMax = 10)
        {
            $"Utils.releaseAllEventInstances: {eventPath}".logDbg();
            FMODUWE.GetEventInstance(eventPath, out EventInstance eventInstance);
            var desc = eventInstance.getDescription();

            eventInstance.release();

            int count = desc.getInstanceCount();                                                                                                                    $"Utils.releaseAllEventInstances: instances count = {count}".logDbg();

            if (count == 0)
            {
                yield break;
            }

            desc.releaseAllInstances();
            yield return(new WaitWhile(() => desc.getInstanceCount() > 0 && waitFramesMax-- > 0));
        }
Example #15
0
        /// <summary>Gets called upon HandClick event.</summary>
        /// <param name="hand">The hand that triggered the click event.</param>
        public void OnHandClick(GUIHand hand)
        {
            if (!enabled)
            {
                return;
            }

            // Get light switch SubRoot
            var subRoot = GetSubRoot();

            if (subRoot == null)
            {
                return;                  // Return if light switch is not in a base or in a submarine
            }
            // Get light switch Constructable
            var constructable = GetComponent <Constructable>();

            if (constructable == null || !constructable.constructed)
            {
                return;                                                      // Return if light switch has not been built
            }
            // Get current light state
            var isLightsOn = (bool)this._isLightsOnField.GetValue(subRoot);

            // Set new light state
            this.IsLightsOn = !isLightsOn;
            subRoot.ForceLightingState(this.IsLightsOn);

            // Play sound (depending on new light state). Scraped from : https://github.com/K07H/DecorationsMod/blob/master/Subnautica_AudioAssets.txt
            if (this.IsLightsOn)
            {
                FMODUWE.PlayOneShot(new FMODAsset()
                {
                    id = "2103", path = "event:/sub/cyclops/lights_on", name = "5384ec29-f493-4ac1-9f74-2c0b14d61440", hideFlags = HideFlags.None
                }, MainCamera.camera.transform.position, 1f);
            }
            else
            {
                FMODUWE.PlayOneShot(new FMODAsset()
                {
                    id = "2102", path = "event:/sub/cyclops/lights_off", name = "95b877e8-2ccd-451d-ab5f-fc654feab173", hideFlags = HideFlags.None
                }, MainCamera.camera.transform.position, 1f);
            }
        }
        public override bool OnAltDown()
        {
            if (PowerCheck)
            {
                par[0].Play();
                Reset();
                mode++;
                FMODUWE.PlayOneShot(modeChangeSound, transform.position, 0.5f);

                switch (mode)
                {
                case 1:
                    textMode.text = "Laser";
                    break;

                case 2:
                    textMode.text = "Cannon";
                    break;

                case 3:
                    textMode.text = "Big";
                    break;

                case 4:
                    textMode.text = "Small";
                    break;

                case 5:
                    textMode.text = "Standby";
                    mode          = 0;
                    break;
                }
            }
            else
            {
                textMode.text = "No Power";
                mode          = 0;
            }
            return(true);
        }
Example #17
0
        private void SwitchLampOn(Renderer renderer, Light reactorRodLight, bool noSound = false)
        {
            if (!isOn)
            {
                // Restore emission
                renderer.material.EnableKeyword("MARMO_GLOW");
                // Restore reactor rod intensity
                renderer.material.SetColor("_GlowColor", savedGlowColor);
                renderer.material.SetFloat("_EnableGlow", 1);
                renderer.material.SetFloat("_Shininess", 10.0f);
                // Restore lamp itensity
                reactorRodLight.intensity = savedIntensity;
                // Restore lamp range
                reactorRodLight.range = savedRange;

                // Play sound
                if (!noSound)
                {
                    FMODUWE.PlayOneShot(_lightsOnAsset, MainCamera.camera.transform.position, 1f);
                }

                isOn = true;
            }
        }
        public EventInstance?PlayOneShot(FMODAsset asset, Vector3 position, float volume = 1.0f, float duration = -1.0f)
        {
            EventInstance?result = null;

            try
            {
                EventInstance eventInstance2 = FMODUWE.GetEvent(asset);
                eventInstance2.setVolume(volume);
                eventInstance2.set3DAttributes(position.To3DAttributes());
                eventInstance2.start();
                if (duration > 0.0f)
                {
                    playingSounds.Add(new EventInstance?(eventInstance2), Time.time + duration);
                    Invoke("StopSounds", duration + 0.1f);
                }
                else
                {
                    eventInstance2.release();
                }
                result = eventInstance2;
            }
            catch { }
            return(result);
        }
        private void SwitchLampOn(Renderer renderer, Light reactorRodLight, bool noSound = false)
        {
            if (!isOn)
            {
                // Restore emission
                renderer.material.EnableKeyword("MARMO_EMISSION");
                // Restore reactor rod intensity
                renderer.material.SetColor("_GlowColor", savedGlowColor);
                // Restore lamp itensity
                reactorRodLight.intensity = savedIntensity;
                // Restore lamp range
                reactorRodLight.range = savedRange;

                // Play sound
#pragma warning disable CS0618
                if (!noSound)
                {
                    FMODUWE.PlayOneShot("event:/sub/cyclops/lights_on", MainCamera.camera.transform.position, 1f);
                }
#pragma warning restore CS0618

                isOn = true;
            }
        }
Example #20
0
        /// <summary>
        /// This is a copy paste of the original <see cref="Survival.Eat(GameObject)"/> because there are too many things to transpile
        /// </summary>
        /// <param name="__instance"></param>
        /// <param name="useObj"></param>
        private void NewPrefixPatch(Survival __instance, GameObject useObj)
        {
            flag = false;
            if (useObj != null)
            {
                Eatable component = useObj.GetComponent <Eatable>();
                if (component != null)
                {
                    if (component.GetFoodValue() != 0f)
                    {
                        float miniFoodOverfill = __instance.GetStomachSize() - 1;
                        if (__instance.food <= miniFoodOverfill)
                        {
                            __instance.food = Mathf.Clamp(__instance.food + component.GetFoodValue(), 0f, __instance.GetStomachOverfillSize());
                        }
                        __instance.onEat.Trigger(component.GetFoodValue());
                        if (component.GetFoodValue() > 0f)
                        {
                            GoalManager.main.OnCustomGoalEvent("Eat_Something");
                        }
                        flag = true;
                    }

                    if (component.GetWaterValue() != 0f)
                    {
                        float minWaterOverfill = __instance.GetWaterCapacity() - 1;
                        if (__instance.water <= minWaterOverfill)
                        {
                            __instance.water = Mathf.Clamp(__instance.water + component.GetWaterValue(), 0f, __instance.GetWaterOverfillSize());
                        }
                        __instance.onDrink.Trigger(component.GetWaterValue());
                        if (component.GetWaterValue() > 0f)
                        {
                            GoalManager.main.OnCustomGoalEvent("Drink_Something");
                        }
                        flag = true;
                    }

                    var lowFoodThreshold  = __instance.GetLowFoodThreshold();
                    var lowWaterThreshold = __instance.GetLowWaterThreshold();

                    bool foodOkay  = (__instance.food > lowFoodThreshold && __instance.food - component.GetFoodValue() < lowFoodThreshold);
                    bool waterOkay = (__instance.water > lowWaterThreshold && __instance.water - component.GetWaterValue() < lowWaterThreshold);
                    if (foodOkay || waterOkay)
                    {
                        __instance.vitalsOkNotification.Play();
                    }
                }


                if (flag)
                {
                    TechType techType = CraftData.GetTechType(useObj);
                    if (techType == TechType.None)
                    {
                        Pickupable component2 = useObj.GetComponent <Pickupable>();
                        if (component2)
                        {
                            techType = component2.GetTechType();
                        }
                    }
                    FMODUWE.PlayOneShot(CraftData.GetUseEatSound(techType), Player.main.transform.position, 1f);
                    if (techType == TechType.Bladderfish)
                    {
                        Player.main.GetComponent <OxygenManager>().AddOxygen(__instance.GetO2FromBlatterfish());
                    }
                }
            }
        }
        private static void BreakIntoResources_Patch(BreakableResource __instance)
        {
            __instance.SendMessage("OnBreakResource", null, SendMessageOptions.DontRequireReceiver);
            if (__instance.gameObject.GetComponent <VFXBurstModel>())
            {
                __instance.gameObject.BroadcastMessage("OnKill");
            }
            else
            {
                UnityEngine.Object.Destroy(__instance.gameObject);
            }
            if (__instance.customGoalText != "")
            {
                GoalManager.main.OnCustomGoalEvent(__instance.customGoalText);
            }
            bool flag = false;

            for (int i = 0; i < __instance.numChances; i++)
            {
                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-01 - start choose random ress");
                AssetReferenceGameObject assetReferenceGameObject = __instance.ChooseRandomResource();
                if (assetReferenceGameObject != null)
                {
                    QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-02 - Random Resouce is called");
                    if (Player.main.GetVehicle() is Exosuit exosuit)
                    {
                        var installedmodule = exosuit.modules.GetCount(MetalHands_BZ.MetalHandsClawModuleTechType);
                        if (((installedmodule > 0) | (MetalHands_BZ.Config.Config_fastcollect == true)) & exosuit.storageContainer.container.HasRoomFor(1, 1))
                        {
                            QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-10 - Start AddToPrawn over randomress");
                            CoroutineHost.StartCoroutine(AddtoPrawn(__instance, exosuit, assetReferenceGameObject));
                        }
                        else
                        {
                            QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-11 - Spawn original way randomress");
                            __instance.SpawnResourceFromPrefab(assetReferenceGameObject);
                        }
                    }
                    else
                    {
                        Inventory inventory = Inventory.Get();
                        if (((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands_BZ.MetalHandsMK2TechType) | (MetalHands_BZ.Config.Config_fastcollect == true)) & inventory.HasRoomFor(1, 1))
                        {
                            QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-20 - Player has glove - randomress");
                            CoroutineHost.StartCoroutine(AddbrokenRestoPlayerInv(__instance, assetReferenceGameObject));
                        }
                        else
                        {
                            QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-04 - Spawn original way - defaultress");
                            __instance.SpawnResourceFromPrefab(assetReferenceGameObject);
                        }
                    }
                    flag = true;
                }
            }
            if (!flag)
            {
                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-01 - default resouce is called");
                if (Player.main.GetVehicle() is Exosuit exosuit)
                {
                    var installedmodule = exosuit.modules.GetCount(MetalHands_BZ.MetalHandsClawModuleTechType);
                    if (((installedmodule > 0) | (MetalHands_BZ.Config.Config_fastcollect == true)) && exosuit.storageContainer.container.HasRoomFor(1, 1))
                    {
                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-02 - Start AddToPrawn over defaultress");
                        CoroutineHost.StartCoroutine(AddtoPrawn(__instance, exosuit, __instance.defaultPrefabReference));
                    }
                    else
                    {
                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-11 - Spawn original way randomress");
                        __instance.SpawnResourceFromPrefab(__instance.defaultPrefabReference);
                    }
                }
                else
                {
                    Inventory inventory = Inventory.Get();
                    if (((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands_BZ.MetalHandsMK2TechType) | (MetalHands_BZ.Config.Config_fastcollect == true)) & inventory.HasRoomFor(1, 1))
                    {
                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-03 - Player has glove - defaultress");
                        CoroutineHost.StartCoroutine(AddbrokenRestoPlayerInv(__instance, __instance.defaultPrefabReference));
                    }
                    else
                    {
                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-04 - Spawn original way - defaultress");
                        __instance.SpawnResourceFromPrefab(__instance.defaultPrefabReference);
                    }
                }
            }
            FMODUWE.PlayOneShot(__instance.breakSound, __instance.transform.position, 1f);
            if (__instance.hitFX)
            {
                global::Utils.PlayOneShotPS(__instance.breakFX, __instance.transform.position, Quaternion.Euler(new Vector3(270f, 0f, 0f)), null);
            }
        }
        private static void BreakIntoResources_Patch(BreakableResource __instance)
        {
            __instance.SendMessage("OnBreakResource", null, SendMessageOptions.DontRequireReceiver);
            if (__instance.gameObject.GetComponent <VFXBurstModel>())
            {
                __instance.gameObject.BroadcastMessage("OnKill");
            }
            else
            {
                UnityEngine.Object.Destroy(__instance.gameObject);
            }
            if (__instance.customGoalText != "")
            {
                GoalManager.main.OnCustomGoalEvent(__instance.customGoalText);
            }
            bool flag = false;

            for (int i = 0; i < __instance.numChances; i++)
            {
                GameObject gameObject = __instance.ChooseRandomResource();
                if (gameObject)
                {
                    QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "1 - Random Resouce is called");
                    if (Player.main.GetVehicle() is Exosuit exosuit)
                    {
                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "2 - Start AddToPrawn over randomress");
                        AddtoPrawn(__instance, exosuit, gameObject);
                    }
                    else
                    {
                        if ((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands.MetalHandsMK2TechType) | (MetalHands.Config.Config_fastcollect == true))
                        {
                            QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "3 - Player has glove - randomress");
                            Vector2int size      = CraftData.GetItemSize(CraftData.GetTechType(gameObject));
                            Inventory  inventory = Inventory.Get();
                            if (inventory.HasRoomFor(size.x, size.y))
                            {
                                CraftData.AddToInventory(CraftData.GetTechType(gameObject));
                            }
                            else
                            {
                                __instance.SpawnResourceFromPrefab(gameObject);
                            }
                        }
                        else
                        {
                            __instance.SpawnResourceFromPrefab(gameObject);
                        }
                    }
                    flag = true;
                }
            }
            if (!flag)
            {
                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "5 - default resouce is called");
                if (Player.main.GetVehicle() is Exosuit exosuit)
                {
                    QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "6 - Start AddToPrawn over defaultress");
                    AddtoPrawn(__instance, exosuit, __instance.defaultPrefab);
                }
                else if ((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands.MetalHandsMK2TechType) | (MetalHands.Config.Config_fastcollect == true))
                {
                    QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "7 - Player has glove - defaultress");
                    Vector2int size      = CraftData.GetItemSize(CraftData.GetTechType(__instance.defaultPrefab));
                    Inventory  inventory = Inventory.Get();
                    if (inventory.HasRoomFor(size.x, size.y))
                    {
                        CraftData.AddToInventory(CraftData.GetTechType(__instance.defaultPrefab));
                    }
                    else
                    {
                        __instance.SpawnResourceFromPrefab(__instance.defaultPrefab);
                    }
                }
                else
                {
                    __instance.SpawnResourceFromPrefab(__instance.defaultPrefab);
                }
            }
            FMODUWE.PlayOneShot(__instance.breakSound, __instance.transform.position, 1f);
            if (__instance.hitFX)
            {
                Utils.PlayOneShotPS(__instance.breakFX, __instance.transform.position, Quaternion.Euler(new Vector3(270f, 0f, 0f)), null);
            }

            QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "9 - Original Methode ending");
        }
Example #23
0
 static bool Prefix(CyclopsExternalCams __instance, ref bool __result)
 {
     if (CyclopsSettings.alternativeCameraControls)
     {
         if (!__instance.usingCamera)
         {
             __result = false;
             return(false);
         }
         if (!__instance.liveMixin.IsAlive())
         {
             __instance.ExitCamera();
             __result = false;
             return(false);
         }
         if (GameInput.GetButtonUp(GameInput.Button.Exit) || Input.GetKeyUp(KeyCode.Escape))
         {
             __instance.ExitCamera();
             __result = false;
             return(false);
         }
         if (GameInput.GetButtonDown(GameInput.Button.CycleNext))
         {
             __instance.ChangeCamera(1);
         }
         else if (GameInput.GetButtonDown(GameInput.Button.CyclePrev))
         {
             __instance.ChangeCamera(-1);
         }
         if (GameInput.GetButtonUp(GameInput.Button.RightHand))
         {
             if (CycleLightUp())
             {
                 FMODUWE.PlayOneShot(__instance.lightingPanel.vn_lightsOn, __instance.cameraLight.transform.position, 1f);
             }
             __instance.SetLight();
         }
         if (GameInput.GetButtonUp(GameInput.Button.LeftHand))
         {
             if (CycleLightDown())
             {
                 FMODUWE.PlayOneShot(__instance.lightingPanel.vn_lightsOff, __instance.cameraLight.transform.position, 1f);
             }
             __instance.SetLight();
         }
         if (GameInput.GetButtonUp(GameInput.Button.Slot1))
         {
             __instance.cameraIndex = 1;
             __instance.ChangeCamera(0);
         }
         if (GameInput.GetButtonUp(GameInput.Button.Slot2))
         {
             __instance.cameraIndex = 2;
             __instance.ChangeCamera(0);
         }
         if (GameInput.GetButtonUp(GameInput.Button.Slot3))
         {
             __instance.cameraIndex = 0;
             __instance.ChangeCamera(0);
         }
         __result = true;
         return(false);
     }
     return(true);
 }
        public static void playToothSound()
        {
            System.Random random = new System.Random();

            FMODUWE.PlayOneShot(CraftData.GetPrefabForTechType(TechType.Stalker).GetComponent <Stalker>().loseToothSound, new Vector3(Player.main.transform.position.x - random.Next(-8, 8), Player.main.transform.position.y - random.Next(-8, 7), Player.main.transform.position.z - random.Next(-7, 8)), 1f);
        }