public void Awake()
        {
            Main = this;

            seamoth     = gameObject.GetComponent <SeaMoth>();
            energyMixin = seamoth.GetComponent <EnergyMixin>();
            var repulsionCannonPrefab = Resources.Load <GameObject>("WorldEntities/Tools/RepulsionCannon").GetComponent <RepulsionCannon>();

            //RepulsionCannon repulsionCannonPrefab = CraftData.InstantiateFromPrefab(TechType.RepulsionCannon, false).GetComponent<RepulsionCannon>();
            shootSound = Instantiate(repulsionCannonPrefab.shootSound, seamoth.transform);
            //Destroy(repulsionCannonPrefab);

            loopingEmitter       = gameObject.AddComponent <FMOD_CustomLoopingEmitter>();
            loopingEmitter.asset = shootSound;

            var powerRelayPrefab = Resources.Load <GameObject>("Submarine/Build/PowerTransmitter").GetComponent <PowerFX>();

            //PowerFX powerRelayPrefab = CraftData.InstantiateFromPrefab(TechType.PowerTransmitter, false).GetComponent<PowerFX>();
            laserBeam = Instantiate(powerRelayPrefab.vfxPrefab, seamoth.transform);
            laserBeam.SetActive(false);
            //Destroy(powerRelayPrefab);

            lineRenderer                = laserBeam.GetComponent <LineRenderer>();
            lineRenderer.startWidth     = 0.4f;
            lineRenderer.endWidth       = 0.4f;
            lineRenderer.receiveShadows = false;
            lineRenderer.loop           = false;

            SetBeamColor();
        }
        public void Awake()
        {
            seamoth         = gameObject.GetComponent <SeaMoth>();
            leftTorpedoSlot = seamoth.torpedoTubeLeft.transform;
            energyMixin     = seamoth.GetComponent <EnergyMixin>();

            var scannerPrefab = Resources.Load <GameObject>("WorldEntities/Tools/Scanner").GetComponent <ScannerTool>();

            //ScannerTool scannerPrefab = CraftData.InstantiateFromPrefab(TechType.Scanner, false).GetComponent<ScannerTool>();
            scanSound     = Instantiate(scannerPrefab.scanSound, gameObject.transform);
            completeSound = Instantiate(scannerPrefab.completeSound, gameObject.transform);
            fxControl     = Instantiate(scannerPrefab.fxControl, gameObject.transform);
            scanBeam      = Instantiate(scannerPrefab.scanBeam, leftTorpedoSlot.transform);

            MeshRenderer[] renderers             = scannerPrefab.GetComponentsInChildren <MeshRenderer>(true);
            Renderer       instantiated_renderer = Instantiate(renderers[0]);

            scanCircuitTex = instantiated_renderer.materials[0].mainTexture;
            scanOrganicTex = instantiated_renderer.materials[2].mainTexture;

            //Destroy(instantiated_renderer);
            //Resources.UnloadAsset(scannerPrefab);

            scanBeam.transform.localScale    = new Vector3(1, 4, 1);
            scanBeam.transform.localRotation = new Quaternion(-0.7683826f, 0.1253118f, 0.0448633f, 0.6259971f);
        }
 void Awake()
 {
     rb            = GetComponentInParent <Rigidbody>();
     eatingEmitter = gameObject.EnsureComponent <FMOD_CustomLoopingEmitter>();
     eatingEmitter.SetAsset(eatingSound);
     eatingEmitter.followParent = true;
 }
