Esempio n. 1
0
        protected IEnumerator waitForValidLocomotionModeToInteract()
        {
            if (locomotionTracker != null && locomotionTracker.GetCurrentController() is RunController)
            {
                Animator      anim          = GetComponent <Animator>();
                RunController runController = (RunController)locomotionTracker.GetCurrentController();
                RunController.ControllerBehaviour oldBehaviour = runController.Behaviour;
                runController.Behaviour = new RunController.ControllerBehaviour
                {
                    IgnoreCollisions   = false,
                    IgnoreGravity      = false,
                    IgnoreRotation     = false,
                    IgnoreTranslation  = false,
                    IgnoreJumpRequests = true,
                    IgnoreStickInput   = true,
                    LastModifier       = this
                };
                AnimatorStateInfo animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim);
                while (!LocomotionUtils.IsLocomoting(animStateInfo) && !LocomotionUtils.IsLanding(animStateInfo) && !LocomotionUtils.IsIdling(animStateInfo))
                {
                    yield return(null);

                    animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim);
                }
                runController.ResetMomentum();
                if (runController.Behaviour.LastModifier == this)
                {
                    runController.Behaviour = oldBehaviour;
                }
            }
        }
 public void Awake()
 {
     agent   = GetComponent <NavMeshAgent>();
     tracker = GetComponent <LocomotionTracker>();
     agent.updatePosition = false;
     agent.updateRotation = false;
     tracker.SetCurrentController <RunController>();
     runController = GetComponent <RunController>();
     runController.Behaviour.SetStyle(LocoStyle);
 }
Esempio n. 3
0
        private void OnDisable()
        {
            base.Broadcaster.OnInteractionPreStartedEvent -= onInteractionPreStartedEvent;
            if (animator != null)
            {
                animator.SetBool(AnimationHashes.Params.Sit, value: false);
            }
            RunController component = GetComponent <RunController>();

            if (component != null)
            {
                component.Behaviour.Reset();
            }
            if (chair != null)
            {
                chair.gameObject.SetActive(value: true);
            }
        }
Esempio n. 4
0
        public static bool CanPlaySizzle(GameObject go)
        {
            bool result = false;

            if (go != null)
            {
                ParticipationController component = go.GetComponent <ParticipationController>();
                if (component == null || !component.IsInteracting())
                {
                    RunController component2 = go.GetComponent <RunController>();
                    if (component2 != null && component2.enabled)
                    {
                        Animator component3 = go.GetComponent <Animator>();
                        if (component3 != null)
                        {
                            AnimatorStateInfo currentAnimatorStateInfo = component3.GetCurrentAnimatorStateInfo(AnimationHashes.Layers.Base);
                            result = IsIdling(currentAnimatorStateInfo) || currentAnimatorStateInfo.IsTag("Sizzling");
                        }
                    }
                }
            }
            return(result);
        }
        public void MoveToTarget(Transform target, float distanceThreshold = 0.15f, PlayerLocoStyle.Style locomotionStyle = PlayerLocoStyle.Style.Walk, float timeoutTime = 15f, bool autoDestroy = true)
        {
            targetDestination = target;
            actorRadius       = 0f;
            actorHalfHeight   = 0.1f;
            this.timeoutTime  = timeoutTime;
            this.autoDestroy  = autoDestroy;
            CharacterController component = GetComponent <CharacterController>();

            if (component != null)
            {
                actorRadius     = component.radius;
                actorHalfHeight = component.height / 2f;
            }
            LocomotionTracker component2 = GetComponent <LocomotionTracker>();

            if (component2.SetCurrentController <RunController>())
            {
                runController = GetComponent <RunController>();
                if (!runControllerBehaviourWasSet)
                {
                    oldRunBehaviour         = runController.Behaviour;
                    runController.Behaviour = new RunController.ControllerBehaviour
                    {
                        IgnoreCollisions   = false,
                        IgnoreGravity      = false,
                        IgnoreRotation     = false,
                        IgnoreTranslation  = false,
                        IgnoreJumpRequests = true,
                        IgnoreStickInput   = true,
                        Style = locomotionStyle
                    };
                    runControllerBehaviourWasSet = true;
                }
                runController.ResetMomentum();
                dest = targetDestination.transform.position;
                Vector3 vector = dest - base.transform.position;
                if (vector == Vector3.zero)
                {
                    vector = base.transform.forward;
                }
                distThresholdSq = distanceThreshold * distanceThreshold;
                vector.y        = 0f;
                elapsedTime     = 0f;
                done            = false;
            }
            if (!CanReachWaypoint())
            {
                if (this.OnComplete != null)
                {
                    this.OnComplete();
                }
                runController.Steer(Vector3.zero);
                runController.SnapToPosition(dest);
                runController.SnapToFacing(targetDestination.transform.forward);
                if (autoDestroy)
                {
                    UnityEngine.Object.Destroy(this);
                }
            }
        }
Esempio n. 6
0
 public void Awake()
 {
     controller = GetComponent <RunController>();
 }