Change ActorIndex to work in terms of TraitInfo, instead of Trait.
This allows actor.Info.HasTraitInfo to be used when checking if an actor needs to be added to the index, which is a cheaper call than actor.TraitsImplementing.
This commit is contained in:
@@ -70,8 +70,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Func<Actor, bool> unitCannotBeOrdered;
|
||||
readonly Dictionary<Actor, HarvesterTraitWrapper> harvesters = new();
|
||||
readonly Stack<HarvesterTraitWrapper> harvestersNeedingOrders = new();
|
||||
readonly ActorIndex.OwnerAndNamesAndTrait<Building> refineries;
|
||||
readonly ActorIndex.OwnerAndNamesAndTrait<Harvester> harvestersIndex;
|
||||
readonly ActorIndex.OwnerAndNamesAndTrait<BuildingInfo> refineries;
|
||||
readonly ActorIndex.OwnerAndNamesAndTrait<HarvesterInfo> harvestersIndex;
|
||||
readonly Dictionary<CPos, string> resourceTypesByCell = new();
|
||||
|
||||
IResourceLayer resourceLayer;
|
||||
@@ -85,8 +85,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
world = self.World;
|
||||
player = self.Owner;
|
||||
unitCannotBeOrdered = a => a.Owner != self.Owner || a.IsDead || !a.IsInWorld;
|
||||
refineries = new ActorIndex.OwnerAndNamesAndTrait<Building>(world, info.RefineryTypes, player);
|
||||
harvestersIndex = new ActorIndex.OwnerAndNamesAndTrait<Harvester>(world, info.HarvesterTypes, player);
|
||||
refineries = new ActorIndex.OwnerAndNamesAndTrait<BuildingInfo>(world, info.RefineryTypes, player);
|
||||
harvestersIndex = new ActorIndex.OwnerAndNamesAndTrait<HarvesterInfo>(world, info.HarvesterTypes, player);
|
||||
}
|
||||
|
||||
protected override void Created(Actor self)
|
||||
|
||||
Reference in New Issue
Block a user