public static void MonitorSeamothBatteryCount(SeaMoth thisSeaMoth)
        {
            EnergyMixin energyMixin = thisSeaMoth.gameObject.GetComponent <EnergyMixin>();

            if (energyMixin != null)
            {
                GameObject thisGameObject = energyMixin.GetBattery();

                if (thisGameObject != null)
                {
                    SeamothInfo.BatteryInSlot = 1;
                }
                else
                {
                    SeamothInfo.BatteryInSlot = 0;
                }
            }

            SeamothInfo.MainBatteryCount = 0;

            foreach (InventoryItem item in Inventory.main.container)
            {
                if (energyMixin.Filter(item))
                {
                    SeamothInfo.MainBatteryCount += 1;
                }
            }

            SeamothInfo.TotalBatteryCount = SeamothInfo.BatteryInSlot + SeamothInfo.MainBatteryCount;
        }
        private void Awake()
        {
            seamoth = GetComponent <SeaMoth>();

            objectHelper = ArmServices.main.objectHelper;

            vfxConstructing = GetComponent <VFXConstructing>();

            light_left         = objectHelper.FindDeepChild(gameObject, "light_left").transform;
            light_left_default = new PureTransform(light_left.localPosition, light_left.localRotation, light_left.localScale);
            light_left_UP      = new PureTransform(new Vector3(0f, 0.68f, 1f), Quaternion.Euler(0, 0, 0), light_left.localScale);

            light_right         = objectHelper.FindDeepChild(gameObject, "light_right").transform;
            light_right_default = new PureTransform(light_right.localPosition, light_right.localRotation, light_right.localScale);
            light_right_DOWN    = new PureTransform(new Vector3(0f, -1.21f, 1.04f), Quaternion.Euler(35, 0, 0), light_left.localScale);

            GameObject leftArmAttachPoint = objectHelper.CreateGameObject("leftArmAttachPoint", seamoth.torpedoTubeLeft, new Vector3(-0.93f, 0f, -0.74f), new Vector3(346, 23, 0));

            leftArmAttach = leftArmAttachPoint.transform;

            GameObject rightArmAttachPoint = objectHelper.CreateGameObject("rightArmAttachPoint", seamoth.torpedoTubeRight, new Vector3(0.93f, 0f, -0.74f), new Vector3(346, 337, 360));

            rightArmAttach = rightArmAttachPoint.transform;

            GameObject leftAimForward = objectHelper.CreateGameObject("leftAimForward", seamoth.transform);

            aimTargetLeft = leftAimForward.transform;

            GameObject rightAimForward = objectHelper.CreateGameObject("rightAimForward", seamoth.transform);

            aimTargetRight = rightAimForward.transform;
        }
        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);
        }
        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();
        }
Esempio n. 5
0
        public override GameObject GetGameObject()
        {
            if (PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.Seamoth), out string seamothFileName))
            {
                GameObject prefab     = Resources.Load <GameObject>(seamothFileName);
                GameObject gameObject = GameObject.Instantiate(prefab);
                prefab.SetActive(false);
                gameObject.SetActive(false);

                SeaMoth seaMoth = gameObject.GetComponent <SeaMoth>();

                SeamothCloneBehaviour seamothCloneBehaviour = gameObject.EnsureComponent <SeamothCloneBehaviour>();

                typeof(SeaMoth).GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Static).ForEach((x) => { try { x.SetValue(seamothCloneBehaviour, x.GetValue(seaMoth)); } catch { } });

                seamothCloneBehaviour.energyInterface = seaMoth.energyInterface;

                GameObject.DestroyImmediate(seaMoth);

                gameObject.SetActive(true);
                return(gameObject);
            }

            return(GameObject.CreatePrimitive(PrimitiveType.Cube));
        }
        private void Start()
        {
            objectHelper = new ObjectHelper();

            thisSeamoth = GetComponent <SeaMoth>();
            liveMixin   = GetComponent <LiveMixin>();
            energyMixin = GetComponent <EnergyMixin>();

            shield_on_loop      = ScriptableObject.CreateInstance <FMODAsset>();
            shield_on_loop.name = "shield_on_loop";
            shield_on_loop.path = "event:/sub/cyclops/shield_on_loop";
            sfx              = gameObject.AddComponent <FMOD_CustomEmitter>();
            sfx.asset        = shield_on_loop;
            sfx.followParent = true;

            GameObject CyclopsPrefab = objectHelper.GetRootGameObject("Cyclops", "Cyclops-MainPrefab");

            SubRoot subRoot = CyclopsPrefab.GetComponent <SubRoot>();

            shieldFX = Instantiate(subRoot.shieldFX, transform);

            shieldFX.gameObject.SetActive(false);

            Utils.ZeroTransform(shieldFX.transform);

            shieldFX.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);

            thisSeamoth.onToggle             += OnToggle;
            thisSeamoth.modules.onAddItem    += OnAddItem;
            thisSeamoth.modules.onRemoveItem += OnRemoveItem;
        }
