Exemple #1
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;
            }
        }
Exemple #2
0
        public void SetPilotingChair(PilotingChair newPilotingChair)
        {
            if (activeSub == null)
            {
                return;
            }

            if (activeChair == newPilotingChair)
            {
                return;
            }

            activeChair = newPilotingChair;
            var syncedCyclops = activeSub.GetComponent <SyncedCyclops>();

            if (activeChair != null)
            {
                Attach(activeChair.sittingPosition.transform);
                syncedCyclops.Enter(this);
                // arms.SetWorldIKTarget(activeChair.leftHandPlug, activeChair.rightHandPlug);
            }
            else
            {
                SetSubRoot(activeSub);
                syncedCyclops.Exit();
                // arms.SetWorldIKTarget(null, null);
            }

            var steering = (newPilotingChair != null);

            animator.main.SetBool("cyclops_steering", steering);
            // rigidbody.isKinematic = steering;
        }
        public static bool Prefix(PilotingChair __instance, GUIHand hand)
        {
            if (skipPrefix)
            {
                return(true);
            }

            SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>();

            SubRoot subRoot = __instance.GetComponentInParent <SubRoot>();

            Validate.NotNull(subRoot, "PilotingChair cannot find it's corresponding SubRoot!");
            NitroxId id = NitroxEntity.GetId(subRoot.gameObject);

            if (simulationOwnership.HasExclusiveLock(id))
            {
                Log.Debug($"Already have an exclusive lock on the piloting chair: {id}");
                return(true);
            }

            HandInteraction <PilotingChair> context = new HandInteraction <PilotingChair>(__instance, hand);
            LockRequest <HandInteraction <PilotingChair> > lockRequest = new LockRequest <HandInteraction <PilotingChair> >(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context);

            simulationOwnership.RequestSimulationLock(lockRequest);

            return(false);
        }
Exemple #4
0
        public static bool Prefix(PilotingChair __instance, GUIHand hand)
        {
            if (skipPrefix)
            {
                return(true);
            }

            pilotingChair = __instance;
            guiHand       = hand;

            SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>();

            SubRoot subRoot = __instance.GetComponentInParent <SubRoot>();

            Validate.NotNull(subRoot, "PilotingChair cannot find it's corresponding SubRoot!");
            string guid = GuidHelper.GetGuid(subRoot.gameObject);

            if (simulationOwnership.HasExclusiveLock(guid))
            {
                Log.Debug($"Already have an exclusive lock on the piloting chair: {guid}");
                return(true);
            }

            simulationOwnership.RequestSimulationLock(guid, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse);

            return(false);
        }
Exemple #5
0
        public static void Postfix(PilotingChair __instance)
        {
            SubRoot subRoot = __instance.GetComponentInParent <SubRoot>();

            Validate.NotNull(subRoot, "PilotingChair cannot find it's corresponding SubRoot!");
            NitroxId id = NitroxEntity.GetId(subRoot.gameObject);

            SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>();

            // Request to be downgraded to a transient lock so we can still simulate the positioning.
            simulationOwnership.RequestSimulationLock(id, SimulationLockType.TRANSIENT);
        }
        private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, HandInteraction <PilotingChair> context)
        {
            PilotingChair pilotingChair = context.Target;

            if (lockAquired)
            {
                skipPrefix = true;
                TARGET_METHOD.Invoke(pilotingChair, new[] { context.GuiHand });
                skipPrefix = false;
            }
            else
            {
                pilotingChair.gameObject.AddComponent <DenyOwnershipHand>();
                pilotingChair.isValidHandTarget = false;
            }
        }
Exemple #7
0
        public void SetPilotingChair(PilotingChair newPilotingChair)
        {
            if (PilotingChair != newPilotingChair)
            {
                PilotingChair = newPilotingChair;

                if (newPilotingChair != null)
                {
                    Attach(newPilotingChair.sittingPosition.transform);
                }
                else
                {
                    SetSubRoot(SubRoot);
                }
                rigidBody.isKinematic = animationController["cyclops_steering"] = newPilotingChair != null;
            }
        }