private ChairProperties getClosestChair(Vector3 position)
    {
        ChairProperties chairProperties = null;

        Collider[] array = Physics.OverlapSphere(position, 0f, -1, QueryTriggerInteraction.Collide);
        for (int i = 0; i < array.Length; i++)
        {
            ChairProperties component = array[i].gameObject.GetComponent <ChairProperties>();
            if (!(component != null))
            {
                continue;
            }
            if (chairProperties != null)
            {
                if ((position - component.transform.position).sqrMagnitude < (position - chairProperties.transform.position).sqrMagnitude)
                {
                    chairProperties = component;
                }
            }
            else
            {
                chairProperties = component;
            }
        }
        return(chairProperties);
    }
Пример #2
0
    protected override void Update()
    {
        ChairProperties component = SceneRefs.ActionSequencer.GetTrigger(GetTarget()).GetComponent <ChairProperties>();

        if (component != null)
        {
            LocomotionHelper.SetCurrentController <SitController>(GetTarget());
            LocomotionController currentController = LocomotionHelper.GetCurrentController(GetTarget());
            if (currentController is SitController)
            {
                SitController sitController = (SitController)currentController;
                sitController.SetChair(component);
            }
        }
        Completed();
    }
 public void RemoteSit(ChairProperties _chair)
 {
     if (_chair == null)
     {
         _chair = getClosestChair(base.transform.position);
     }
     if (_chair != null)
     {
         SetChair(_chair);
         PlayAnimAction component = _chair.gameObject.GetComponent <PlayAnimAction>();
         if (component != null && component.IdealStartTransform != null)
         {
             base.transform.rotation = component.IdealStartTransform.rotation;
         }
     }
     animator.SetBool(AnimationHashes.Params.Sit, value: true);
     animator.Play(AnimationHashes.States.Interactions.Sit, 0);
     mode = Mode.Sitting;
     base.Broadcaster.BroadcastOnControlsUnLocked();
 }
 public void SetChair(ChairProperties _chair)
 {
     if (chair != null)
     {
         chair.gameObject.SetActive(value: true);
     }
     chair = _chair;
     if (chair != null)
     {
         chestBoneRotation = chair.Fields.ChestBoneRotation;
         if (animator != null)
         {
             animator.SetFloat(AnimationHashes.Params.EnterSitAnimIndex, chair.Fields.EnterSitAnimIndex);
             animator.SetFloat(AnimationHashes.Params.SitAnimIndex, chair.Fields.SitAnimIndex);
         }
         chair.gameObject.SetActive(value: false);
     }
     else
     {
         Log.LogError(this, "Attempted to sit penguin without chair properties!");
     }
 }