public virtual void Awake()
        {
            TruckHelper = GetComponentInParent <SeaTruckArmManager>().helper;

            animator = GetComponent <Animator>();

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

            hookPrefab = Instantiate(component.hookPrefab);
            hookPrefab.GetComponent <Collider>().enabled = false;
            rope = ArmServices.main.objectHelper.GetObjectClone(component.rope);

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

            hook = hookPrefab.AddComponent <SeaTruckGrapplingHook>();
            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";
        }
Ejemplo n.º 2
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";
        }
Ejemplo n.º 3
0
        static void Postfix(ExosuitGrapplingArm __instance)
        {
            if (!__instance.GetComponent <GrapplingArmUpgraded>())
            {
                return;
            }

            __instance.hook.GetComponent <SphereCollider>().radius            = 0.25f; // from 0.5f
            __instance.hook.GetComponent <Rigidbody>().collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
        }
 static void Postfix(ExosuitGrapplingArm __instance)
 {
     if (__instance.hook.attached && (__instance.hook.transform.position - __instance.front.position).sqrMagnitude > sqrMagnitudeGrapplingArm)
     {
         if (!consumeArmEnergy(__instance, Main.config.armsEnergyUsage.grapplingArmPull))
         {
             (__instance as IExosuitArm).OnUseUp(out _);
         }
     }
 }