Esempio n. 7
0
 static void Postfix(SeaMoth __instance, int slotID, TechType techType, bool added)
 {
     if (techType == LaserCannon.TechTypeID)
     {
         if (added)
         {
             if (__instance.GetComponent <LaserCannon_Seamoth>() == null)
             {
                 var laserCannon = __instance.gameObject.AddComponent <LaserCannon_Seamoth>();
                 laserCannon.slotID = slotID;
                 Debug.Log($"[LaserCannon] Added component to instance: {__instance.name} ID: {__instance.GetInstanceID()}");
             }
             else
             {
                 var laserCannon = __instance.GetComponent <LaserCannon_Seamoth>();
                 laserCannon.seamoth = __instance.GetComponent <SeaMoth>();
                 laserCannon.slotID  = slotID;
                 laserCannon.enabled = true;
             }
         }
         else
         {
             __instance.GetComponent <LaserCannon_Seamoth>().enabled = false;
         }
     }
 }
        internal static void PreSeamothAwake(ref SeaMoth __instance)
        {
            QuickLogger.Debug(nameof(PreSeamothAwake));
            VehicleUpgrader vehicleUpgrader = __instance.gameObject.EnsureComponent <VehicleUpgrader>();

            vehicleUpgrader.Initialize(ref __instance);
        }
Esempio n. 9
0
        static void Postfix(SeaMoth __instance, int slotID, bool active)
        {
            // Find the TechType in the toggled slot.
            // Valid inputs would be along the lines of: SeamothModule1, SeamothModule2, etc
            // slotID is 0-based, so an addition of 1 is required.
            var techType = __instance.modules.GetTechTypeInSlot($"SeamothModule{slotID + 1}");

            // If its the SeamothClawModule
            if (techType == SeamothModule.SeamothClawModule)
            {
                // Get the SeamothClaw component from the SeaMoth object.
                var seamothClawModule = __instance.GetComponent <SeamothClaw>();

                // If its not null
                if (seamothClawModule != null)
                {
                    // Set its toggle!
                    seamothClawModule.toggle = active;
                }
            }
            // If its the SeamothDrillModule
            else if (techType == SeamothModule.SeamothDrillModule)
            {
                // Get the SeamothDrill component from the SeaMoth object.
                var seamothDrillModule = __instance.GetComponent <SeamothDrill>();

                // If its not null
                if (seamothDrillModule != null)
                {
                    // Set its toggle!
                    seamothDrillModule.toggle = active;
                }
            }
        }
        internal static void Prefix(ref SeaMoth __instance)
        {
            QuickLogger.Debug("SeaMoth_Start_Patcher");
            VehicleUpgrader vehicleUpgrader = __instance.gameObject.EnsureComponent <VehicleUpgrader>();

            vehicleUpgrader.Initialize(ref __instance);
        }
        public static void CreateVolumetricLight(Light light, SeaMoth seaMothTemplate, Vector3 offset = new Vector3())
        {
            var templateVolumetricLight = seaMothTemplate.toggleLights.lightsParent.GetComponentInChildren <VFXVolumetricLight>();
            var volumetricLight         = light.gameObject.GetComponent <VFXVolumetricLight>();

            if (volumetricLight == null)
            {
                volumetricLight = light.gameObject.AddComponent <VFXVolumetricLight>();
            }

            System.Reflection.FieldInfo[] volumetricLightFields = volumetricLight.GetType().GetFields();
            foreach (System.Reflection.FieldInfo field in volumetricLightFields)
            {
                field.SetValue(volumetricLight, field.GetValue(templateVolumetricLight));
            }

            var volume = GameObject.Instantiate(templateVolumetricLight.volumGO, light.transform).gameObject;

            volume.transform.localScale    = CalculateLightCone(light);
            light.transform.localPosition += offset;

            volumetricLight.volumGO     = volume;
            volumetricLight.lightSource = light;
            volumetricLight.block       = null;
            volumetricLight.angle       = (int)light.spotAngle;
            volumetricLight.intensity   = 0.45f;

            volumetricLight.Awake();
        }
        private static float fActiveModeHealthRegenMultiplier    = 5f; // Health regeneration is multiplied by this amount in active mode


        protected void Start()
        {
            string RCFilename;

            if (thermalReactorCharge is null && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.Exosuit), out RCFilename))
            {
                AddressablesUtility.LoadAsync <GameObject>(RCFilename).Completed += (x) =>
                {
                    GameObject gameObject1 = x.Result;
                    Exosuit    exosuit     = gameObject1?.GetComponent <Exosuit>();
                    thermalReactorCharge = exosuit?.thermalReactorCharge;
                };
            }

            if (sonarSound is null && PrefabDatabase.TryGetPrefabFilename(CraftData.GetClassIdForTechType(TechType.Seamoth), out RCFilename))
            {
                AddressablesUtility.LoadAsync <GameObject>(RCFilename).Completed += (x) =>
                {
                    GameObject gameObject1 = x.Result;
                    SeaMoth    seamoth     = gameObject1?.GetComponent <SeaMoth>();
                    if (seamoth?.sonarSound != null)
                    {
                        sonarSound = this.gameObject.AddComponent <FMOD_CustomEmitter>();
                        sonarSound.SetAsset(seamoth.sonarSound.asset);
                        sonarSound.UpdateEventAttributes();
                    }
                    foreach (var r in gameObject1.GetComponentsInChildren <Renderer>())
                    {
                    }
                };
            }
        }
