private void ProvideMaterial(object o) { var po = o as ProductionOrderFinished; var request = po.Message as MaterialRequest; if (request.Material.Name == "Table") { Logger.Log(LogLevel.Info, "Simulation: Table No: {arg} has finished", new object[] { ++MaterialCounter }); } //Console.WriteLine("Time: " + TimePeriod + " Number " + MaterialCounter + " Finished: " + request.Material.Name); if (!request.IsHead) { var parrent = WaitingItems.Single(x => x.Id == request.Parrent); parrent.ChildRequests[request.Id] = true; // now check if item can be deployd to ReadyQueue if (parrent.ChildRequests.All(x => x.Value == true)) { WaitingItems.Remove(parrent); ReadyItems.Enqueue(parrent); } } Machines.Remove(Sender); Machines.Add(Sender, true); PushWork(); }
/// <summary> /// solve Tree /// </summary> /// <param name="request"></param> private void MaterialRequest(object o) { var p = o as ProductionOrder; var request = p.Message as MaterialRequest; if (request.Material.Materials != null) { foreach (var child in request.Material.Materials) { for (int i = 0; i < child.Quantity; i++) { var childRequest = new MaterialRequest(material: child, childRequests: null, parrent: request.Id, due: request.Due - request.Material.AssemblyDuration - child.AssemblyDuration, isHead: false); request.ChildRequests.Add(childRequest.Id, false); var po = new ProductionOrder(childRequest, Self); _SimulationContext.Tell(po, Self); } } } if (request.Material.IsReady) { ReadyItems.Enqueue(request); } else { WaitingItems.Add(request); } PushWork(); }
private void PushWork() { if (Machines.ContainsValue(true) && ReadyItems.Count() != 0) { var key = Machines.First(X => X.Value == true).Key; Machines.Remove(key); var m = new MachineAgent.Work(ReadyItems.Dequeue(), key); Machines.Add(key, false); _SimulationContext.Tell(m, Sender); } ; }
public Inventory(List <byte> gameStateByteArray, DataOvlReference dataOvlRef) { this.gameStateByteArray = gameStateByteArray; DataChunk.CreateDataChunk(DataChunk.DataFormatType.Byte, "Grapple", gameStateByteArray, 0x209, sizeof(byte)); DataChunk.CreateDataChunk(DataChunk.DataFormatType.Byte, "Magic Carpet", gameStateByteArray, 0x20A, sizeof(byte)); ProtectiveArmour = new Armours(dataOvlRef, gameStateByteArray); AllItems.AddRange(ProtectiveArmour.GenericItemList); ReadyItems.AddRange(ProtectiveArmour.GenericItemList); TheWeapons = new Weapons(dataOvlRef, gameStateByteArray); ReadyItems.AddRange(TheWeapons.GenericItemList); MagicScrolls = new Scrolls(dataOvlRef, gameStateByteArray); UseItems.AddRange(MagicScrolls.GenericItemList); MagicPotions = new Potions(dataOvlRef, gameStateByteArray); UseItems.AddRange(MagicPotions.GenericItemList); SpecializedItems = new SpecialItems(dataOvlRef, gameStateByteArray); AllItems.AddRange(SpecializedItems.GenericItemList); UseItems.AddRange(SpecializedItems.GenericItemList); Artifacts = new LordBritishArtifacts(dataOvlRef, gameStateByteArray); AllItems.AddRange(Artifacts.GenericItemList); UseItems.AddRange(Artifacts.GenericItemList); Shards = new ShadowlordShards(dataOvlRef, gameStateByteArray); AllItems.AddRange(Shards.GenericItemList); UseItems.AddRange(Shards.GenericItemList); SpellReagents = new Reagents(dataOvlRef, gameStateByteArray); AllItems.AddRange(SpellReagents.GenericItemList); MagicSpells = new Spells(dataOvlRef, gameStateByteArray); AllItems.AddRange(MagicSpells.GenericItemList); }