protected override void TickCore(Entity host, RealmTime time, ref object state) { BuzzStorage storage = (BuzzStorage)state; Status = CycleStatus.NotStarted; if (host.HasConditionEffect(ConditionEffects.Paralyzed)) { return; } if (storage.RemainingTime > 0) { storage.RemainingTime -= time.thisTickTimes; Status = CycleStatus.NotStarted; } else { Status = CycleStatus.InProgress; if (storage.RemainingDistance <= 0) { do { storage.Direction = new Vector2(Random.Next(-1, 2), Random.Next(-1, 2)); } while (storage.Direction.X == 0 && storage.Direction.Y == 0); storage.Direction.Normalize(); storage.RemainingDistance = this.dist; Status = CycleStatus.Completed; } float dist = host.GetSpeed(speed) * (time.thisTickTimes / 1000f); host.ValidateAndMove(host.X + storage.Direction.X * dist, host.Y + storage.Direction.Y * dist); host.UpdateCount++; storage.RemainingDistance -= dist; } state = storage; }
protected override void OnStateEntry(Entity host, RealmTime time, ref object state) { state = new BuzzStorage(); }