Пример #1
0
        public void UseTorpedo(ExosuitTorpedoArm torpedoArm, ExosuitArmAction armAction, Optional <Vector3> opVector, Optional <Quaternion> opRotation)
        {
            if (armAction == ExosuitArmAction.startUseTool || armAction == ExosuitArmAction.altHit)
            {
                if (opVector.IsEmpty() || opRotation.IsEmpty())
                {
                    Log.Error("Torpedo arm action shoot: no vector or rotation present");
                    return;
                }
                Vector3    forward  = opVector.Get();
                Quaternion rotation = opRotation.Get();
                Transform  silo     = default(Transform);
                if (armAction == ExosuitArmAction.startUseTool)
                {
                    silo = torpedoArm.siloFirst;
                }
                else
                {
                    silo = torpedoArm.siloSecond;
                }
                ItemsContainer container    = (ItemsContainer)torpedoArm.ReflectionGet("container");
                Exosuit        exosuit      = torpedoArm.GetComponentInParent <Exosuit>();
                TorpedoType[]  torpedoTypes = exosuit.torpedoTypes;

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

                // Copied from SeamothModuleActionProcessor. We need to synchronize both methods
                GameObject     gameObject        = UnityEngine.Object.Instantiate(torpedoType.prefab);
                Transform      component         = gameObject.GetComponent <Transform>();
                SeamothTorpedo component2        = gameObject.GetComponent <SeamothTorpedo>();
                Vector3        zero              = Vector3.zero;
                Rigidbody      componentInParent = silo.GetComponentInParent <Rigidbody>();
                Vector3        rhs   = (!(componentInParent != null)) ? Vector3.zero : componentInParent.velocity;
                float          speed = Vector3.Dot(forward, rhs);
                component2.Shoot(silo.position, rotation, speed, -1f);

                torpedoArm.animator.SetBool("use_tool", true);
                if (container.count == 0)
                {
                    Utils.PlayFMODAsset(torpedoArm.torpedoDisarmed, torpedoArm.transform, 1f);
                }
            }
            else if (armAction == ExosuitArmAction.endUseTool)
            {
                torpedoArm.animator.SetBool("use_tool", false);
            }
            else
            {
                Log.Error("Torpedo arm got an arm action he should not get: " + armAction);
            }
        }
Пример #2
0
 //Copied this from the Vehicle class
 public static bool TorpedoShot(ItemsContainer container, TorpedoType torpedoType, Transform muzzle, Vector3 forward, Quaternion rotation)
 {
     if (torpedoType != null && container.DestroyItem(torpedoType.techType))
     {
         GameObject     gameObject        = UnityEngine.Object.Instantiate <GameObject>(torpedoType.prefab);
         Transform      component         = gameObject.GetComponent <Transform>();
         SeamothTorpedo component2        = gameObject.GetComponent <SeamothTorpedo>();
         Vector3        zero              = Vector3.zero;
         Rigidbody      componentInParent = muzzle.GetComponentInParent <Rigidbody>();
         Vector3        rhs   = (!(componentInParent != null)) ? Vector3.zero : componentInParent.velocity;
         float          speed = Vector3.Dot(forward, rhs);
         component2.Shoot(muzzle.position, rotation, speed, -1f);
         return(true);
     }
     return(false);
 }
Пример #3
0
        static void Postfix(SeamothTorpedo __instance)
        {
            if (__instance.name.Contains("Gas"))
            {
                Console.WriteLine("GasTorpedo spawned! at " + __instance.transform.position);

                var mesh = __instance.gameObject.FindChild("mesh");

                if (mesh != null)
                {
                    GameObject.DestroyImmediate(mesh);
                }

                var newObject = GameObject.Instantiate(Main.KaiserTorpedo, __instance.transform);
            }
        }
Пример #4
0
        static bool Prepare() => Main.config.torpedoSpeed != 10f || !Main.config.homingTorpedoes;         // non-default values, need to patch

        static void Postfix(SeamothTorpedo __instance)
        {
            __instance.homingTorpedo = Main.config.homingTorpedoes;
            __instance.speed         = Main.config.torpedoSpeed;
        }
Пример #5
0
 static bool SeamothTorpedo_OnEnergyDepleted_Prefix(SeamothTorpedo __instance)
 {
     return(__instance._active);
 }