tidy in OreRefinery, Harvester, CncLobbyLogic, ScaredyCat

This commit is contained in:
Chris Forbes
2011-10-29 17:39:58 +13:00
parent 268f06caf0
commit 9279161de6
29 changed files with 128 additions and 165 deletions

View File

@@ -9,7 +9,6 @@
#endregion
using OpenRA.Mods.RA.Move;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -25,64 +24,17 @@ namespace OpenRA.Mods.RA
{
readonly ScaredyCatInfo Info;
public bool Panicked = false;
public ScaredyCat(Actor self, ScaredyCatInfo info)
{
Info = info;
}
public ScaredyCat(Actor self, ScaredyCatInfo info) { Info = info; }
public void TickIdle(Actor self)
{
if (!Panicked)
return;
if (!Panicked) return;
var target = Util.SubPxVector[self.World.SharedRandom.Next(255)]* Info.MoveRadius / 1024 + self.Location;
self.Trait<Mobile>().ResolveOrder(self, new Order("Move", self, false) { TargetLocation = target });
}
public void Damaged(Actor self, AttackInfo e)
{
Panicked = true;
}
}
class RenderInfantryPanicInfo : RenderInfantryInfo, Requires<ScaredyCatInfo>
{
public override object Create(ActorInitializer init) { return new RenderInfantryPanic(init.self, this); }
}
class RenderInfantryPanic : RenderInfantry
{
readonly ScaredyCat sc;
bool wasPanic;
public RenderInfantryPanic(Actor self, RenderInfantryPanicInfo info)
: base(self, info)
{
sc = self.Trait<ScaredyCat>();
}
protected override string NormalizeInfantrySequence(Actor self, string baseSequence)
{
var prefix = sc != null && sc.Panicked ? "panic-" : "";
if (anim.HasSequence(prefix + baseSequence))
return prefix + baseSequence;
else
return baseSequence;
}
protected override bool AllowIdleAnimation(Actor self)
{
return base.AllowIdleAnimation(self) && !sc.Panicked;
}
public override void Tick (Actor self)
{
if (wasPanic != sc.Panicked)
dirty = true;
wasPanic = sc.Panicked;
base.Tick(self);
}
public void Damaged(Actor self, AttackInfo e) { Panicked = true; }
}
}