Example #1
0
        private void ZapRadius()
        {
            GameObject        gameObject       = Utils.SpawnZeroedAt(seaMoth.seamothElectricalDefensePrefab, Cyclops.transform, false);
            ElectricalDefense defenseComponent = gameObject.GetComponent <ElectricalDefense>();

            defenseComponent.charge        = ZapPower;
            defenseComponent.chargeScalar  = ZapPower;
            defenseComponent.radius       *= ZapPower;
            defenseComponent.chargeRadius *= ZapPower;

            Cyclops.powerRelay.ConsumeEnergy(EnergyCostPerRadiusZap, out float amountConsumed);
        }
        public override void Process(SeamothModulesAction packet)
        {
            using (packetSender.Suppress <SeamothModulesAction>())
                using (packetSender.Suppress <ItemContainerRemove>())
                {
                    GameObject _gameObject = NitroxEntity.RequireObjectFrom(packet.Id);
                    SeaMoth    seamoth     = _gameObject.GetComponent <SeaMoth>();
                    if (seamoth != null)
                    {
                        TechType techType = packet.TechType.ToUnity();

                        if (techType == TechType.SeamothElectricalDefense)
                        {
                            float[]           chargearray = (float[])seamoth.ReflectionGet("quickSlotCharge");
                            float             charge      = chargearray[packet.SlotID];
                            float             slotCharge  = seamoth.GetSlotCharge(packet.SlotID);
                            GameObject        gameObject  = global::Utils.SpawnZeroedAt(seamoth.seamothElectricalDefensePrefab, seamoth.transform, false);
                            ElectricalDefense component   = gameObject.GetComponent <ElectricalDefense>();
                            component.charge       = charge;
                            component.chargeScalar = slotCharge;
                        }

                        if (techType == TechType.SeamothTorpedoModule)
                        {
                            Transform      muzzle        = (packet.SlotID != seamoth.GetSlotIndex("SeamothModule1") && packet.SlotID != seamoth.GetSlotIndex("SeamothModule3")) ? seamoth.torpedoTubeRight : seamoth.torpedoTubeLeft;
                            ItemsContainer storageInSlot = seamoth.GetStorageInSlot(packet.SlotID, TechType.SeamothTorpedoModule);
                            TorpedoType    torpedoType   = null;

                            for (int i = 0; i < seamoth.torpedoTypes.Length; i++)
                            {
                                if (storageInSlot.Contains(seamoth.torpedoTypes[i].techType))
                                {
                                    torpedoType = seamoth.torpedoTypes[i];
                                    break;
                                }
                            }

                            //Original Function use Player Camera need parse owner camera values
                            TorpedoShot(storageInSlot, torpedoType, muzzle, packet.Forward.ToUnity(), packet.Rotation.ToUnity());
                        }
                    }
                }
        }