move common traits

This commit is contained in:
Matthias Mailänder
2015-03-01 16:27:17 +01:00
parent 762c0e12a2
commit 737a0e0b67
22 changed files with 172 additions and 150 deletions

View File

@@ -75,7 +75,6 @@
<Compile Include="Traits\Render\RenderGunboat.cs" />
<Compile Include="Traits\Render\WithCargo.cs" />
<Compile Include="Traits\Render\WithDeliveryAnimation.cs" />
<Compile Include="Traits\Render\WithFire.cs" />
<Compile Include="Traits\Render\WithRoof.cs" />
<Compile Include="Traits\SpawnViceroid.cs" />
<Compile Include="Traits\SupportPowers\IonCannonPower.cs" />

View File

@@ -1,36 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
[Desc("Renders a flame sprite on top of the actor.")]
class WithFireInfo : ITraitInfo, Requires<RenderSpritesInfo>
{
public readonly string StartSequence = "fire-start";
public readonly string LoopSequence = "fire-loop";
public object Create(ActorInitializer init) { return new WithFire(init.Self, this); }
}
class WithFire
{
public WithFire(Actor self, WithFireInfo info)
{
var rs = self.Trait<RenderSprites>();
var fire = new Animation(self.World, rs.GetImage(self));
fire.PlayThen(info.StartSequence, () => fire.PlayRepeating(info.LoopSequence));
rs.Add("fire", new AnimationWithOffset(fire, null, null, 1024));
}
}
}