public void Run(State state) { var node = state.Geo.Nodes.FirstOrDefault(n => n.Id == Id); if (node != null) { // update node node.Type = Type; node.X = X; node.Y = Y; node.Floor = Floor; node.Depot = Depot; node.Icon = Icon ?? node.Icon; node.Name = Name ?? node.Name; if (OperationIds != null) { node.OperationIds = OperationIds; } EventAddEdge.RecalculateWeights(node, state); } else { var id = Utils.CreateIdFor(state.Geo.Nodes.Select(n => n.Id).ToList()); var nd = new Node { Id = id, Depot = Depot, Floor = Floor, Type = Type, X = X, Y = Y, Icon = Icon ?? "", Name = Name ?? "", OperationIds = OperationIds ?? new List <int>() }; nd.Name = AliceController.GetCorrectNodeName(state, nd); // add node state.Geo.Nodes.Add(nd); } EventAddDepot.RedefineDepots(state); }
public void Run(State state) { var depot = state.Geo.Depots.FirstOrDefault( x => (x.Id == Id) ); if (depot != null) { state.Geo.Depots.Remove(depot); foreach (var node in state.Geo.Nodes) { if (node.X > depot.X && node.X < depot.X + depot.W && node.Y > depot.Y && node.Y < depot.Y + depot.H && node.Floor == depot.Floor) { node.Depot = 0; } } } EventAddDepot.RedefineDepots(state); }