Esempio n. 13
0
 static void Postfix(SeaMoth __instance, bool docked)
 {
     if (docked)
     {
         __instance.toggleLights.SetLightsActive(false);
     }
 }
        // Forgive me father for I have sinned
        // someone replace this horrid code.... maybe loop through types and reflect them all OR circumvent the need for this

        public static Optional <Equipment> GetBasedOnOwnersType(GameObject owner)
        {
            Charger charger = owner.GetComponent <Charger>();

            if (charger != null)
            {
                return(Optional <Equipment> .Of((Equipment)charger.ReflectionGet("equipment")));
            }

            BaseNuclearReactor baseNuclearReactor = owner.GetComponent <BaseNuclearReactor>();

            if (baseNuclearReactor != null)
            {
                return(Optional <Equipment> .Of((Equipment)baseNuclearReactor.ReflectionGet("_equipment")));
            }

            CyclopsDecoyLoadingTube cyclopsDecoyLoadingTube = owner.GetComponent <CyclopsDecoyLoadingTube>();

            if (cyclopsDecoyLoadingTube != null)
            {
                return(Optional <Equipment> .Of(cyclopsDecoyLoadingTube.decoySlots));
            }

            Exosuit exosuit = owner.GetComponent <Exosuit>();

            if (exosuit != null)
            {
                return(Optional <Equipment> .Of(exosuit.modules));
            }

            SeaMoth seamoth = owner.GetComponent <SeaMoth>();

            if (seamoth != null)
            {
                return(Optional <Equipment> .Of(seamoth.modules));
            }

            UpgradeConsole upgradeConsole = owner.GetComponent <UpgradeConsole>();

            if (upgradeConsole != null)
            {
                return(Optional <Equipment> .Of(upgradeConsole.modules));
            }

            Vehicle vehicle = owner.GetComponent <Vehicle>();

            if (vehicle != null)
            {
                return(Optional <Equipment> .Of(vehicle.modules));
            }

            VehicleUpgradeConsoleInput vehicleUpgradeConsoleInput = owner.GetComponent <VehicleUpgradeConsoleInput>();

            if (vehicleUpgradeConsoleInput != null)
            {
                return(Optional <Equipment> .Of(vehicleUpgradeConsoleInput.equipment));
            }

            return(Optional <Equipment> .Empty());
        }
        public override void Process(VehicleMovement vehicleMovement)
        {
            Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(vehicleMovement.Guid);

            RemotePlayer player = remotePlayerManager.FindOrCreate(vehicleMovement.PlayerId);

            Vector3    remotePosition  = vehicleMovement.Position;
            Vector3    remoteVelocity  = vehicleMovement.Velocity;
            Quaternion remoteRotation  = vehicleMovement.BodyRotation;
            Vector3    angularVelocity = vehicleMovement.AngularVelocity;

            Vehicle vehicle = null;
            SubRoot subRoot = null;

            if (opGameObject.IsPresent())
            {
                GameObject gameObject = opGameObject.Get();

                vehicle = gameObject.GetComponent <Vehicle>();
                subRoot = gameObject.GetComponent <SubRoot>();

                MultiplayerVehicleControl mvc = null;

                if (subRoot != null)
                {
                    mvc = subRoot.gameObject.EnsureComponent <MultiplayerCyclops>();
                }
                else if (vehicle != null)
                {
                    SeaMoth seamoth = vehicle as SeaMoth;
                    Exosuit exosuit = vehicle as Exosuit;

                    if (seamoth)
                    {
                        mvc = seamoth.gameObject.EnsureComponent <MultiplayerSeaMoth>();
                    }
                    else if (exosuit)
                    {
                        mvc = exosuit.gameObject.EnsureComponent <MultiplayerExosuit>();
                    }
                }

                if (mvc != null)
                {
                    mvc.SetPositionVelocityRotation(remotePosition, remoteVelocity, remoteRotation, angularVelocity);
                    mvc.SetThrottle(vehicleMovement.AppliedThrottle);
                    mvc.SetSteeringWheel(vehicleMovement.SteeringWheelYaw, vehicleMovement.SteeringWheelPitch);
                }
            }
            else
            {
                CreateVehicleAt(player, vehicleMovement.TechType, vehicleMovement.Guid, remotePosition, remoteRotation);
            }
            player.SetVehicle(vehicle);
            player.SetSubRoot(subRoot);
            player.SetPilotingChair(subRoot?.GetComponentInChildren <PilotingChair>());

            player.AnimationController.UpdatePlayerAnimations = false;
        }
        static void Postfix(SeaMoth __instance, TechType techType)
        {
            // Dictionary of TechTypes and their depth additions.
            var dictionary = new Dictionary <TechType, float>
            {
                {
                    TechType.SeamothReinforcementModule,
                    800f
                },
                {
                    TechType.VehicleHullModule1,
                    100f
                },
                {
                    TechType.VehicleHullModule2,
                    300f
                },
                {
                    TechType.VehicleHullModule3,
                    700f
                },
                {
                    Main.SeamothHullModule4,
                    1100f
                },
                {
                    Main.SeamothHullModule5,
                    1500f
                }
            };

            // Depth upgrade to add.
            var depthUpgrade = 0f;

            // Loop through all slots.
            for (int i = 0; i < SeamothUtility.slotIDs.Length; i++)
            {
                // Get the slot and the TechType
                var slot           = SeamothUtility.slotIDs[i];
                var techTypeInSlot = __instance.modules.GetTechTypeInSlot(slot);

                // If its one of the depth modules
                if (dictionary.ContainsKey(techTypeInSlot))
                {
                    // Get the depth upgrade for that TechType
                    var currentIteration = dictionary[techTypeInSlot];

                    // If the upgrade is more than the one currently selected
                    if (currentIteration > depthUpgrade)
                    {
                        // Select this one!
                        depthUpgrade = currentIteration;
                    }
                }
            }

            // Add the upgrade.
            __instance.crushDamage.SetExtraCrushDepth(depthUpgrade);
        }
