Decompose RenderInfantry into WithInfantryBody and RenderSprites.
This commit is contained in:
@@ -45,7 +45,8 @@ namespace OpenRA.Mods.RA.Activities
|
||||
to = self.World.Map.CenterOfSubCell(targetMobile.FromCell, targetMobile.FromSubCell);
|
||||
length = Math.Max((to - from).Length / speed.Range, 1);
|
||||
|
||||
self.Trait<RenderInfantry>().Attacking(self, Target.FromActor(target));
|
||||
// HACK: why isn't this using the interface?
|
||||
self.Trait<WithInfantryBody>().Attacking(self, Target.FromActor(target));
|
||||
|
||||
if (weapon.Report != null && weapon.Report.Any())
|
||||
Sound.Play(weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
|
||||
|
||||
@@ -94,7 +94,6 @@
|
||||
<Compile Include="Traits\PaletteEffects\ChronoshiftPaletteEffect.cs" />
|
||||
<Compile Include="Traits\PortableChrono.cs" />
|
||||
<Compile Include="Traits\Render\RenderJammerCircle.cs" />
|
||||
<Compile Include="Traits\Render\RenderDisguise.cs" />
|
||||
<Compile Include="Traits\Render\RenderLandingCraft.cs" />
|
||||
<Compile Include="Traits\Render\RenderShroudCircle.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnitReload.cs" />
|
||||
@@ -106,6 +105,7 @@
|
||||
<Compile Include="Scripting\Properties\ChronosphereProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\ParadropProperties.cs" />
|
||||
<Compile Include="Scripting\Properties\ParatroopersProperties.cs" />
|
||||
<Compile Include="Traits\Render\WithDisguisingInfantryBody.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
|
||||
@@ -13,21 +13,23 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
class RenderDisguiseInfo : RenderInfantryInfo, Requires<DisguiseInfo>
|
||||
class WithDisguisingInfantryBodyInfo : WithInfantryBodyInfo, Requires<DisguiseInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderDisguise(init, this); }
|
||||
public override object Create(ActorInitializer init) { return new WithDisguisingInfantryBody(init, this); }
|
||||
}
|
||||
|
||||
class RenderDisguise : RenderInfantry
|
||||
class WithDisguisingInfantryBody : WithInfantryBody
|
||||
{
|
||||
RenderDisguiseInfo info;
|
||||
readonly WithDisguisingInfantryBodyInfo info;
|
||||
readonly Disguise disguise;
|
||||
readonly RenderSprites rs;
|
||||
string intendedSprite;
|
||||
Disguise disguise;
|
||||
|
||||
public RenderDisguise(ActorInitializer init, RenderDisguiseInfo info)
|
||||
public WithDisguisingInfantryBody(ActorInitializer init, WithDisguisingInfantryBodyInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
this.info = info;
|
||||
rs = init.Self.Trait<RenderSprites>();
|
||||
disguise = init.Self.Trait<Disguise>();
|
||||
intendedSprite = disguise.AsSprite;
|
||||
}
|
||||
@@ -37,8 +39,8 @@ namespace OpenRA.Mods.RA.Traits
|
||||
if (disguise.AsSprite != intendedSprite)
|
||||
{
|
||||
intendedSprite = disguise.AsSprite;
|
||||
DefaultAnimation.ChangeImage(intendedSprite ?? GetImage(self), info.StandAnimations.Random(Game.CosmeticRandom));
|
||||
UpdatePalette();
|
||||
DefaultAnimation.ChangeImage(intendedSprite ?? rs.GetImage(self), info.StandSequences.Random(Game.CosmeticRandom));
|
||||
rs.UpdatePalette();
|
||||
}
|
||||
|
||||
base.Tick(self);
|
||||
Reference in New Issue
Block a user