Merge pull request #9073 from pchote/remove-production-duplication
Minor Production trait cleanups.
This commit is contained in:
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Where the unit should leave the building. Multiples are allowed if IDs are added: Exit@2, ...")]
|
[Desc("Where the unit should leave the building. Multiples are allowed if IDs are added: Exit@2, ...")]
|
||||||
public class ExitInfo : TraitInfo<Exit>
|
public class ExitInfo : TraitInfo<Exit>, Requires<IOccupySpaceInfo>
|
||||||
{
|
{
|
||||||
[Desc("Offset at which that the exiting actor is spawned relative to the center of the producing actor.")]
|
[Desc("Offset at which that the exiting actor is spawned relative to the center of the producing actor.")]
|
||||||
public readonly WVec SpawnOffset = WVec.Zero;
|
public readonly WVec SpawnOffset = WVec.Zero;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
readonly Lazy<RallyPoint> rp;
|
readonly Lazy<RallyPoint> rp;
|
||||||
|
|
||||||
public ProductionInfo Info;
|
public readonly ProductionInfo Info;
|
||||||
public string Faction { get; private set; }
|
public string Faction { get; private set; }
|
||||||
|
|
||||||
readonly bool occupiesSpace;
|
readonly bool occupiesSpace;
|
||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public Production(ActorInitializer init, ProductionInfo info)
|
public Production(ActorInitializer init, ProductionInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
occupiesSpace = init.Self.Info.Traits.WithInterface<IOccupySpaceInfo>().Any();
|
occupiesSpace = init.Self.Info.Traits.Contains<IOccupySpaceInfo>();
|
||||||
rp = Exts.Lazy(() => init.Self.IsDead ? null : init.Self.TraitOrDefault<RallyPoint>());
|
rp = Exts.Lazy(() => init.Self.IsDead ? null : init.Self.TraitOrDefault<RallyPoint>());
|
||||||
Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
|
Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
|
||||||
}
|
}
|
||||||
@@ -118,17 +118,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (Reservable.IsReserved(self))
|
if (Reservable.IsReserved(self))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!occupiesSpace)
|
|
||||||
{
|
|
||||||
DoProduction(self, producee, null, factionVariant);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pick a spawn/exit point pair
|
// Pick a spawn/exit point pair
|
||||||
var exit = self.Info.Traits.WithInterface<ExitInfo>().Shuffle(self.World.SharedRandom)
|
var exit = self.Info.Traits.WithInterface<ExitInfo>().Shuffle(self.World.SharedRandom)
|
||||||
.FirstOrDefault(e => CanUseExit(self, producee, e));
|
.FirstOrDefault(e => CanUseExit(self, producee, e));
|
||||||
|
|
||||||
if (exit != null)
|
if (exit != null || !occupiesSpace)
|
||||||
{
|
{
|
||||||
DoProduction(self, producee, exit, factionVariant);
|
DoProduction(self, producee, exit, factionVariant);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ conyard:
|
|||||||
Range: 10c0
|
Range: 10c0
|
||||||
Production:
|
Production:
|
||||||
Produces: Building, Upgrade
|
Produces: Building, Upgrade
|
||||||
MoveIntoWorld: false
|
|
||||||
Exit:
|
Exit:
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 2000
|
Cost: 2000
|
||||||
|
|||||||
Reference in New Issue
Block a user