Esempio n. 17
0
 static void Postfix(SeaMoth __instance, int slotID, TechType techType, bool added)
 {
     if (techType == LaserCannonPrefab.TechTypeID && added)
     {
         var control = __instance.gameObject.EnsureComponent <LaserCannonControl>();
         control.moduleSlotID = slotID;
     }
 }
        internal static void Postfix(SeaMoth __instance)
        {
            if (__instance.GetComponent <SlotExtender>() == null)
            {
                __instance.gameObject.AddComponent <SlotExtender>();

                Debug.Log($"[SlotExtender] Added component to instance: {__instance.name} ID: {__instance.GetInstanceID()}");
            }
        }
Esempio n. 19
0
        private void CreateToggleLights(SeaMoth seaMothTemplate)
        {
            var seaMothToggleLights = seaMothTemplate.toggleLights;

            lightsOnSound  = seaMothToggleLights.lightsOnSound;
            lightsOffSound = seaMothToggleLights.lightsOffSound;
            onSound        = seaMothToggleLights.onSound;
            offSound       = seaMothToggleLights.offSound;
        }
        static void Prefix(SeaMoth __instance)
        {
            var updateContainer = __instance.upgradesInput;

            if (Input.GetKeyDown(Main.UpgradeKey) && !Player.main.GetPDA().isOpen&& Player.main.GetVehicle() == __instance)
            {
                updateContainer.OpenFromExternal();
            }
        }
