public void Apply(Simulation sim, ResourceCollection resources) { if (resources.CanApplyNextCycle(OperatingCost)) { resources.ApplyNextCycle(OperatingCost); resources.GetResource(ResourceType.Deflection).ChangeNextCycle += sim.MaxTime - sim.CurrentTime; } }
public ResourceCollection(ResourceCollection other) : this() { foreach (Resource resource in Resources) { Resource otherResource = other.GetResource(resource.Type); resource.Amount = otherResource.Amount; resource.ChangeNextCycle = otherResource.ChangeNextCycle; } }
public void Apply(Simulation sim, ResourceCollection resources) { resources.GetResource(Type).ChangeNextCycle += Growth; }
public void BuyUpgrade(Upgrade upgrade) { foreach (ResourceDelta cost in upgrade.Cost) { if (!resources.CanApplyImmediate(cost)) { throw new Exception( $"Expected at least {cost.Amount} of {cost.Type}, found only {resources.GetResource(cost.Type).Amount}." + $"This should not happen, because we should have fastforwarded until there was enough!"); } resources.ApplyImmediate(cost); } boughtUpgrades.Add(upgrade); boughtUpgradeTimes.Add(CurrentTime); RecalculateNextCycle(); }