public override void EnterState(WorldScreen Game, World World) { World.PrepareCombatGridForPlayerInput(); }
private void PrepareCombatGrid(WorldScreen Game, World World) { // Setup the combat grid World.PrepareCombatGridForPlayerInput(); var pathfinder = new Gem.Pathfinding<CombatCell>(c => new List<CombatCell>(c.Links.Select(l => l.Neighbor).Where(n => World.GlobalRules.ConsiderCheckRule("can-traverse", BoundActor, n) == SharpRuleEngine.CheckResult.Allow)), a => 1.0f); var path = pathfinder.Flood(World.CombatGrid.Cells[(int)BoundActor.Orientation.Position.X, (int)BoundActor.Orientation.Position.Y, (int)BoundActor.Orientation.Position.Z], c => false, c => 1.0f); var walkCommand = BoundActor.Properties.GetPropertyAsOrDefault<PlayerCommand>("walk-command"); if (walkCommand != null) { foreach (var node in path.VisitedNodes) { var commandProperties = Gem.PropertyBag.Create( "actor", BoundActor, "game", Game, "world", World, "cell", node.Key, "path", node.Value); var canWalk = walkCommand.ConsiderCheck(commandProperties); if (canWalk == SharpRuleEngine.CheckResult.Allow) { node.Key.Visible = true; node.Key.Texture = 1; node.Key.PathNode = node.Value; var localNode = node; node.Key.ClickAction = () => walkCommand.ConsiderPerform(commandProperties); node.Key.HoverAction = () => PreviewCost = (int)localNode.Value.PathCost; } } } }