Esempio n. 21
0
 [HarmonyPrefix]      // Harmony Prefix
 public static bool Prefix(SeaMoth __instance)
 {
     // Kickstart battery monitoring
     if (__instance.GetPilotingMode())
     {
         MonitorBatteryCount.MonitorSeamothBatteryCount(__instance);
     }
     return(true);
 } // end public static void Postfix()
Esempio n. 22
0
        public void UpdateVehiclePosition(VehicleMovementData vehicleModel, Optional <RemotePlayer> player)
        {
            Vector3    remotePosition  = vehicleModel.Position;
            Vector3    remoteVelocity  = vehicleModel.Velocity;
            Quaternion remoteRotation  = vehicleModel.Rotation;
            Vector3    angularVelocity = vehicleModel.AngularVelocity;

            Vehicle vehicle = null;
            SubRoot subRoot = null;

            Optional <GameObject> opGameObject = GuidHelper.GetObjectFrom(vehicleModel.Guid);

            if (opGameObject.IsPresent())
            {
                GameObject gameObject = opGameObject.Get();

                vehicle = gameObject.GetComponent <Vehicle>();
                subRoot = gameObject.GetComponent <SubRoot>();

                MultiplayerVehicleControl mvc = null;

                if (subRoot != null)
                {
                    mvc = subRoot.gameObject.EnsureComponent <MultiplayerCyclops>();
                }
                else if (vehicle != null)
                {
                    SeaMoth seamoth = vehicle as SeaMoth;
                    Exosuit exosuit = vehicle as Exosuit;

                    if (seamoth)
                    {
                        mvc = seamoth.gameObject.EnsureComponent <MultiplayerSeaMoth>();
                    }
                    else if (exosuit)
                    {
                        mvc = exosuit.gameObject.EnsureComponent <MultiplayerExosuit>();
                    }
                }

                if (mvc != null)
                {
                    mvc.SetPositionVelocityRotation(remotePosition, remoteVelocity, remoteRotation, angularVelocity);
                    mvc.SetThrottle(vehicleModel.AppliedThrottle);
                    mvc.SetSteeringWheel(vehicleModel.SteeringWheelYaw, vehicleModel.SteeringWheelPitch);
                }
            }

            if (player.IsPresent())
            {
                RemotePlayer playerInstance = player.Get();
                playerInstance.SetVehicle(vehicle);
                playerInstance.SetSubRoot(subRoot);
                playerInstance.SetPilotingChair(subRoot?.GetComponentInChildren <PilotingChair>());
                playerInstance.AnimationController.UpdatePlayerAnimations = false;
            }
        }
Esempio n. 23
0
        protected override void Awake()
        {
            seamoth          = GetComponent <SeaMoth>();
            WheelYawSetter   = value => seamoth.steeringWheelYaw = value;
            WheelPitchSetter = value => seamoth.steeringWheelPitch = value;

            SetUpSound();
            base.Awake();
        }
Esempio n. 24
0
        internal static void Postfix(SeaMoth __instance)
        {
            string name = __instance.name;
            int    ID   = __instance.GetInstanceID();

            __instance.gameObject.AddIfNeedComponent <SlotExtender>();

            SNLogger.Log($"[{SEConfig.PROGRAM_NAME}] component added to instance: {name} ID: {ID}");
        }
Esempio n. 25
0
        public void BroadcastElectricalDefense(TechType techType, int slotID, SeaMoth instance)
        {
            string Guid = GuidHelper.GetGuid(instance.gameObject);

            if (techType == TechType.SeamothElectricalDefense)
            {
                SeamothModulesAction Changed = new SeamothModulesAction(techType, slotID, Guid, Player.main.camRoot.GetAimingTransform().forward, Player.main.camRoot.GetAimingTransform().rotation);
                packetSender.Send(Changed);
            }
        }
