public TargettingState( BaseMapHandler map, BaseActor source, Measure measure, TargetZone zone, Func <IEnumerable <Loc>, Option <ICommand> > callback) { _map = map; _source = source; _targetZone = zone; _callback = callback; _targettableActors = new List <BaseActor>(); _targetted = new List <Loc>(); _path = new List <Loc>(); _measure = measure; var actor = (Mech)_source; _inRange = zone.GetAllValidTargets(actor.Pos, actor.Facing, _measure, true); // Pick out the interesting targets. // TODO: select items for item targetting spells foreach (Loc point in _inRange) { _map.GetActor(point) .MatchSome(actor => _targettableActors.Add(actor)); } // Initialize the targetting to an interesting target. var firstActor = Option.None <BaseActor>(); foreach (BaseActor target in _targettableActors) { if (!(target is Player) && _map.Field[target.Pos].IsVisible) { firstActor = Option.Some(target); break; } } firstActor.Match( some: first => _cursor = first.Pos, none: () => _cursor = source.Pos); DrawTargettedTiles(); }
public TargettingState( Actor.Actor source, TargetZone zone, int spellnum, Func <IEnumerable <Loc>, Option <ICommand> > callback) { _source = source; _targetZone = zone; CurrentSpell = spellnum; _callback = callback; _targettableActors = new List <Actor.Actor>(); _targetted = new List <Loc>(); _path = new List <Loc>(); _inRange = zone.GetAllValidTargets(_source.Pos); // Pick out the interesting targets. // TODO: select items for item targetting spells foreach (Loc point in _inRange) { Game.MapHandler.GetActor(point) .MatchSome(actor => _targettableActors.Add(actor)); } // Initialize the targetting to an interesting target. var firstActor = Option.None <Actor.Actor>(); foreach (Actor.Actor target in _targettableActors) { if (!(target is Actor.Player) && Game.MapHandler.Field[target.Pos].IsVisible) { firstActor = Option.Some(target); break; } } firstActor.Match( some: first => _cursor = first.Pos, none: () => _cursor = source.Pos); DrawTargettedTiles(); }