Esempio n. 4
0
        private void Awake()
        {
            objectHelper = Main.graphics.objectHelper;

            animator = GetComponent <Animator>();

            front = objectHelper.FindDeepChild(gameObject, "hook").transform;
            ExosuitGrapplingArm component = GetComponent <ExosuitGrapplingArm>();

            hookPrefab = Instantiate(component.hookPrefab);
            rope       = objectHelper.GetObjectClone(component.rope);

            DestroyImmediate(hookPrefab.GetComponent <GrapplingHook>());
            DestroyImmediate(component);

            hook = hookPrefab.AddComponent <SeamothGrapplingHook>();
            hook.transform.parent        = front;
            hook.transform.localPosition = Vector3.zero;
            hook.transform.localRotation = Quaternion.identity;
            hook.transform.localScale    = new Vector3(1f, 1f, 1f);

            rope.attachPoint = hook.transform;

            grapplingLoopSound = GetComponent <FMOD_CustomLoopingEmitter>();

            shootSound      = ScriptableObject.CreateInstance <FMODAsset>();
            shootSound.path = "event:/sub/exo/hook_shoot";
            shootSound.name = "hook_shoot";
        }
        public void Awake()
        {
            //helper = new SeaTruckHelper(gameObject, false, false, false);
            helper = SeatruckServices.Main.GetSeaTruckHelper(gameObject);

            mainCab     = helper.MainCab;
            motor       = helper.TruckMotor;
            engineSound = motor.engineSound;
            rigidbody   = helper.TruckWorldForces.useRigidbody;

            CoroutineHost.StartCoroutine(LoadBiodomeRobotArmResourcesAsync());

            CoroutineHost.StartCoroutine(Init_Graphics());

            engineDefault      = ScriptableObject.CreateInstance <FMODAsset>();
            engineDefault.name = "engine";
            engineDefault.path = "event:/bz/vehicles/seatruck/engine";

            engine      = ScriptableObject.CreateInstance <FMODAsset>();
            engine.name = "engine";
            engine.path = "event:/sub/drone/motor_loop";

            isFlying.changedEvent.AddHandler(this, new Event <Utils.MonitoredValue <bool> > .HandleFunction(OnFlyModeChanged));

            mainCabExitPoint = helper.TruckSegment.exitPosition.localPosition;

            //helper.onPilotingBegin += OnPilotingBegin;

#if DEBUG
            CoroutineHost.StartCoroutine(InitDebugHUD());
#endif
        }
Esempio n. 6
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        internal AudioManager(FMOD_CustomLoopingEmitter emitter)
        {
            LoadFModAssets();

            _loopingEmitter = emitter;

            _loopingEmitter.asset = _loop;
        }
Esempio n. 7
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public AMMiniMedBayAudioManager(FMOD_CustomLoopingEmitter emitter)
        {
            LoadFModAssets();

            _loopingEmitter = emitter;

            _loopingEmitter.asset = _scanLoop;
        }
Esempio n. 8
0
        /// <summary>
        /// Default Constructor 
        /// </summary>
        public CubeGeneratorAudioHandler(FMOD_CustomLoopingEmitter emitter)
        {
            LoadFModAssets();

            _loopingEmitter = emitter;

            _loopingEmitter.asset = _waterFilterLoop;
        }
