declare Burns -> RenderSimple dep; remove first tick weirdness
This commit is contained in:
@@ -13,35 +13,37 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class BurnsInfo : TraitInfo<Burns>
|
class BurnsInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||||
{
|
{
|
||||||
public readonly string Anim = "1";
|
public readonly string Anim = "1";
|
||||||
public readonly int Damage = 1;
|
public readonly int Damage = 1;
|
||||||
public readonly int Interval = 8;
|
public readonly int Interval = 8;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new Burns(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class Burns : ITick, ISync
|
class Burns : ITick, ISync
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
int ticks;
|
int ticks;
|
||||||
bool isSetup;
|
BurnsInfo Info;
|
||||||
|
|
||||||
|
public Burns(Actor self, BurnsInfo info)
|
||||||
|
{
|
||||||
|
Info = info;
|
||||||
|
var rs = self.Trait<RenderSimple>();
|
||||||
|
var anim = new Animation("fire", () => 0);
|
||||||
|
anim.PlayRepeating(Info.Anim);
|
||||||
|
rs.anims.Add("fire",
|
||||||
|
new AnimationWithOffset(anim, () => new float2(0, -3), null));
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (!isSetup)
|
|
||||||
{
|
|
||||||
isSetup = true;
|
|
||||||
|
|
||||||
var anim = new Animation("fire", () => 0);
|
|
||||||
anim.PlayRepeating(self.Info.Traits.Get<BurnsInfo>().Anim);
|
|
||||||
self.Trait<RenderSimple>().anims.Add("fire",
|
|
||||||
new AnimationWithOffset(anim, () => new float2(0, -3), null));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (--ticks <= 0)
|
if (--ticks <= 0)
|
||||||
{
|
{
|
||||||
self.InflictDamage(self, self.Info.Traits.Get<BurnsInfo>().Damage, null);
|
self.InflictDamage(self, Info.Damage, null);
|
||||||
ticks = self.Info.Traits.Get<BurnsInfo>().Interval;
|
ticks = Info.Interval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user