public void Initialize(ArmsController controller)
 {
     armsController = controller;
     player         = Utils.GetLocalPlayerComp();
     ik             = controller.GetComponent <FullBodyBipedIK>();
     scale          = MainCameraControl.main.viewModel.localScale;
 }
Example #2
0
        public static void Prefix(ArmsController __instance, PlayerTool tool)
        {
            FullBodyBipedIK ik = VRHandsController.main.ik;

            ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).bendGoal = __instance.leftHandElbow;
            ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).weight   = 1f;
            if (tool == null)
            {
                Traverse tInstance = Traverse.Create(__instance);
                tInstance.Field("leftAim").Field("shouldAim").SetValue(false);
                tInstance.Field("rightAim").Field("shouldAim").SetValue(false);

                ik.solver.leftHandEffector.target  = null;
                ik.solver.rightHandEffector.target = null;
                if (!VRHandsController.main.pda.isActiveAndEnabled)
                {
                    Transform leftWorldTarget = tInstance.Field <Transform>("leftWorldTarget").Value;
                    if (leftWorldTarget)
                    {
                        ik.solver.leftHandEffector.target = leftWorldTarget;
                        ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).bendGoal = null;
                        ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).weight   = 0f;
                    }

                    Transform rightWorldTarget = tInstance.Field <Transform>("rightWorldTarget").Value;
                    if (rightWorldTarget)
                    {
                        ik.solver.rightHandEffector.target = rightWorldTarget;
                        return;
                    }
                }
            }
        }
 public ArmsControllerTests()
 {
     _repo       = new Mock <IReadArmRepository>();
     _repoDroid  = new Mock <IReadDroidRepository>();
     _handler    = new Mock <IDroidHandler>();
     _controller = new ArmsController(_repo.Object, _repoDroid.Object, _handler.Object);
 }
Example #4
0
        public RemotePlayer(string playerId, string playerName, PlayerSettings playerSettings)
        {
            PlayerId       = playerId;
            PlayerName     = playerName;
            PlayerSettings = playerSettings;

            GameObject originalBody = GameObject.Find("body");

            Body = CloneBody(originalBody);

            RigidBody            = Body.AddComponent <Rigidbody>();
            RigidBody.useGravity = false;

            // Get player
            PlayerModel = Body.transform.Find("player_view").gameObject;

            // Move variables to keep player animations from mirroring and for identification
            ArmsController = PlayerModel.GetComponent <ArmsController>();
            ArmsController.smoothSpeedUnderWater = 0;
            ArmsController.smoothSpeedAboveWater = 0;

            AnimationController = PlayerModel.AddComponent <AnimationController>();

            ErrorMessage.AddMessage($"{playerName} joined the game.");
        }
Example #5
0
        public void SetVehicle(Vehicle newVehicle)
        {
            if (Vehicle != newVehicle)
            {
                if (Vehicle != null)
                {
                    Vehicle.mainAnimator.SetBool("player_in", false);

                    Detach();
                    ArmsController.SetWorldIKTarget(null, null);

                    Vehicle.GetComponent <MultiplayerVehicleControl <Vehicle> >().Exit();
                }

                if (newVehicle != null)
                {
                    newVehicle.mainAnimator.SetBool("player_in", true);

                    Attach(newVehicle.playerPosition.transform);
                    ArmsController.SetWorldIKTarget(newVehicle.leftHandPlug, newVehicle.rightHandPlug);

                    newVehicle.GetComponent <MultiplayerVehicleControl <Vehicle> >().Enter();
                }

                RigidBody.isKinematic = newVehicle != null;

                Vehicle = newVehicle;

                AnimationController["in_seamoth"] = newVehicle is SeaMoth;
                AnimationController["in_exosuit"] = AnimationController["using_mechsuit"] = newVehicle is Exosuit;
            }
        }
Example #6
0
        public void SetPilotingChair(PilotingChair newPilotingChair)
        {
            if (PilotingChair != newPilotingChair)
            {
                PilotingChair = newPilotingChair;

                Validate.NotNull(SubRoot, "Player changed PilotingChair but is not in SubRoot!");

                MultiplayerCyclops mpCyclops = SubRoot.GetComponent <MultiplayerCyclops>();

                if (PilotingChair != null)
                {
                    Attach(PilotingChair.sittingPosition.transform);
                    ArmsController.SetWorldIKTarget(PilotingChair.leftHandPlug, PilotingChair.rightHandPlug);

                    mpCyclops.CurrentPlayer = this;
                    mpCyclops.Enter();
                }
                else
                {
                    SetSubRoot(SubRoot);
                    ArmsController.SetWorldIKTarget(null, null);

                    mpCyclops.CurrentPlayer = null;
                    mpCyclops.Exit();
                }

                RigidBody.isKinematic = AnimationController["cyclops_steering"] = newPilotingChair != null;
            }
        }
Example #7
0
        public static void PostFix(ArmsController __instance)
        {
            if (!VRSettings.enabled)
            {
                return;
            }

            VRHandsController.main.Initialize(__instance);
        }
            public static void PostFix(ArmsController __instance)
            {
                if (!XRSettings.enabled)
                {
                    return;
                }

                GetXRArmsController().Initialize(__instance);
            }
Example #9
0
        public void Initialize(ArmsController controller)
        {
            armsController = controller;
            player         = global::Utils.GetLocalPlayerComp();
            ik             = controller.GetComponent <FullBodyBipedIK>();
            pda            = player.GetPDA();

            rightController = new GameObject("rightController");
            rightController.transform.parent = player.camRoot.transform;

            leftController = new GameObject("leftController");
            leftController.transform.parent = player.camRoot.transform;
        }
