internal void AddMoreMaterials(Conveyor conveyor) { IsFree = false; conveyor.UpdateState(ConveyorState.AddMaterials); Thread.Sleep(1000); IsFree = true; }
public void Repair(Conveyor conveyor) { lock (Locker) { IsFree = false; conveyor.UpdateState(ConveyorState.InRepairing); Thread.Sleep(2000); IsFree = true; } }
public async void AddNewConveyor() { var conveyor = new Conveyor(); conveyor.AddMaterials += HandleAddMaterials; conveyor.Repair += HandleRepair; conveyor.Update += HandleUpdate; Conveyors.Add(conveyor); ConveyorAdded?.Invoke(conveyor); await Task.Run(conveyor.StartWorking); }
private void HandleUpdate(Conveyor caller, ConveyorState state) { var pos = Conveyors.FindIndex(conveyor => conveyor == caller); UpdateView?.Invoke(pos, state, Loader.IsFree, Mechanic.IsFree); }
private void HandleRepair(Conveyor caller) { Mechanic.Repair(caller); }
private void HandleAddMaterials(Conveyor caller) { Loader.AddMoreMaterials(caller); }