Esempio n. 9
0
        public static void Patch()
        {
            try
            {
                var harmony = HarmonyInstance.Create("MrPurple6411.SeamothDrillArm");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                var exosuit = Resources.Load <GameObject>("WorldEntities/Tools/Exosuit").GetComponent <Exosuit>();
                ExosuitThermalReactorCharge = exosuit.thermalReactorCharge;

                var exosuitDrillArmGO = (GameObject)GetArmPrefabMethod.Invoke(exosuit, new object[] { TechType.ExosuitDrillArmModule });
                var exosuitDrillArm   = exosuitDrillArmGO.GetComponent <ExosuitDrillArm>();
                DrillLoopHit = exosuitDrillArm.loopHit;
                DrillLoop    = exosuitDrillArm.loop;

                var path = @"./QMods/QuickMiner/mod.json";
                if (!File.Exists(path))
                {
                    Console.WriteLine("[SeamothDrillArm] Quick Miner not installed; node health set to default");
                }
                else
                {
                    Console.WriteLine("[SeamothDrillArm] Quick Miner IS installed; reading config...");
                    var    qmConfigJson      = File.ReadAllText(path);
                    string nodeHealthPattern = "\"NodeHealth\"\\s*:\\s*(\\d+\\.?\\d*)";
                    Match  match             = Regex.Match(qmConfigJson, nodeHealthPattern);
                    if (match.Success)
                    {
                        GroupCollection iAmGroup     = match.Groups;
                        float           qmNodeHealth = 0;
                        if (float.TryParse(iAmGroup[1].Value, out qmNodeHealth))
                        {
                            Console.WriteLine("[SeamothDrillArm] New node health is " + qmNodeHealth + ", based on QM config.");
                            DrillNodeHealth = qmNodeHealth;
                        }
                        else
                        {
                            Console.WriteLine("[SeamothDrillArm] Read QM config, but couldn't get the value! Using the default value of 50.");
                            DrillNodeHealth = 50f;
                        }
                    }
                    else
                    {
                        Console.WriteLine("[SeamothDrillArm] Couldn't find the node health config! Using the default value of 50.");
                        DrillNodeHealth = 50f;
                    }
                }

                PrefabHandler.RegisterPrefab(new SeamothDrillModule());

                Console.WriteLine("[SeamothDrillArm] Succesfully patched!");
            }
            catch (Exception e)
            {
                Console.WriteLine("[SeamothDrillArm] Caught exception! " + e.InnerException.Message);
                Console.WriteLine(e.InnerException.StackTrace);
            }
        }
        private void Awake()
        {
            objectHelper = Main.objectHelper;

            Instance    = gameObject.GetComponent <LaserCannonControl>();
            thisSeamoth = Instance.GetComponent <SeaMoth>();
            energyMixin = thisSeamoth.GetComponent <EnergyMixin>();
            playerMain  = Player.main;
            PdaMain     = playerMain.GetPDA();

            isPlayerInThisVehicle = playerMain.GetVehicle() == thisSeamoth ? true : false;

            GameObject repulsionCannonPrefab = Instantiate(Resources.Load <GameObject>("WorldEntities/Tools/RepulsionCannon"));

            shootSound = objectHelper.GetObjectClone(repulsionCannonPrefab.GetComponent <RepulsionCannon>().shootSound);

            DestroyImmediate(repulsionCannonPrefab);

            loopingEmitter       = gameObject.AddComponent <FMOD_CustomLoopingEmitter>();
            loopingEmitter.asset = shootSound;

            GameObject powerTransmitterPrefab = Instantiate(Resources.Load <GameObject>("Submarine/Build/PowerTransmitter"));

            GameObject laserBeam = objectHelper.GetGameObjectClone(powerTransmitterPrefab.GetComponent <PowerFX>().vfxPrefab, null, false);

            LineRenderer lineRenderer = laserBeam.GetComponent <LineRenderer>();

            lineRenderer.startWidth     = 0.2f;
            lineRenderer.endWidth       = 0.2f;
            lineRenderer.positionCount  = 2;
            lineRenderer.receiveShadows = false;
            lineRenderer.loop           = false;

            laserRight      = objectHelper.GetGameObjectClone(laserBeam, thisSeamoth.torpedoTubeRight, false);
            laserRight.name = "laserRight";
            laserRight.transform.localPosition = Vector3.zero;
            laserRight.transform.localRotation = Quaternion.identity;
            rightBeam = laserRight.GetComponent <LineRenderer>();

            laserLeft      = objectHelper.GetGameObjectClone(laserBeam, thisSeamoth.torpedoTubeLeft, false);
            laserLeft.name = "laserLeft";
            laserLeft.transform.localPosition = Vector3.zero;
            laserLeft.transform.localRotation = Quaternion.identity;
            leftBeam = laserLeft.GetComponent <LineRenderer>();

            DestroyImmediate(laserBeam);
            DestroyImmediate(powerTransmitterPrefab);

            OnConfigChanged(true);

            thisSeamoth.onToggle             += OnToggle;
            thisSeamoth.modules.onAddItem    += OnAddItem;
            thisSeamoth.modules.onRemoveItem += OnRemoveItem;
            playerMain.playerModeChanged.AddHandler(this, new Event <Player.Mode> .HandleFunction(OnPlayerModeChanged));

            Main.OnConfigChanged.AddHandler(this, new Event <bool> .HandleFunction(OnConfigChanged));
        }
