private void ConsumeResources(ResponseHandle <Resources.Commands.ConsumeResources, ConsumptionRequest, ConsumptionResponse> responseHandle) { Evolution.Material consumed = responseHandle.Request.consumed; Evolution.Material produced = responseHandle.Request.produced; Map <Evolution.Material, uint> toxicLimits = responseHandle.Request.toxicLimits; var resources = ResourcesWriter.Data.resources; uint toxicity = 0; foreach (KeyValuePair <Evolution.Material, uint> resource in resources) { if (resource.Value > toxicLimits[resource.Key]) { toxicity += 1; } } if (resources[consumed] > 0) { resources[consumed] -= 1; resources[produced] += 1; ResourcesWriter.Send(new Resources.Update().SetResources(resources)); responseHandle.Respond(new ConsumptionResponse(false, toxicity)); } else { responseHandle.Respond(new ConsumptionResponse(true, toxicity)); } }
public static Evolution.Material getWaste(Evolution.Material food) { if (food == Evolution.Material.A) { return(Evolution.Material.B); } else if (food == Evolution.Material.B) { return(Evolution.Material.C); } else { return(Evolution.Material.A); } }