public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = this.ResolveTargetAnimator(arg);

            if (targ == null)
            {
                return(false);
            }

            var anim = this.TryPlay(targ);

            if (anim.IsNullOrDestroyed())
            {
                if (_triggerCompleteIfNoAnim)
                {
                    this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0f);
                }
                return(false);
            }

            if (_onAnimComplete.Count > 0)
            {
                AnimUtil.TrySchedule(anim, (a) =>
                {
                    _onAnimComplete.ActivateTrigger(this, arg);
                });
            }

            return(false);
        }
Ejemplo n.º 2
0
        public void SignalBlip(IAspect aspect)
        {
            if (_onHeardSound.Count > 0)
            {
                _onHeardSound.ActivateTrigger(this, aspect);
            }

            if (_signalEntity && !object.ReferenceEquals(_entity, null))
            {
                Messaging.Broadcast <IAudibleResponder>(_entity.gameObject, (o) => o.OnSound(aspect, false));
            }
            else
            {
                Messaging.Execute <IAudibleResponder>(this.gameObject, (o) => o.OnSound(aspect, false));
            }
        }
        protected GameObject Spawn(GameObject prefab, System.Action <GameObject> initializeProperties = null)
        {
            if (!this.enabled)
            {
                return(null);
            }
            if (prefab == null)
            {
                return(null);
            }

            Transform par           = (_spawnAsChild) ? this.transform : null;
            var       pos           = this.transform.position;
            var       rot           = this.transform.rotation;
            var       spawnedObject = _spawnMechanism.Spawn(prefab, pos, rot, par, initializeProperties);

            if (spawnedObject == null)
            {
                return(null);
            }

            if (_onSpawnedObject != null && _onSpawnedObject.Count > 0)
            {
                _onSpawnedObject.ActivateTrigger(this, spawnedObject);
            }
            return(spawnedObject);
        }
        public GameObject Spawn()
        {
            if (!this.enabled)
            {
                return(null);
            }
            if (_spawnedAttachment != null)
            {
                this.Despawn();
            }

            int index = SpawnPointHelper.SelectFromMultiple(this, this.PrefabCount);

            if (index < 0 || index >= this.PrefabCount)
            {
                return(null);
            }

            var prefab = _prefabs[index];

            _spawnedAttachment = _spawnMechanism.Spawn(prefab, this.transform.position, this.transform.rotation, this.transform);

            if (_onSpawnedObject != null && _onSpawnedObject.Count > 0)
            {
                _onSpawnedObject.ActivateTrigger(this, _spawnedAttachment);
            }

            return(_spawnedAttachment);
        }
        private GameObject Spawn(GameObject prefab)
        {
            var go = _spawnMechanism.Spawn(prefab, this.transform.position, this.transform.rotation, (_spawnAsChild) ? this.transform : null);

            if (_onSpawnedObject != null && _onSpawnedObject.Count > 0)
            {
                _onSpawnedObject.ActivateTrigger(this, go);
            }

            return(go);
        }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var anim = _targetAnimator.GetTarget <ISPAnimationSource>(arg);

            if (anim == null || !anim.CanPlayAnim)
            {
                return(false);
            }

            var id = _clipIDs.PickRandom();

            _currentAnimState = anim.GetAnim(id);
            if (_currentAnimState == null)
            {
                //this.Invoke(() => { this.OnAnimCompleteCallback(null); }, 0f);
                if (_triggerCompleteIfNoAnim)
                {
                    this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0f);
                }
                return(false);
            }

            _currentAnimState.TimeSupplier = _timeSupplier.TimeSupplier;
            _currentAnimState.Play(_speed, _startTime, QueueMode.PlayNow, _playMode);
            _currentAnimState.Schedule((s) =>
            {
                _currentAnimState = null;
                _onAnimComplete.ActivateTrigger(this, arg);
            });

            return(true);
        }
        private void OnFinishHandler(object sender, System.EventArgs e)
        {
            _onFinish.ActivateTrigger(this, null);

            var tween = sender as Tweener;

            if (tween != null)
            {
                tween.OnFinish -= this.OnFinishHandler;
                if (_activeTweens != null)
                {
                    _activeTweens.Remove(tween);
                }
            }
        }
