private void OnEntityMoved(object sender, Entity.EntityMovedEventArgs args) { Entities.Move(args.Entity as Entity, args.Entity.Position); if (GameLoop.World.players.ContainsKey(GameLoop.NetworkingManager.myUID)) { GameLoop.UIManager.CenterOnActor(GameLoop.World.players[GameLoop.NetworkingManager.myUID]); } }
/// <summary> /// Handles pathfinding walkability view syncing for entities /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnEntityMoved(object sender, Entity.EntityMovedEventArgs args) { // Reset from position Walkability[args.FromPosition.Y * Width + args.FromPosition.X] = true; // Set new position Walkability[args.Entity.Position.Y * Width + args.Entity.Position.X] = false; // Recalculate field of view if (args.Entity is Actor actor) { actor.FieldOfView.Calculate(); } }
// When the Entity's .Moved value changes, it triggers this event handler // which updates the Entity's current position in the SpatialMap private void OnEntityMoved(object sender, Entity.EntityMovedEventArgs args) { Entities.Move(args.Entity as Entity, args.Entity.Position); }
private void Entity_Moved(object sender, Entity.EntityMovedEventArgs e) => EvaluateEntityState((Entity)sender);