public void MoveDirectly(string key, Position dest) { if (!NameToEntity.ContainsKey(key) || PosToName.ContainsKey(dest)) { return; } Entity e = NameToEntity[key]; Position pos = e.Pos; PosToName.Remove(pos); NameToEntity.Remove(key); Add(key, e.UpdateWith(pos: dest)); foreach (var k in NameToEntity.Keys) { if (NameToEntity[k].Faction == e.Faction) { NameToEntity[k] = NameToEntity[k].UpdateAlly(pos, dest); } else { NameToEntity[k] = NameToEntity[k].UpdateEnemy(pos, dest); } } // byName[key].Seeker.SetGoal(dest.Y, dest.X); // byPosition[dest].Seeker.SetGoal(dest.Y, dest.X); //Seeker.GetPath(Y, X); }
public void Move(string key, int yMove, int xMove) { if (!NameToEntity.ContainsKey(key) || PosToName.ContainsKey(new Position(NameToEntity[key].Pos.Y + yMove, NameToEntity[key].Pos.X + xMove))) { return; } Entity e = NameToEntity[key]; Position pos = e.Pos; PosToName.Remove(pos); NameToEntity.Remove(key); e.Pos.Move(yMove, xMove); Add(key, e); foreach (var k in NameToEntity.Keys) { if (NameToEntity[k].Faction == e.Faction) { NameToEntity[k] = NameToEntity[k].UpdateAlly(pos, e.Pos); } else { NameToEntity[k] = NameToEntity[k].UpdateEnemy(pos, e.Pos); } } // byName[key].Seeker.SetGoal(e.Pos.Y, e.Pos.X); // byPosition[e.Pos].Seeker.SetGoal(e.Pos.Y, e.Pos.X); //Seeker.GetPath(Y, X); }
public bool ContainsExactly(Entity key) { if (key == null) { return(false); } return(NameToEntity.ContainsKey(key.Name) && NameToEntity[key.Name].Equals(key)); }
public bool Contains(Entity key) { if (key == null) { return(false); } return(NameToEntity.ContainsKey(key.Name)); }
public int Step(string key) { if (!NameToEntity.ContainsKey(key)) { return(0); } Entity e = NameToEntity[key]; if (e.Seeker.Path == null || e.Seeker.Path.Count == 0) { return(0); } Position nxt = e.Seeker.Path.First(); e.Seeker.Path.RemoveAt(0); MoveDirectly(key, nxt); return(e.Seeker.Path.Count); }
public bool Contains(string key) { return(NameToEntity.ContainsKey(key)); }