From 3b6523236517786426f67bd1316b78c44b1cf7c0 Mon Sep 17 00:00:00 2001 From: teees Date: Fri, 11 Dec 2015 17:48:30 +0100 Subject: [PATCH] Optionally discard resources when silo capacity has been reached --- OpenRA.Mods.Common/Traits/Buildings/Refinery.cs | 7 ++++++- mods/ts/rules/shared-structures.yaml | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs index e1d33418da..b444668176 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs @@ -35,6 +35,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("In how many steps to perform the dragging?")] public readonly int DragLength = 0; + [Desc("Discard resources once silo capacity has been reached.")] + public readonly bool DiscardExcessResources = false; + public readonly bool ShowTicks = true; public readonly int TickLifetime = 30; public readonly int TickVelocity = 2; @@ -84,10 +87,12 @@ namespace OpenRA.Mods.Common.Traits .Where(a => a.Trait.LinkedProc == self); } - public bool CanGiveResource(int amount) { return playerResources.CanGiveResources(amount); } + public bool CanGiveResource(int amount) { return info.DiscardExcessResources || playerResources.CanGiveResources(amount); } public void GiveResource(int amount) { + if (info.DiscardExcessResources) + amount = Math.Min(amount, playerResources.ResourceCapacity - playerResources.Resources); playerResources.GiveResources(amount); if (info.ShowTicks) currentDisplayValue += amount; diff --git a/mods/ts/rules/shared-structures.yaml b/mods/ts/rules/shared-structures.yaml index 53673819e4..f90ab5ed2b 100644 --- a/mods/ts/rules/shared-structures.yaml +++ b/mods/ts/rules/shared-structures.yaml @@ -76,6 +76,7 @@ PROC: TiberianSunRefinery: DockAngle: 160 DockOffset: 2,1 + DiscardExcessResources: true StoresResources: PipColor: Green PipCount: 15