Esempio n. 11
0
 public void Awake()
 {
     thisVehicle         = gameObject.GetComponent <Vehicle>();
     energyMixin         = thisVehicle.GetComponent <EnergyMixin>();
     weldSoundAsset      = ScriptableObject.CreateInstance <FMODAsset>();
     weldSoundAsset.path = "event:/tools/welder/weld_loop";
     weldSound           = gameObject.AddComponent <FMOD_CustomLoopingEmitter>();
     weldSound.asset     = weldSoundAsset;
     repairPerSec        = thisVehicle.liveMixin.maxHealth * 0.1f;
 }
Esempio n. 12
0
 public void AddEmitter(string path, FMOD_CustomLoopingEmitter loopingEmitter, float radius)
 {
     if (!customEmitters.ContainsKey(path))
     {
         loopingEmitters.Add(path, new KeyValuePair <FMOD_CustomLoopingEmitter, float>(loopingEmitter, radius));
     }
     else
     {
         Log.Warn($"[FMODEmitterController] loopingEmitters already contains {path}");
     }
 }
 public void Awake()
 {
     exosuit                 = gameObject.GetComponent <Exosuit>();
     energyMixin             = exosuit.GetComponent <EnergyMixin>();
     scanSoundAsset          = ScriptableObject.CreateInstance <FMODAsset>();
     scanSoundAsset.path     = "event:/tools/scanner/scan_loop";
     scanSound               = gameObject.AddComponent <FMOD_CustomLoopingEmitter>();
     scanSound.asset         = scanSoundAsset;
     completeSoundAsset      = ScriptableObject.CreateInstance <FMODAsset>();
     completeSoundAsset.path = "event:/tools/scanner/scan_complete";
 }
Esempio n. 14
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);
        }
 public static void Postfix(FMOD_CustomLoopingEmitter __instance)
 {
     if (__instance.assetStop && fmodSystem.IsWhitelisted(__instance.assetStop.path))
     {
         __instance.TryGetComponent(out NitroxEntity nitroxEntity);
         if (!nitroxEntity)
         {
             nitroxEntity = __instance.GetComponentInParent <NitroxEntity>();
         }
         if (nitroxEntity)
         {
             fmodSystem.PlayCustomLoopingEmitter(nitroxEntity.Id, __instance.assetStop.path);
         }
     }
 }
Esempio n. 16
0
        private void SetUpSound()
        {
            FMODSystem fmodSystem = NitroxServiceLocator.LocateService <FMODSystem>();

            rpmSound = seamoth.engineSound.engineRpmSFX;
            revSound = seamoth.engineSound.engineRevUp;

            rpmSound.followParent = true;
            revSound.followParent = true;

            fmodSystem.IsWhitelisted(rpmSound.asset.path, out bool _, out radiusRpmSound);
            fmodSystem.IsWhitelisted(revSound.asset.path, out bool _, out radiusRevSound);

            rpmSound.GetEventInstance().setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 1f);
            revSound.GetEventInstance().setProperty(EVENT_PROPERTY.MINIMUM_DISTANCE, 1f);
            rpmSound.GetEventInstance().setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, radiusRpmSound);
            revSound.GetEventInstance().setProperty(EVENT_PROPERTY.MAXIMUM_DISTANCE, radiusRevSound);
        }