Ejemplo n.º 8
0
        public void SignalBlip(IAspect aspect)
        {
            var audible = aspect as AudibleAspect;

            if (object.ReferenceEquals(audible, null) || !this.ConcernedWith(audible))
            {
                return;
            }

            this.OnSensedAspect(aspect);
            if (_onHeardSound.Count > 0)
            {
                _onHeardSound.ActivateTrigger(this, aspect);
            }

            if (_signalEntity && !object.ReferenceEquals(_entity, null))
            {
                Messaging.Broadcast <IAudibleResponder>(_entity.gameObject, (o) => o.OnSound(aspect, false));
            }
            else
            {
                Messaging.Execute <IAudibleResponder>(this.gameObject, (o) => o.OnSound(aspect, false));
            }
        }
Ejemplo n.º 9
0
        void ISpawnerModifier.OnSpawnedNotification(SpawnPointTriggeredNotification n)
        {
            if (!this.IsActiveAndEnabled())
            {
                return;
            }

            if (!_maxActiveReachedTriggered && n.SpawnPoint.ActiveCount == this._maxActiveCount)
            {
                _maxActiveReachedTriggered = true;
                _onMaxActiveCountReached.ActivateTrigger(this, null);
            }
            if (!_maxCountReachedTriggered && n.SpawnPoint.TotalCount == this._maxCount)
            {
                _maxCountReachedTriggered = true;
                _onMaxCountReached.ActivateTrigger(this, null);
            }
        }
        private GameObject DoSpawn(ResourceLink link)
        {
            var prefab = link.GetResource <GameObject>();

            if (prefab == null)
            {
                return(null);
            }

            var go = _spawnMechanism.Spawn(prefab, this.transform.position, this.transform.rotation, (_spawnAsChild) ? this.transform : null);

            if (_onSpawnedObject != null && _onSpawnedObject.Count > 0)
            {
                _onSpawnedObject.ActivateTrigger(this, go);
            }

            return(go);
        }
        public override bool Trigger(object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            switch (_mode)
            {
            case TweenHash.AnimMode.To:
                _transition.Values[0].Value = _transition.GetValue();
                break;

            case TweenHash.AnimMode.From:
                _transition.Values[_transition.Values.Count - 1].Value = _transition.GetValue();
                break;
            }

            var twn = SPTween.Tween(_transition)
                      .FromTo("Position", 0f, 1f, _duration)
                      .SetId(this.AutoKillId)
                      .Use(_timeSupplier.TimeSupplier)
                      .Ease(EaseMethods.GetEase(_ease));

            if (_onComplete.Count > 0)
            {
                twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null));
            }

            if (_onTick.Count > 0)
            {
                twn.OnStep((t) => _onTick.ActivateTrigger(this, null));
            }

            twn.Play(true);

            return(true);
        }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var targ = this.ResolveTargetAnimator(arg);

            if (targ == null)
            {
                return(false);
            }

            var anim = this.TryPlay(targ);

            if (anim == null)
            {
                if (_triggerCompleteIfNoAnim)
                {
                    this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0.01f);
                }
                return(false);
            }

            if (_onAnimComplete.Count > 0)
            {
                if (anim is ISPAnim)
                {
                    (anim as ISPAnim).Schedule((s) =>
                    {
                        _onAnimComplete.ActivateTrigger(this, arg);
                    });
                }
                else if (anim is AnimationState)
                {
                    GameLoopEntry.Hook.StartCoroutine((anim as AnimationState).ScheduleLegacy(() =>
                    {
                        _onAnimComplete.ActivateTrigger(this, arg);
                    }));
                }
            }

            return(false);
        }
 private void OnAudioComplete()
 {
     _completeRoutine = null;
     _onAudioComplete.ActivateTrigger(this, null);
 }
Ejemplo n.º 14
0
 protected override ActionResult OnTick(IAIController ai)
 {
     _trigger.ActivateTrigger(this, null);
     return(ActionResult.Success);
 }
 public virtual void Go(Controller controller)
 {
     goTrigger?.ActivateTrigger();
 }
Ejemplo n.º 16
0
 override public void Activate()
 {
     base.Activate();
     triggerToActivate.ActivateTrigger();
 }
 public virtual void Stop(Controller controller)
 {
     stopTrigger?.ActivateTrigger();
 }
 void IAIState.OnStateExited(IAIStateMachine machine, IAIState nextState)
 {
     this.OnStateExited(machine, nextState);
     _isActive = false;
     _onExitState.ActivateTrigger(this, null);
 }
 void IAIState.OnStateEntered(IAIStateMachine machine, IAIState lastState)
 {
     _isActive = true;
     this.OnStateEntered(machine, lastState);
     _onEnterState.ActivateTrigger(this, null);
 }