Esempio n. 26
0
        public void BroadcastElectricalDefense(TechType techType, int slotID, SeaMoth instance)
        {
            NitroxId id = NitroxIdentifier.GetId(instance.gameObject);

            if (techType == TechType.SeamothElectricalDefense)
            {
                SeamothModulesAction Changed = new SeamothModulesAction(techType.Model(), slotID, id, Player.main.camRoot.GetAimingTransform().forward, Player.main.camRoot.GetAimingTransform().rotation);
                packetSender.Send(Changed);
            }
        }
Esempio n. 27
0
        private static void Postfix(SeaMoth __instance)
        {
            // Dictionary of TechTypes and their depth additions.
            var dictionary = new Dictionary <TechType, float>
            {
                {
                    TechType.SeamothReinforcementModule,
                    800f
                },
                {
                    TechType.VehicleHullModule1,
                    100f
                },
                {
                    TechType.VehicleHullModule2,
                    300f
                },
                {
                    TechType.VehicleHullModule3,
                    700f
                },
                {
                    Main.moduleMK4.TechType,
                    1100f
                },
                {
                    Main.moduleMK5.TechType,
                    1500f
                }
            };

            // Depth upgrade to add.
            var depthUpgrade = 0f;

            // Loop through available depth module upgrades
            foreach (var entry in dictionary)
            {
                var depthTechType = entry.Key;
                var depthAddition = entry.Value;

                var count = __instance.modules.GetCount(depthTechType);

                // If you have at least 1 such depth module
                if (count > 0)
                {
                    if (depthAddition > depthUpgrade)
                    {
                        depthUpgrade = depthAddition;
                    }
                }
            }

            // Add the upgrade.
            __instance.crushDamage.SetExtraCrushDepth(depthUpgrade);
        }
Esempio n. 28
0
        private void OnCollisionEnter(Collision collisionInfo)
        {
            SeaMoth componentInParent = collisionInfo.gameObject.GetComponentInParent <SeaMoth>();

            GrapplingHook component = collisionInfo.gameObject.GetComponent <GrapplingHook>();

            if (staticAttached || (fixedJoint && fixedJoint.connectedBody) || componentInParent != null || component != null)
            {
                return;
            }

            Rigidbody targetRigidbody = GetTargetRigidbody(collisionInfo.gameObject);

            rb.velocity = Vector3.zero;

            if (targetRigidbody != null && JointHelper.ConnectFixed(gameObject, targetRigidbody))
            {
                staticAttached = false;
            }
            else
            {
                staticAttached = true;
                rb.isKinematic = true;
            }

            Utils.PlayFMODAsset(hitSound, transform, 5f);

            Vector3 vector = default(Vector3);

            int num = 0;

            for (int i = 0; i < collisionInfo.contacts.Length; i++)
            {
                ContactPoint contactPoint = collisionInfo.contacts[i];
                if (num == 0)
                {
                    vector = contactPoint.normal;
                }
                else
                {
                    vector += contactPoint.normal;
                }
                num++;
            }
            if (num > 0)
            {
                vector /= num;
                Vector3 eulerAngles = Quaternion.LookRotation(transform.forward, vector).eulerAngles;
                eulerAngles.z        -= 90f;
                transform.eulerAngles = eulerAngles;
            }
            VFXSurface component2 = collisionInfo.gameObject.GetComponent <VFXSurface>();

            VFXSurfaceTypeManager.main.Play(component2, VFXEventTypes.impact, transform.position, transform.rotation, null);
        }
Esempio n. 29
0
        public void BroadcastElectricalDefense(TechType techType, int slotID, SeaMoth instance)
        {
            NitroxId id = NitroxEntity.GetId(instance.gameObject);

            if (techType == TechType.SeamothElectricalDefense)
            {
                Transform            aimingTransform = Player.main.camRoot.GetAimingTransform();
                SeamothModulesAction changed         = new SeamothModulesAction(techType.ToDto(), slotID, id, aimingTransform.forward.ToDto(), aimingTransform.rotation.ToDto());
                packetSender.Send(changed);
            }
        }
Esempio n. 30
0
 internal static void Postfix(SeaMoth __instance, bool docked, Vehicle.DockType dockType)
 {
     if (__instance.gameObject.TryGetComponent(out SeamothArmManager manager))
     {
         manager.onDockedChanged?.Trigger(docked);
     }
     else
     {
         SNLogger.Warn("Seamoth Arm Manager is not ready!");
     }
 }