private void Awake()
 {
     if (LightSwitchPoint._commandRefreshEvent == null)
     {
         LightSwitchPoint._commandRefreshEvent = new Subject <Unit>();
         ObservableExtensions.Subscribe <IList <Unit> >(Observable.Where <IList <Unit> >(Observable.TakeUntilDestroy <IList <Unit> >((IObservable <M0>)Observable.Buffer <Unit, Unit>((IObservable <M0>)LightSwitchPoint._commandRefreshEvent, (IObservable <M1>)Observable.ThrottleFrame <Unit>((IObservable <M0>)LightSwitchPoint._commandRefreshEvent, 1, (FrameCountType)0)), (Component)Singleton <Manager.Map> .Instance), (Func <M0, bool>)(_ => !_.IsNullOrEmpty <Unit>())), (Action <M0>)(_ =>
         {
             CommandArea commandArea = Manager.Map.GetCommandArea();
             if (Object.op_Equality((Object)commandArea, (Object)null))
             {
                 return;
             }
             commandArea.RefreshCommands();
         }));
     }
     if (this._linkMapObject)
     {
         LightSwitchData lightSwitchData = LightSwitchData.Get(this._linkID);
         if (Object.op_Inequality((Object)lightSwitchData, (Object)null))
         {
             this._onModeObjects  = lightSwitchData.OnModeObjects;
             this._offModeObjects = lightSwitchData.OffModeObjects;
         }
     }
     this.ActiveChange(this._firstLightEnable);
 }
        private void RefreshCommand()
        {
            CommandArea commandArea = Manager.Map.GetCommandArea();

            if (Object.op_Equality((Object)commandArea, (Object)null) || !commandArea.ContainsConsiderationObject((ICommandable)this) || LightSwitchPoint._commandRefreshEvent == null)
            {
                return;
            }
            LightSwitchPoint._commandRefreshEvent.OnNext(Unit.get_Default());
        }
        public virtual TaskStatus OnUpdate()
        {
            PlayerActor player      = Singleton <Manager.Map> .Instance.Player;
            CommandArea commandArea = player.PlayerController.CommandArea;
            Vector3     offset      = Vector3.get_zero();

            if (Object.op_Inequality((Object)commandArea.BaseTransform, (Object)null))
            {
                Vector3 eulerAngles = commandArea.BaseTransform.get_eulerAngles();
                eulerAngles.x = (__Null)(double)(eulerAngles.z = (__Null)0.0f);
                offset        = Quaternion.op_Multiply(Quaternion.Euler(eulerAngles), commandArea.Offset);
            }
            return(commandArea.WithinRange(player.NavMeshAgent, (ICommandable)this.Agent, offset) ? (TaskStatus)2 : (TaskStatus)1);
        }
        protected override void OnEnable()
        {
            base.OnEnable();
            CommandArea commandArea = (!Singleton <Manager.Map> .IsInstance() ? (PlayerActor)null : Singleton <Manager.Map> .Instance.Player)?.PlayerController?.CommandArea;

            if (Object.op_Equality((Object)commandArea, (Object)null))
            {
                return;
            }
            if (this._labels == null)
            {
                this.Init();
            }
            if (commandArea.ContainsCommandableObject((ICommandable)this))
            {
                return;
            }
            commandArea.AddCommandableObject((ICommandable)this);
        }
        protected override void OnDisable()
        {
            base.OnDisable();
            CommandArea commandArea = (!Singleton <Manager.Map> .IsInstance() ? (PlayerActor)null : Singleton <Manager.Map> .Instance.Player)?.PlayerController?.CommandArea;

            if (Object.op_Equality((Object)commandArea, (Object)null))
            {
                return;
            }
            bool flag = commandArea.ContainsConsiderationObject((ICommandable)this);

            if (!commandArea.ContainsCommandableObject((ICommandable)this))
            {
                return;
            }
            commandArea.RemoveCommandableObject((ICommandable)this);
            if (!flag)
            {
                return;
            }
            commandArea.RefreshCommands();
        }
Exemplo n.º 6
0
        private void OnUpdate()
        {
            if (Object.op_Equality((Object)this._eventPoint, (Object)null) || !Singleton <Manager.Map> .IsInstance())
            {
                return;
            }
            PlayerActor player      = Manager.Map.GetPlayer();
            CommandArea commandArea = Manager.Map.GetCommandArea(player);

            if (Object.op_Equality((Object)commandArea, (Object)null))
            {
                return;
            }
            bool flag = this._eventPoint.IsNeutralCommand;

            if (flag)
            {
                IState state = player.PlayerController.State;
                int    num1  = flag ? 1 : 0;
                int    num2;
                switch (state)
                {
                case Normal _:
                case Houchi _:
                    num2 = 1;
                    break;

                default:
                    num2 = state is Onbu ? 1 : 0;
                    break;
                }
                flag = (num1 & num2) != 0;
            }
            if (flag)
            {
                float   num1          = !this._eventPoint.EnableRangeCheck ? commandArea.AllAroundRadius : this._eventPoint.CheckRadius;
                Vector3 commandCenter = this._eventPoint.CommandCenter;
                Vector3 p1            = Vector3.op_Addition(player.Position, Quaternion.op_Multiply(player.Rotation, commandArea.Offset));
                flag &= (double)this.DistanceNonHeight(commandCenter, p1) <= (double)num1;
                if (flag)
                {
                    float num2 = Mathf.Abs((float)(commandCenter.y - p1.y));
                    flag &= (double)num2 < (double)commandArea.Height;
                }
                if (flag)
                {
                    NavMeshHit navMeshHit;
                    flag = ((flag ? 1 : 0) & (!Object.op_Inequality((Object)player.NavMeshAgent, (Object)null) || !((Behaviour)player.NavMeshAgent).get_isActiveAndEnabled() ? 0 : (!player.NavMeshAgent.Raycast(commandCenter, ref navMeshHit) ? 1 : 0))) != 0;
                }
            }
            if (flag)
            {
                switch (this._collisionState)
                {
                case CollisionState.None:
                case CollisionState.Exit:
                    this._collisionState = CollisionState.Enter;
                    this.OnHitEnter();
                    this.OnHitStay();
                    break;

                case CollisionState.Enter:
                case CollisionState.Stay:
                    this._collisionState = CollisionState.Stay;
                    this.OnHitStay();
                    break;
                }
            }
            else
            {
                switch (this._collisionState)
                {
                case CollisionState.None:
                case CollisionState.Exit:
                    this._collisionState = CollisionState.None;
                    break;

                case CollisionState.Enter:
                case CollisionState.Stay:
                    this._collisionState = CollisionState.Exit;
                    this.OnHitExit();
                    break;
                }
            }
        }