Esempio n. 17
0
        public override GameObject GetGameObject()
        {
            var        prefab       = GameObject.Instantiate(_ionCubeGenPrefab);
            GameObject consoleModel = prefab.FindChild("model");

            // Update sky applier
            SkyApplier skyApplier = prefab.AddComponent <SkyApplier>();

            skyApplier.renderers = consoleModel.GetComponentsInChildren <MeshRenderer>();
            skyApplier.anchorSky = Skies.Auto;

            //Add the constructible component to the prefab
            Constructable constructible = prefab.AddComponent <Constructable>();

            CreateDisplayedIonCube(prefab);

            constructible.allowedInBase           = true;  // Only allowed in Base
            constructible.allowedInSub            = false; // Not allowed in Cyclops
            constructible.allowedOutside          = false;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = true; // Only on ground
            constructible.allowedOnWall           = false;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.rotationEnabled         = true;
            constructible.techType = this.TechType;
            constructible.model    = consoleModel;

            //Add the prefabIdentifier
            PrefabIdentifier prefabID = prefab.AddComponent <PrefabIdentifier>();

            prefabID.ClassId = this.ClassID;

            // Add the custom component
            CubeGeneratorMono cubeGenerator = prefab.AddComponent <CubeGeneratorMono>(); // Moved to the bottom to allow constructible to be added

            CubeGeneratorAnimator cubeGeneratorAnimator = prefab.AddComponent <CubeGeneratorAnimator>();

            IonGeneratorDisplay cubeGeneratorDisplay = prefab.AddComponent <IonGeneratorDisplay>();

            FMOD_CustomLoopingEmitter FMOD_CustomLoopingEmitter = prefab.AddComponent <FMOD_CustomLoopingEmitter>();

            return(prefab);
        }
        public void Awake()
        {
            thisVehicle = GetComponent <Vehicle>();
            energyMixin = thisVehicle.GetComponent <EnergyMixin>();

            weld_loop      = ScriptableObject.CreateInstance <FMODAsset>();
            weld_loop.name = "weld_loop";
            weld_loop.path = "event:/tools/welder/weld_loop";

            weldSound       = gameObject.AddComponent <FMOD_CustomLoopingEmitter>();
            weldSound.asset = weld_loop;

            repairPerSec = thisVehicle.liveMixin.maxHealth * 0.1f;

            thisVehicle.onToggle             += OnToggle;
            thisVehicle.modules.onAddItem    += OnAddItem;
            thisVehicle.modules.onRemoveItem += OnRemoveItem;

            Player.main.playerMotorModeChanged.AddHandler(this, new Event <Player.MotorMode> .HandleFunction(OnPlayerMotorModeChanged));

            moduleSlotID = GetSlotIndex(thisVehicle, RepairModulePrefab.TechTypeID);
        }
Esempio n. 19
0
        private void Awake()
        {
            animator     = GetComponent <Animator>();
            fxControl    = GetComponent <VFXController>();
            vfxEventType = VFXEventTypes.exoDrill;
            fxSpawnPoint = Main.graphics.objectHelper.FindDeepChild(gameObject, "FXSpawnPoint").transform;

            FMOD_CustomLoopingEmitter[] emitters = GetComponents <FMOD_CustomLoopingEmitter>();

            for (int i = 0; i < emitters.Length; i++)
            {
                if (emitters[i].asset.name.Equals("drill_loop"))
                {
                    loop = emitters[i];
                    loop.followParent = true;
                }

                if (emitters[i].asset.name.Equals("drill_hit_loop"))
                {
                    loopHit = emitters[i];
                    loopHit.followParent = true;
                }
            }
        }
        public void Awake()
        {
            thisExosuit     = GetComponent <Exosuit>();
            energyMixin     = thisExosuit.GetComponent <EnergyMixin>();
            handReticleMain = HandReticle.main;

            scan_loop       = ScriptableObject.CreateInstance <FMODAsset>();
            scan_loop.name  = "scan_loop";
            scan_loop.path  = "event:/tools/scanner/scan_loop";
            scanSound       = gameObject.AddComponent <FMOD_CustomLoopingEmitter>();
            scanSound.asset = scan_loop;

            completeSound      = ScriptableObject.CreateInstance <FMODAsset>();
            completeSound.name = "scan_complete";
            completeSound.path = "event:/tools/scanner/scan_complete";

            thisExosuit.onToggle             += OnToggle;
            thisExosuit.modules.onAddItem    += OnAddItem;
            thisExosuit.modules.onRemoveItem += OnRemoveItem;

            Player.main.playerMotorModeChanged.AddHandler(this, new Event <Player.MotorMode> .HandleFunction(OnPlayerMotorModeChanged));

            moduleCount = thisExosuit.modules.GetCount(ScannerModulePrefab.TechTypeID);
        }
