Rewrite ActorInit queries.

This commit is contained in:
Paul Chote
2020-05-24 22:28:16 +01:00
committed by teinarss
parent 626b40f31b
commit 7c6ec577dc
66 changed files with 332 additions and 265 deletions

View File

@@ -118,8 +118,7 @@ namespace OpenRA.Mods.Common.Traits
public EditorActorPreview Add(string id, ActorReference reference, bool initialSetup = false)
{
var owner = Players.Players[reference.InitDict.Get<OwnerInit>().PlayerName];
var owner = Players.Players[reference.InitDict.Get<OwnerInit>().InternalName];
var preview = new EditorActorPreview(worldRenderer, id, reference, owner);
Add(preview, initialSetup);

View File

@@ -67,11 +67,11 @@ namespace OpenRA.Mods.Common.Traits
CenterPosition = PreviewPosition(world, actor.InitDict);
var location = actor.InitDict.Get<LocationInit>().Value(worldRenderer.World);
var location = actor.InitDict.Get<LocationInit>().Value;
var ios = Info.TraitInfoOrDefault<IOccupySpaceInfo>();
var subCellInit = actor.InitDict.GetOrDefault<SubCellInit>();
var subCell = subCellInit != null ? subCellInit.Value(worldRenderer.World) : SubCell.Any;
var subCell = subCellInit != null ? subCellInit.Value : SubCell.Any;
if (ios != null)
Footprint = ios.OccupiedCells(Info, location, subCell);
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits
Func<object, bool> saveInit = init =>
{
var factionInit = init as FactionInit;
if (factionInit != null && factionInit.Faction == Owner.Faction)
if (factionInit != null && factionInit.Value == Owner.Faction)
return false;
// TODO: Other default values will need to be filtered
@@ -166,15 +166,15 @@ namespace OpenRA.Mods.Common.Traits
WPos PreviewPosition(World world, TypeDictionary init)
{
if (init.Contains<CenterPositionInit>())
return init.Get<CenterPositionInit>().Value(world);
return init.Get<CenterPositionInit>().Value;
if (init.Contains<LocationInit>())
{
var cell = init.Get<LocationInit>().Value(world);
var cell = init.Get<LocationInit>().Value;
var offset = WVec.Zero;
var subCellInit = Actor.InitDict.GetOrDefault<SubCellInit>();
var subCell = subCellInit != null ? subCellInit.Value(worldRenderer.World) : SubCell.Any;
var subCell = subCellInit != null ? subCellInit.Value : SubCell.Any;
var buildingInfo = Info.TraitInfoOrDefault<BuildingInfo>();
if (buildingInfo != null)

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
var actorReference = new ActorReference(kv.Value.Value, kv.Value.ToDictionary());
// If there is no real player associated, don't spawn it.
var ownerName = actorReference.InitDict.Get<OwnerInit>().PlayerName;
var ownerName = actorReference.InitDict.Get<OwnerInit>().InternalName;
if (!world.Players.Any(p => p.InternalName == ownerName))
continue;
@@ -68,9 +68,6 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Name;
public SpawnedByMapInit(string name) { Name = name; }
public string Value(World world)
{
return Name;
}
public string Value { get { return Name; } }
}
}