Example #10
0
        public static void Postfix(ArmsController __instance)
        {
            if (!VRSettings.enabled)
            {
                return;
            }

            PDA    pda    = VRHandsController.main.pda;
            Player player = VRHandsController.main.player;

            if ((Player.main.motorMode != Player.MotorMode.Vehicle && !player.cinematicModeActive) || pda.isActiveAndEnabled)
            {
                VRHandsController.main.UpdateHandPositions();
            }
        }
        public static bool Prefix(ArmsController __instance)
        {
            if (__instance.smoothSpeed == 0)
            {
                Traverse traverse = Traverse.Create(__instance);
                object   leftAim  = traverse.Field("leftAim").GetValue();
                object   rightAim = traverse.Field("rightAim").GetValue();
                leftAim.ReflectionCall("Update", true, false, __instance.ikToggleTime);
                rightAim.ReflectionCall("Update", true, false, __instance.ikToggleTime);
                __instance.ReflectionCall("UpdateHandIKWeights");

                return(false);
            }
            return(true);
        }
        public static bool Prefix(ArmsController __instance)
        {
            if (__instance.smoothSpeedAboveWater == 0)
            {
                if (__instance.reconfigureWorldTarget)
                {
                    __instance.Reconfigure(null);
                    __instance.reconfigureWorldTarget = false;
                }

                __instance.leftAim.Update(__instance.ikToggleTime);
                __instance.rightAim.Update(__instance.ikToggleTime);
                __instance.UpdateHandIKWeights();
                return false;
            }

            return true;
        }
Example #13
0
        public static bool Prefix(ArmsController __instance)
        {
            if (__instance.smoothSpeedAboveWater == 0)
            {
                if ((bool)reconfigureWorldTarget.GetValue(__instance))
                {
                    reconfigure.Invoke(__instance, new PlayerTool[] { null });
                    reconfigureWorldTarget.SetValue(__instance, false);
                }

                object   leftAim  = leftAimField.GetValue(__instance);
                object   rightAim = rightAimField.GetValue(__instance);
                object[] args     = new object[] { __instance.ikToggleTime };
                armAimingUpdate.Invoke(leftAim, args);
                armAimingUpdate.Invoke(rightAim, args);

                updateHandIKWeights.Invoke(__instance, new object[] { });
                return(false);
            }
            return(true);
        }
Example #14
0
        public RemotePlayer(string playerId)
        {
            PlayerId = playerId;
            GameObject originalBody = GameObject.Find("body");

            //Cheap fix for showing head, much easier since male_geo contains many different heads
            originalBody.GetComponentInParent <Player>().head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
            Body = Object.Instantiate(originalBody);
            originalBody.GetComponentInParent <Player>().head.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;


            RigidBody            = Body.AddComponent <Rigidbody>();
            RigidBody.useGravity = false;

            //Get player
            PlayerView = Body.transform.Find("player_view").gameObject;

            //Move variables to keep player animations from mirroring and for identification
            ArmsController = PlayerView.GetComponent <ArmsController>();
            ArmsController.smoothSpeedUnderWater = 0;
            ArmsController.smoothSpeedAboveWater = 0;

            //Sets up a copy from the xSignal template for the signal
            //todo: settings menu to disable this?
            GameObject signalBase = Object.Instantiate(Resources.Load("VFX/xSignal")) as GameObject;

            signalBase.name = "signal" + playerId;
            signalBase.transform.localScale     = new Vector3(.5f, .5f, .5f);
            signalBase.transform.localPosition += new Vector3(0, 0.8f, 0);
            signalBase.transform.SetParent(PlayerView.transform, false);
            PingInstance ping = signalBase.GetComponent <PingInstance>();

            ping.SetLabel("Player " + playerId);
            ping.pingType = PingType.Signal;

            AnimationController = PlayerView.AddComponent <AnimationController>();

            ErrorMessage.AddMessage($"{playerId} joined the game.");
        }
Example #15
0
 public void NowInHand(ArmsController armsController)
 {
     pickupCollider.enabled   = false;
     swingHitCollider.enabled = true;
     armsControllerRef        = armsController;
 }
 static void Postfix(ArmsController __instance)
 {
     //get the private ik field from ArmsController to use it in PDA Update method
     myIK = Traverse.Create(__instance).Field("ik").GetValue <FullBodyBipedIK>();
 }
 static void Postfix(ArmsController __instance)
 {
     //This fixes a bug in the original game code where reconfigureWorldTarget was set to true in SetWorldIKTarget but never reset to false after running Reconfigure
     //This caused the PDA ik target to work until piloting a vehicle which called SetWorldIKTarget and continuously called Reconfigure every frame after.
     Traverse.Create(__instance).Field("reconfigureWorldTarget").SetValue(false);
 }
 public static void ArmsCon_Start_Postfix(ArmsController __instance)
 {
     MainPatcher.myIK = Traverse.Create(__instance).Field("ik").GetValue <FullBodyBipedIK>();
 }
Example #19
0
 public static void Postfix(ArmsController __instance)
 {
     __instance.Reconfigure(null);
 }
 public static void Postfix(ArmsController __instance)
 {
     reconfigure.Invoke(__instance, new object[] { (PlayerTool)null });
 }
 public static void Reconfigure_Postfix(ArmsController __instance)
 {
     Traverse.Create(__instance).Field("reconfigureWorldTarget").SetValue(false);
 }