Esempio n. 21
0
        private void Start()
        {
            animator     = GetComponent <Animator>();
            fxControl    = GetComponent <VFXController>();
            vfxEventType = VFXEventTypes.exoDrill;
            fxSpawnPoint = gameObject.FindChildInMaxDepth("FXSpawnPoint").transform;

            FMOD_CustomLoopingEmitter[] emitters = GetComponents <FMOD_CustomLoopingEmitter>();

            for (int i = 0; i < emitters.Length; i++)
            {
                if (emitters[i].asset.name.Equals("drill_loop"))
                {
                    loop = emitters[i];
                    loop.followParent = true;
                }

                if (emitters[i].asset.name.Equals("drill_hit_loop"))
                {
                    loopHit = emitters[i];
                    loopHit.followParent = true;
                }
            }
        }
Esempio n. 22
0
        public void Awake()
        {
            thisSeamoth     = GetComponent <SeaMoth>();
            leftTorpedoSlot = thisSeamoth.torpedoTubeLeft.transform;
            energyMixin     = thisSeamoth.GetComponent <EnergyMixin>();

            GameObject scannerPrefab = Instantiate(CraftData.GetPrefabForTechType(TechType.Scanner));

            scannerPrefab.SetActive(false);
            Utils.ZeroTransform(scannerPrefab.transform);

            ScannerTool scannerTool = scannerPrefab.GetComponent <ScannerTool>();

            GameObject ScannerModuleGO = new GameObject("ScannerModuleGO");

            ScannerModuleGO.transform.SetParent(leftTorpedoSlot.transform, false);
            Utils.ZeroTransform(ScannerModuleGO.transform);

            scan_loop       = ScriptableObject.CreateInstance <FMODAsset>();
            scan_loop.name  = "scan_loop";
            scan_loop.path  = "event:/tools/scanner/scan_loop";
            scanSound       = ScannerModuleGO.AddComponent <FMOD_CustomLoopingEmitter>();
            scanSound.asset = scan_loop;

            completeSound      = ScriptableObject.CreateInstance <FMODAsset>();
            completeSound.name = "scan_complete";
            completeSound.path = "event:/tools/scanner/scan_complete";

            fxControl = scannerTool.fxControl.GetComponentClone(ScannerModuleGO.transform);

            scanBeam = scannerPrefab.FindChild("x_ScannerBeam").GetPrefabClone(ScannerModuleGO.transform, false);

            scanCircuitTex = scannerTool.scanCircuitTex.CreateRWTextureFromNonReadableTexture();
            scanOrganicTex = scannerTool.scanOrganicTex.CreateRWTextureFromNonReadableTexture();

            scanCircuitColor = scannerTool.scanCircuitColor;
            scanOrganicColor = scannerTool.scanOrganicColor;

            scanBeam.transform.localPosition = new Vector3(0, 0, -0.37f);
            scanBeam.transform.localScale    = new Vector3(1, 4.41f, 1.55f);
            scanBeam.transform.localRotation = Quaternion.Euler(280, 184, 185);

            Destroy(scannerPrefab);
            Destroy(ScannerModuleGO.FindChild("Scanner(Clone)(Clone)"));



            SetFXActive(false);

            Shader shader = Shader.Find("FX/Scanning");

            if (shader != null)
            {
                scanMaterialCircuitFX = new Material(shader)
                {
                    hideFlags = HideFlags.HideAndDontSave
                };
                scanMaterialCircuitFX.SetTexture(ShaderPropertyID._MainTex, scanCircuitTex);
                scanMaterialCircuitFX.SetColor(ShaderPropertyID._Color, scanCircuitColor);
                scanMaterialOrganicFX = new Material(shader)
                {
                    hideFlags = HideFlags.HideAndDontSave
                };
                scanMaterialOrganicFX.SetTexture(ShaderPropertyID._MainTex, scanOrganicTex);
                scanMaterialOrganicFX.SetColor(ShaderPropertyID._Color, scanOrganicColor);
            }

            thisSeamoth.onToggle             += OnToggle;
            thisSeamoth.modules.onAddItem    += OnAddItem;
            thisSeamoth.modules.onRemoveItem += OnRemoveItem;

            Player.main.playerMotorModeChanged.AddHandler(this, new Event <Player.MotorMode> .HandleFunction(OnPlayerMotorModeChanged));

            moduleCount = thisSeamoth.modules.GetCount(ScannerModulePrefab.TechTypeID);
        }
 /// <summary>
 /// Default Constructor
 /// </summary>
 internal AudioManager(FMOD_CustomLoopingEmitter emitter)
 {
     _loopingEmitter = emitter;
 }
