Ejemplo n.º 1
0
        public override void Initialize()
        {
            base.Initialize();

            _currentDamageState = DamageState.Alive;
            CurrentMobState     = _behavior[_currentDamageState];
            CurrentMobState.EnterState(Owner);
            CurrentMobState.UpdateState(Owner);
        }
Ejemplo n.º 2
0
 public MobStateChangedMessage(
     IMobStateComponent component,
     IMobState?oldMobState,
     IMobState currentMobState)
 {
     Component       = component;
     OldMobState     = oldMobState;
     CurrentMobState = currentMobState;
 }
Ejemplo n.º 3
0
        public void OnHealthChanged(HealthChangedEventArgs e)
        {
            if (e.Damageable.CurrentDamageState != _currentDamageState)
            {
                _currentDamageState = e.Damageable.CurrentDamageState;
                CurrentMobState.ExitState(Owner);
                CurrentMobState = _behavior[_currentDamageState];
                CurrentMobState.EnterState(Owner);
            }

            CurrentMobState.UpdateState(Owner);
        }
Ejemplo n.º 4
0
 public IdleState(IMobState nextState, DateTime?expiry = null)
 {
     NextState = nextState;
     if (expiry != null)
     {
         Expiry = expiry.Value;
     }
     else
     {
         Expiry = DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(5, 15));
     }
 }
        public bool TryGetState(
            int damage,
            [NotNullWhen(true)] out IMobState?state,
            out int threshold)
        {
            var highestState = GetState(damage);

            if (highestState == null)
            {
                state     = default;
                threshold = default;
                return(false);
            }

            (state, threshold) = highestState.Value;
            return(true);
        }
Ejemplo n.º 6
0
        public bool TryGetEarliestIncapacitatedState(
            int minimumDamage,
            [NotNullWhen(true)] out IMobState?state,
            out int threshold)
        {
            var earliestState = GetEarliestIncapacitatedState(minimumDamage);

            if (earliestState == null)
            {
                state     = default;
                threshold = default;
                return(false);
            }

            (state, threshold) = earliestState.Value;
            return(true);
        }
Ejemplo n.º 7
0
 public void ChangeState(IMobState state)
 {
     CurrentState = state;
 }
Ejemplo n.º 8
0
 public void ChangeState(IMobState state)
 {
     CurrentState = state;
 }