Fix Weapons factory

This commit is contained in:
Paul Chote
2010-02-05 23:25:10 +13:00
parent 32552bce28
commit 504ca7638a
3 changed files with 31 additions and 9 deletions

View File

@@ -7,6 +7,8 @@ namespace OpenRa.Traits
public class ProductionInfo : ITraitInfo public class ProductionInfo : ITraitInfo
{ {
public readonly int[] SpawnOffset = null; public readonly int[] SpawnOffset = null;
public readonly int[] ProductionOffset = null;
public readonly int[] ExitOffset = null;
public readonly string[] Produces = { }; public readonly string[] Produces = { };
public virtual object Create(Actor self) { return new Production(self); } public virtual object Create(Actor self) { return new Production(self); }
@@ -21,7 +23,20 @@ namespace OpenRa.Traits
public virtual int2? CreationLocation( Actor self, ActorInfo producee ) public virtual int2? CreationLocation( Actor self, ActorInfo producee )
{ {
return ( 1 / 24f * self.CenterLocation ).ToInt2(); var pos = (1 / 24f * self.CenterLocation).ToInt2();
var pi = self.Info.Traits.Get<ProductionInfo>();
if (pi.ProductionOffset != null)
pos += new int2(pi.ProductionOffset[0], pi.ProductionOffset[1]);
return pos;
}
public virtual int2? ExitLocation(Actor self, ActorInfo producee)
{
var pos = (1 / 24f * self.CenterLocation).ToInt2();
var pi = self.Info.Traits.Get<ProductionInfo>();
if (pi.ExitOffset != null)
pos += new int2(pi.ExitOffset[0], pi.ExitOffset[1]);
return pos;
} }
public virtual int CreationFacing( Actor self, Actor newUnit ) public virtual int CreationFacing( Actor self, Actor newUnit )
@@ -38,15 +53,22 @@ namespace OpenRa.Traits
var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner ); var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner );
newUnit.traits.Get<Unit>().Facing = CreationFacing( self, newUnit ); ; newUnit.traits.Get<Unit>().Facing = CreationFacing( self, newUnit ); ;
var pi = self.Info.Traits.Get<ProductionInfo>();
var rp = self.traits.GetOrDefault<RallyPoint>(); var rp = self.traits.GetOrDefault<RallyPoint>();
if( rp != null ) if( rp != null || pi.ExitOffset != null)
{ {
var mobile = newUnit.traits.GetOrDefault<Mobile>(); var mobile = newUnit.traits.GetOrDefault<Mobile>();
if( mobile != null ) if( mobile != null )
{
if (pi.ExitOffset != null)
newUnit.QueueActivity(new Activities.Move(ExitLocation( self, producee).Value, 1));
if (rp != null)
newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) ); newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) );
} }
}
var pi = self.Info.Traits.Get<ProductionInfo>();
if (pi != null && pi.SpawnOffset != null) if (pi != null && pi.SpawnOffset != null)
newUnit.CenterLocation = self.CenterLocation newUnit.CenterLocation = self.CenterLocation
+ new float2(pi.SpawnOffset[0], pi.SpawnOffset[1]); + new float2(pi.SpawnOffset[0], pi.SpawnOffset[1]);

View File

@@ -59,9 +59,9 @@
<sequence name="idle" start="0" /> <sequence name="idle" start="0" />
<sequence name="damaged-idle" start="1" /> <sequence name="damaged-idle" start="1" />
<sequence name="critical-idle" start="2" /> <sequence name="critical-idle" start="2" />
<sequence name="build-top" start="0" length="4" src="weap2" /> <sequence name="build-top" start="0" length="10" src="weap2" />
<sequence name="damaged-build-top" start="4" length="4" src="weap2" /> <sequence name="damaged-build-top" start="10" length="10" src="weap2" />
<sequence name="critical-build-top" start="4" length="4" src="weap2" /> <sequence name="critical-build-top" start="10" length="10" src="weap2" />
<sequence name="idle-top" start="0" length="1" src="weap2" /> <sequence name="idle-top" start="0" length="1" src="weap2" />
<sequence name="damaged-idle-top" start="4" length="1" src="weap2" /> <sequence name="damaged-idle-top" start="4" length="1" src="weap2" />
<sequence name="critical-idle-top" start="4" length="1" src="weap2" /> <sequence name="critical-idle-top" start="4" length="1" src="weap2" />

View File

@@ -167,7 +167,7 @@ WEAP:
LongDesc: Assembly point for vehicle reinforcements LongDesc: Assembly point for vehicle reinforcements
Building: Building:
Power: -30 Power: -30
Footprint: ___ xxx xxx Footprint: ___ xxx ===
Dimensions: 3,3 Dimensions: 3,3
Capturable: true Capturable: true
Bib: yes Bib: yes
@@ -178,8 +178,8 @@ WEAP:
RenderWarFactory: RenderWarFactory:
RallyPoint: RallyPoint:
Production: Production:
ExitOffset:-1,1
Produces: Vehicle Produces: Vehicle
HQ: HQ:
RequiresPower: RequiresPower:
CanPowerDown: CanPowerDown: