Overhaul resource layer logic:
* ResourceType trait has been removed. * Simulation-related data is now defined on the ResourceLayer (which mods can subclass/replace). * Support non-money resources by moving the resource values to the PlayerResources trait. * Allow mods to disable the neighbour density override and instead always use the map-defined densities. * Allow mods to define their own resource placement logic (e.g. allow resources on slopes) by subclassing (Editor)ResourceLayer. * Improve ability to subclass/override ResourceRenderer by exposing more virtual methods.
This commit is contained in:
@@ -57,7 +57,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly RefineryInfo info;
|
||||
readonly Dictionary<string, int> resourceValues;
|
||||
PlayerResources playerResources;
|
||||
IEnumerable<int> resourceValueModifiers;
|
||||
|
||||
@@ -83,8 +82,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
currentDisplayTick = info.TickRate;
|
||||
resourceValues = self.World.WorldActor.TraitsImplementing<ResourceType>()
|
||||
.ToDictionary(r => r.Info.Type, r => r.Info.ValuePerUnit);
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
@@ -105,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
int IAcceptResources.AcceptResources(string resourceType, int count)
|
||||
{
|
||||
if (!resourceValues.TryGetValue(resourceType, out var resourceValue))
|
||||
if (!playerResources.Info.ResourceValues.TryGetValue(resourceType, out var resourceValue))
|
||||
return 0;
|
||||
|
||||
var value = Util.ApplyPercentageModifiers(count * resourceValue, resourceValueModifiers);
|
||||
|
||||
Reference in New Issue
Block a user