public void RefreshBehaviorTick <T>() { EntityBehavior B = GetBehavior <T>().ToDynamic(); if (B != null) { _behaviorTicks[_behaviors.IndexOf(B)] = B.FramesPerTick; } }
public void AddBehavior(EntityBehavior behavior) { if (_behaviors == null) { _behaviors = new List <EntityBehavior>(); _behaviorTicks = new List <int>(); } _behaviors.Add(behavior); _behaviorTicks.Add(0); }
public void RemoveBehavior(EntityBehavior behavior) { if (_behaviors == null) { _behaviors = new List <EntityBehavior>(); _behaviorTicks = new List <int>(); } if (_behaviors.Contains(behavior)) { _behaviorTicks.RemoveAt(_behaviors.IndexOf(behavior)); _behaviors.Remove(behavior); } }
public virtual void Update() { Ani.Position += Speed; Ani.Update(); if (_behaviors != null) { int i = 0; while (i < _behaviors.Count) { EntityBehavior behavior = _behaviors[i]; if (behavior.enabled && _behaviorTicks[i]++ >= behavior.FramesPerTick) { _behaviorTicks[i] = 0; behavior.Update(); } i++; } } }