Esempio n. 24
0
        public static void Patch()
        {
            try
            {
                #region Patching

                var harmony = HarmonyInstance.Create("com.ahk1221.moreseamothupgrades");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                LanguagePatcher.customLines.Add("Tooltip_VehicleHullModule3", "Enhances diving depth. Does not stack"); // To update conflicts about the maximity.

                #endregion

                #region Extract From Exosuit

                var exosuit = Resources.Load <GameObject>("WorldEntities/Tools/Exosuit").GetComponent <Exosuit>();
                ExosuitThermalReactorCharge = exosuit.thermalReactorCharge;

                var exosuitDrillArmGO = (GameObject)GetArmPrefabMethod.Invoke(exosuit, new object[] { TechType.ExosuitDrillArmModule });
                var exosuitDrillArm   = exosuitDrillArmGO.GetComponent <ExosuitDrillArm>();
                DrillLoopHit = exosuitDrillArm.loopHit;
                DrillLoop    = exosuitDrillArm.loop;

                #endregion

                #region Add TechTypes

                SeamothHullModule4   = TechTypePatcher.AddTechType("SeamothHullModule4", "Seamoth depth module MK4", "Enhances diving depth. Does not stack.");
                SeamothHullModule5   = TechTypePatcher.AddTechType("SeamothHullModule5", "Seamoth depth module MK5", "Enhances diving depth to maximum. Does not stack.");
                SeamothThermalModule = TechTypePatcher.AddTechType("SeamothThermalModule", "Seamoth thermal reactor", "Recharges power cells in hot areas. Doesn't stack.");
                SeamothDrillModule   = TechTypePatcher.AddTechType("SeamothDrillModule", "Seamoth drill module", "Enables the Seamoth to mine resources like the PRAWN Drill Arm.");

                #endregion

                #region Add Recipes

                var seamothHullModule4Recipe = new TechDataHelper()
                {
                    _techType    = SeamothHullModule4,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(TechType.VehicleHullModule3, 1),
                        new IngredientHelper(TechType.PlasteelIngot, 1),
                        new IngredientHelper(TechType.Nickel, 2),
                        new IngredientHelper(TechType.AluminumOxide, 3)
                    },
                    _craftAmount = 1
                };

                var seamothHullModule5Recipe = new TechDataHelper()
                {
                    _techType    = SeamothHullModule5,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(SeamothHullModule4, 1),
                        new IngredientHelper(TechType.Titanium, 5),
                        new IngredientHelper(TechType.Lithium, 2),
                        new IngredientHelper(TechType.Kyanite, 3)
                    },
                    _craftAmount = 1
                };

                var seamothThermalModuleRecipe = new TechDataHelper()
                {
                    _techType    = SeamothThermalModule,
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(TechType.Kyanite, 1),
                        new IngredientHelper(TechType.Polyaniline, 2),
                        new IngredientHelper(TechType.WiringKit, 1)
                    }
                };

                var seamothDrillModuleRecipe = new TechDataHelper()
                {
                    _techType    = SeamothDrillModule,
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(TechType.ExosuitDrillArmModule, 1),
                        new IngredientHelper(TechType.Diamond, 2),
                        new IngredientHelper(TechType.Titanium, 2)
                    }
                };

                CraftDataPatcher.customTechData[SeamothHullModule4]   = seamothHullModule4Recipe;
                CraftDataPatcher.customTechData[SeamothHullModule5]   = seamothHullModule5Recipe;
                CraftDataPatcher.customTechData[SeamothThermalModule] = seamothThermalModuleRecipe;
                CraftDataPatcher.customTechData[SeamothDrillModule]   = seamothDrillModuleRecipe;

                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothHullModule4, CraftTree.Type.Workbench, "SeamothMenu/SeamothHullModule4"));
                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothHullModule5, CraftTree.Type.Workbench, "SeamothMenu/SeamothHullModule5"));
                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothThermalModule, CraftTree.Type.SeamothUpgrades, "SeamothModules/SeamothThermalModule"));
                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothDrillModule, CraftTree.Type.SeamothUpgrades, "SeamothModules/SeamothDrillModule"));

                #endregion

                #region Equipment Types

                CraftDataPatcher.customEquipmentTypes[SeamothHullModule4]   = EquipmentType.SeamothModule;
                CraftDataPatcher.customEquipmentTypes[SeamothHullModule5]   = EquipmentType.SeamothModule;
                CraftDataPatcher.customEquipmentTypes[SeamothThermalModule] = EquipmentType.SeamothModule;
                CraftDataPatcher.customEquipmentTypes[SeamothDrillModule]   = EquipmentType.SeamothModule;

                //TODO: SMLHelper: Add CraftDataPatcher.customSlotTypes.
                var slotTypes = (Dictionary <TechType, QuickSlotType>) typeof(CraftData).GetField("slotTypes", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
                slotTypes[SeamothDrillModule] = QuickSlotType.Selectable;

                #endregion

                #region Add Prefabs

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothHullModule4",
                                                          "WorldEntities/Tools/SeamothHullModule4",
                                                          SeamothHullModule4,
                                                          GetSeamothHullModuleIV));

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothHullModule5",
                                                          "WorldEntities/Tools/SeamothHullModule5",
                                                          SeamothHullModule5,
                                                          GetSeamothHullModuleV));

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothThermalModule",
                                                          "WorldEntities/Tools/SeamothThermalModule",
                                                          SeamothThermalModule,
                                                          GetSeamothThermalModule));

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothDrillModule",
                                                          "WorldEntities/Tools/SeamothDrillModule",
                                                          SeamothDrillModule,
                                                          GetSeamothDrillModule));

                #endregion

                #region Add Sprites

                var depthSprite = SpriteManager.Get(TechType.VehicleHullModule3);

                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothHullModule4, depthSprite));
                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothHullModule5, depthSprite));

                var thermalReactorSprite = SpriteManager.Get(TechType.ExosuitThermalReactorModule);

                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothThermalModule, thermalReactorSprite));

                var assetBundle = AssetBundle.LoadFromFile(@"./QMods/MoreSeamothUpgrades/moreseamothupgrades.assets");
                var drillSprite = assetBundle.LoadAsset <Sprite>("SeamothDrill");

                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothDrillModule, drillSprite));

                #endregion

                Console.WriteLine("[MoreSeamothUpgrades] Succesfully patched!");
            }
            catch (Exception e)
            {
                Console.WriteLine("[MoreSeamothUpgrades] Caught exception! " + e.InnerException.Message);
                Console.WriteLine(e.InnerException.StackTrace);
            }
        }