Ejemplo n.º 5
0
            [HarmonyPostfix, HarmonyPatch(typeof(ExosuitGrapplingArm), "FixedUpdate")]             // energy usage for grappling arm
            static void ExosuitGrapplingArm_FixedUpdate_Postfix(ExosuitGrapplingArm __instance)
            {
                const float sqrMagnitudeGrapplingArm = 16f;                 // if hook attached and its sqr length less than that, then don't consume power

                if (__instance.hook.attached && (__instance.hook.transform.position - __instance.front.position).sqrMagnitude > sqrMagnitudeGrapplingArm)
                {
                    if (!consumeArmEnergy(__instance, Main.config.armsEnergyUsage.grapplingArmPull))
                    {
                        (__instance as IExosuitArm).OnUseUp(out _);
                    }
                }
            }
        public static bool Prefix(ExosuitGrapplingArm __instance, GrapplingHook ___hook)
        {
            Exosuit componentInParent = __instance.GetComponentInParent <Exosuit>();

            if (componentInParent != null)
            {
                if (!componentInParent.GetPilotingMode())
                {
                    // We suppress this method if it is called from another player pilot, so we can use our own implementation
                    // See: ExosuitModuleEvents.UseGrapplingarm -> onHit Section
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 7
0
        public void UseGrappling(ExosuitGrapplingArm grapplingArm, ExosuitArmAction armAction, Optional <Vector3> opHitVector)
        {
            if (armAction == ExosuitArmAction.endUseTool)
            {
                grapplingArm.animator.SetBool("use_tool", false);
                grapplingArm.ReflectionCall("ResetHook");
            }
            else if (armAction == ExosuitArmAction.startUseTool)
            {
                grapplingArm.animator.SetBool("use_tool", true);
                if (!grapplingArm.rope.isLaunching)
                {
                    grapplingArm.rope.LaunchHook(35f);
                }

                GrapplingHook hook = (GrapplingHook)grapplingArm.ReflectionGet("hook");

                hook.transform.parent   = null;
                hook.transform.position = grapplingArm.front.transform.position;
                hook.SetFlying(true);
                Exosuit componentInParent = grapplingArm.GetComponentInParent <Exosuit>();


                if (opHitVector.IsEmpty())
                {
                    Log.Error("No vector given that contains the hook direction");
                    return;
                }

                hook.rb.velocity = opHitVector.Get();
                global::Utils.PlayFMODAsset(grapplingArm.shootSound, grapplingArm.front, 15f);
                grapplingArm.ReflectionSet("grapplingStartPos", componentInParent.transform.position);
            }
            else
            {
                Log.Error("Grappling arm got an arm action he should not get: " + armAction);
            }
        }
Ejemplo n.º 8
0
        public void UseGrappling(ExosuitGrapplingArm grapplingArm, ExosuitArmAction armAction, Vector3?opHitVector)
        {
            if (armAction == ExosuitArmAction.END_USE_TOOL)
            {
                grapplingArm.animator.SetBool("use_tool", false);
                grapplingArm.ResetHook();
            }
            else if (armAction == ExosuitArmAction.START_USE_TOOL)
            {
                grapplingArm.animator.SetBool("use_tool", true);
                if (!grapplingArm.rope.isLaunching)
                {
                    grapplingArm.rope.LaunchHook(35f);
                }

                GrapplingHook hook = grapplingArm.hook;

                hook.transform.parent   = null;
                hook.transform.position = grapplingArm.front.transform.position;
                hook.SetFlying(true);
                Exosuit componentInParent = grapplingArm.GetComponentInParent <Exosuit>();


                if (!opHitVector.HasValue)
                {
                    Log.Error("No vector given that contains the hook direction");
                    return;
                }

                hook.rb.velocity = opHitVector.Value;
                Utils.PlayFMODAsset(grapplingArm.shootSound, grapplingArm.front, 15f);
                grapplingArm.grapplingStartPos = componentInParent.transform.position;
            }
            else
            {
                Log.Error("Grappling arm got an arm action he should not get: " + armAction);
            }
        }
 public static void Postfix(ExosuitGrapplingArm __instance, GrapplingHook ___hook)
 {
     // We send the hook direction to the other player so he sees where the other player exosuit is heading
     NitroxServiceLocator.LocateService <ExosuitModuleEvent>().BroadcastArmAction(TechType.ExosuitGrapplingArmModule, __instance, ExosuitArmAction.START_USE_TOOL, ___hook.rb.velocity, null);
 }
 private static void Postfix(ExosuitGrapplingArm __instance)
 {
     Console.WriteLine("ExosuitGrapplingArm.OnAltDown() Postfix is working!");
 }
 public static void Prefix(ExosuitGrapplingArm __instance)
 {
     NitroxServiceLocator.LocateService <ExosuitModuleEvent>().BroadcastArmAction(TechType.ExosuitGrapplingArmModule, __instance, ExosuitArmAction.endUseTool);
 }
Ejemplo n.º 12
0
        private void InitArmsGraphics()
        {
            Exosuit exosuitResource = Resources.Load <GameObject>("worldentities/tools/exosuit").GetComponent <Exosuit>();

            GameObject clone, model;
            Transform  ArmRig, elbow;

            foreach (Exosuit.ExosuitArmPrefab armPrefab in exosuitResource.armPrefabs)
            {
                clone = UWE.Utils.InstantiateDeactivated(armPrefab.prefab, Templates.transform, Vector3.zero, Quaternion.Euler(0, 0, 0));

                ArmRig = clone.transform.Find("exosuit_01_armRight/ArmRig");
                elbow  = ArmRig.Find("clavicle/shoulder/bicepPivot/elbow/");

                switch (armPrefab.techType)
                {
                case TechType.ExosuitClawArmModule:
                    clone.name = "ClawArmTemplate";
                    DestroyImmediate(clone.GetComponent <ExosuitClawArm>());

                    DestroyImmediate(ArmRig.Find("exosuit_arm_torpedoLauncher_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_drill_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_hand_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_propulsion_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("grapplingHook").gameObject);
                    DestroyImmediate(elbow.Find("drill").gameObject);
                    DestroyImmediate(elbow.Find("grapplingBase").gameObject);
                    DestroyImmediate(elbow.Find("object").gameObject);
                    DestroyImmediate(elbow.Find("propulsion").gameObject);
                    DestroyImmediate(elbow.Find("torpedoLauncher").gameObject);

                    model      = ArmRig.Find("exosuit_hand_geo").gameObject;
                    model.name = "ArmModel";

                    ArmsTemplateCache.Add(ArmTemplate.ClawArm, clone);
                    break;

                case TechType.ExosuitDrillArmModule:
                    clone.name = "DrillArmTemplate";
                    DestroyImmediate(clone.GetComponent <ExosuitDrillArm>());

                    DestroyImmediate(ArmRig.Find("exosuit_arm_torpedoLauncher_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_hand_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_hand_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_propulsion_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("grapplingHook").gameObject);
                    DestroyImmediate(elbow.Find("grapplingBase").gameObject);
                    DestroyImmediate(elbow.Find("object").gameObject);
                    DestroyImmediate(elbow.Find("propulsion").gameObject);
                    DestroyImmediate(elbow.Find("torpedoLauncher").gameObject);
                    DestroyImmediate(elbow.Find("wrist").gameObject);

                    model      = ArmRig.Find("exosuit_drill_geo").gameObject;
                    model.name = "ArmModel";

                    ArmsTemplateCache.Add(ArmTemplate.DrillArm, clone);
                    break;

                case TechType.ExosuitGrapplingArmModule:
                    clone.name = "GrapplingArmTemplate";

                    ExosuitGrapplingArm component = clone.GetComponent <ExosuitGrapplingArm>();

                    HookPrefab      = Instantiate(component.hookPrefab, Templates.transform);
                    HookPrefab.name = "Hook";

                    DestroyImmediate(component);

                    DestroyImmediate(elbow.Find("drill").gameObject);
                    DestroyImmediate(elbow.Find("object").gameObject);
                    DestroyImmediate(elbow.Find("propulsion").gameObject);
                    DestroyImmediate(elbow.Find("torpedoLauncher").gameObject);
                    DestroyImmediate(elbow.Find("wrist").gameObject);

                    model      = ArmRig.Find("exosuit_grapplingHook_geo").gameObject;
                    model.name = "ArmModel";

                    ArmsTemplateCache.Add(ArmTemplate.GrapplingArm, clone);
                    break;

                case TechType.ExosuitPropulsionArmModule:
                    clone.name = "PropulsionArmTemplate";
                    DestroyImmediate(clone.GetComponent <ExosuitPropulsionArm>());

                    DestroyImmediate(ArmRig.Find("exosuit_arm_torpedoLauncher_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_drill_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_hand_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_hand_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("grapplingHook").gameObject);
                    DestroyImmediate(elbow.Find("drill").gameObject);
                    DestroyImmediate(elbow.Find("grapplingBase").gameObject);
                    DestroyImmediate(elbow.Find("object").gameObject);
                    DestroyImmediate(elbow.Find("torpedoLauncher").gameObject);
                    DestroyImmediate(elbow.Find("wrist").gameObject);

                    model      = ArmRig.Find("exosuit_propulsion_geo").gameObject;
                    model.name = "ArmModel";

                    ArmsTemplateCache.Add(ArmTemplate.PropulsionArm, clone);
                    break;

                case TechType.ExosuitTorpedoArmModule:
                    clone.name = "TorpedoArmTemplate";
                    DestroyImmediate(clone.GetComponent <ExosuitTorpedoArm>());

                    DestroyImmediate(ArmRig.Find("exosuit_drill_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_grapplingHook_hand_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_hand_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("exosuit_propulsion_geo").gameObject);
                    DestroyImmediate(ArmRig.Find("grapplingHook").gameObject);
                    DestroyImmediate(elbow.Find("drill").gameObject);
                    DestroyImmediate(elbow.Find("grapplingBase").gameObject);
                    DestroyImmediate(elbow.Find("object").gameObject);
                    DestroyImmediate(elbow.Find("propulsion").gameObject);
                    DestroyImmediate(elbow.Find("wrist").gameObject);

                    model      = ArmRig.Find("exosuit_arm_torpedoLauncher_geo").gameObject;
                    model.name = "ArmModel";

                    ArmsTemplateCache.Add(ArmTemplate.TorpedoArm, clone);
                    break;
                }
            }


            SNLogger.Log($"Graphics cache initialization complete. GameObject: {name}, path: {transform.GetPath()}, ID: {GetInstanceID()}");
        }
 public static void Postfix(ExosuitGrapplingArm __instance, GrapplingHook ___hook)
 {
     // We send the hook direction to the other player so he sees where the other player exosuit is heading
     NitroxServiceLocator.LocateService <ExosuitModuleEvent>().BroadcastArmAction(TechType.ExosuitGrapplingArmModule, __instance, ExosuitArmAction.startUseTool, Optional <Vector3> .Of(___hook.rb.velocity), Optional <Quaternion> .Empty());
 }