Add wrappers for RenderSprites anims dictionary.
This commit is contained in:
@@ -35,7 +35,7 @@ namespace OpenRA.Traits
|
|||||||
public RenderSimple(Actor self, Func<int> baseFacing)
|
public RenderSimple(Actor self, Func<int> baseFacing)
|
||||||
: base(self)
|
: base(self)
|
||||||
{
|
{
|
||||||
anims.Add("", new Animation(self.World, GetImage(self), baseFacing));
|
Add("", new Animation(self.World, GetImage(self), baseFacing));
|
||||||
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
Info = self.Info.Traits.Get<RenderSimpleInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,16 @@ namespace OpenRA.Traits
|
|||||||
a.Animation.Tick();
|
a.Animation.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Add(string key, AnimationWithOffset anim)
|
||||||
|
{
|
||||||
|
anims.Add(key, anim);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
anims.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
public static string NormalizeSequence(Animation anim, DamageState state, string baseSequence)
|
public static string NormalizeSequence(Animation anim, DamageState state, string baseSequence)
|
||||||
{
|
{
|
||||||
var states = new Pair<DamageState, string>[]
|
var states = new Pair<DamageState, string>[]
|
||||||
|
|||||||
@@ -37,19 +37,19 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
left = new Animation(self.World, name, () => turret.turretFacing);
|
left = new Animation(self.World, name, () => turret.turretFacing);
|
||||||
left.Play("left");
|
left.Play("left");
|
||||||
anims.Add("left", new AnimationWithOffset(left, null, () => facing.Facing > 128, 0));
|
Add("left", new AnimationWithOffset(left, null, () => facing.Facing > 128, 0));
|
||||||
|
|
||||||
right = new Animation(self.World, name, () => turret.turretFacing);
|
right = new Animation(self.World, name, () => turret.turretFacing);
|
||||||
right.Play("right");
|
right.Play("right");
|
||||||
anims.Add("right", new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
|
Add("right", new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
|
||||||
|
|
||||||
var leftWake = new Animation(self.World, name);
|
var leftWake = new Animation(self.World, name);
|
||||||
leftWake.Play("wake-left");
|
leftWake.Play("wake-left");
|
||||||
anims.Add("wake-left", new AnimationWithOffset(leftWake, null, () => facing.Facing > 128, -87));
|
Add("wake-left", new AnimationWithOffset(leftWake, null, () => facing.Facing > 128, -87));
|
||||||
|
|
||||||
var rightWake = new Animation(self.World, name);
|
var rightWake = new Animation(self.World, name);
|
||||||
rightWake.Play("wake-right");
|
rightWake.Play("wake-right");
|
||||||
anims.Add("wake-right", new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));
|
Add("wake-right", new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));
|
||||||
|
|
||||||
self.Trait<IBodyOrientation>().SetAutodetectedFacings(2);
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
var rs = self.Trait<RenderSprites>();
|
var rs = self.Trait<RenderSprites>();
|
||||||
var roof = new Animation(self.World, rs.GetImage(self));
|
var roof = new Animation(self.World, rs.GetImage(self));
|
||||||
roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop"));
|
roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop"));
|
||||||
rs.anims.Add("fire", new AnimationWithOffset(roof, null, null, 1024));
|
rs.Add("fire", new AnimationWithOffset(roof, null, null, 1024));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
var rs = self.Trait<RenderSprites>();
|
var rs = self.Trait<RenderSprites>();
|
||||||
var roof = new Animation(self.World, rs.GetImage(self), () => self.Trait<IFacing>().Facing);
|
var roof = new Animation(self.World, rs.GetImage(self), () => self.Trait<IFacing>().Facing);
|
||||||
roof.Play("roof");
|
roof.Play("roof");
|
||||||
rs.anims.Add("roof", new AnimationWithOffset(roof, null, null, 1024));
|
rs.Add("roof", new AnimationWithOffset(roof, null, null, 1024));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
overlay = new Animation(self.World, rs.GetImage(self));
|
overlay = new Animation(self.World, rs.GetImage(self));
|
||||||
overlay.Play(info.Sequence);
|
overlay.Play(info.Sequence);
|
||||||
rs.anims.Add("crane_overlay_{0}".F(info.Sequence),
|
rs.Add("crane_overlay_{0}".F(info.Sequence),
|
||||||
new AnimationWithOffset(overlay,
|
new AnimationWithOffset(overlay,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !buildComplete));
|
() => !buildComplete));
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
var overlay = new Animation(init.world, rs.GetImage(init.self));
|
var overlay = new Animation(init.world, rs.GetImage(init.self));
|
||||||
overlay.PlayThen(info.Sequence, () => buildComplete = false);
|
overlay.PlayThen(info.Sequence, () => buildComplete = false);
|
||||||
rs.anims.Add("make_overlay_{0}".F(info.Sequence),
|
rs.Add("make_overlay_{0}".F(info.Sequence),
|
||||||
new AnimationWithOffset(overlay, null, () => !buildComplete));
|
new AnimationWithOffset(overlay, null, () => !buildComplete));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
overlay = new Animation(self.World, rs.GetImage(self));
|
overlay = new Animation(self.World, rs.GetImage(self));
|
||||||
overlay.Play(info.Sequence);
|
overlay.Play(info.Sequence);
|
||||||
rs.anims.Add("delivery_overlay_{0}".F(info.Sequence),
|
rs.Add("delivery_overlay_{0}".F(info.Sequence),
|
||||||
new AnimationWithOffset(overlay,
|
new AnimationWithOffset(overlay,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !buildComplete));
|
() => !buildComplete));
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
overlay = new Animation(self.World, rs.GetImage(self));
|
overlay = new Animation(self.World, rs.GetImage(self));
|
||||||
overlay.Play(info.Sequence);
|
overlay.Play(info.Sequence);
|
||||||
rs.anims.Add("docking_overlay_{0}".F(info.Sequence),
|
rs.Add("docking_overlay_{0}".F(info.Sequence),
|
||||||
new AnimationWithOffset(overlay,
|
new AnimationWithOffset(overlay,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !buildComplete));
|
() => !buildComplete));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
overlay = new Animation(self.World, rs.GetImage(self));
|
overlay = new Animation(self.World, rs.GetImage(self));
|
||||||
overlay.PlayRepeating(info.Sequence);
|
overlay.PlayRepeating(info.Sequence);
|
||||||
rs.anims.Add("production_overlay_{0}".F(info.Sequence),
|
rs.Add("production_overlay_{0}".F(info.Sequence),
|
||||||
new AnimationWithOffset(overlay,
|
new AnimationWithOffset(overlay,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !IsProducing || !buildComplete));
|
() => !IsProducing || !buildComplete));
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
|
|||||||
var anim = new Animation(self.World, "fire", () => 0);
|
var anim = new Animation(self.World, "fire", () => 0);
|
||||||
anim.IsDecoration = true;
|
anim.IsDecoration = true;
|
||||||
anim.PlayRepeating(Info.Anim);
|
anim.PlayRepeating(Info.Anim);
|
||||||
self.Trait<RenderSprites>().anims.Add("fire", anim);
|
self.Trait<RenderSprites>().Add("fire", anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
// Additional 512 units move from center -> top of cell
|
// Additional 512 units move from center -> top of cell
|
||||||
var offset = FootprintUtils.CenterOffset(bi).Y + 512;
|
var offset = FootprintUtils.CenterOffset(bi).Y + 512;
|
||||||
anims.Add("roof", new AnimationWithOffset(roof, null,
|
Add("roof", new AnimationWithOffset(roof, null,
|
||||||
() => !buildComplete, offset));
|
() => !buildComplete, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
roof.PlayThen(NormalizeSequence(self, "build-top"), () => { isOpen = true; openExit = exit; });
|
roof.PlayThen(NormalizeSequence(self, "build-top"), () => { isOpen = true; openExit = exit; });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Selling(Actor self) { anims.Remove("roof"); }
|
public void Selling(Actor self) { Remove("roof"); }
|
||||||
public void Sold(Actor self) { }
|
public void Sold(Actor self) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
var images = info.XmasImages.Any() && DateTime.Today.Month == 12 ? info.XmasImages : info.Images;
|
var images = info.XmasImages.Any() && DateTime.Today.Month == 12 ? info.XmasImages : info.Images;
|
||||||
anim = new Animation(self.World, images.Random(Game.CosmeticRandom));
|
anim = new Animation(self.World, images.Random(Game.CosmeticRandom));
|
||||||
anim.Play("idle");
|
anim.Play("idle");
|
||||||
rs.anims.Add("", anim);
|
rs.Add("", anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLanded()
|
public void OnLanded()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
anim = new Animation(self.World, rs.GetImage(self), RenderSimple.MakeFacingFunc(self));
|
anim = new Animation(self.World, rs.GetImage(self), RenderSimple.MakeFacingFunc(self));
|
||||||
anim.Play(info.Sequence);
|
anim.Play(info.Sequence);
|
||||||
rs.anims.Add("harvest_{0}".F(info.Sequence), new AnimationWithOffset(anim,
|
rs.Add("harvest_{0}".F(info.Sequence), new AnimationWithOffset(anim,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !visible,
|
() => !visible,
|
||||||
() => false,
|
() => false,
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||||
overlay = new Animation(self.World, rs.GetImage(self));
|
overlay = new Animation(self.World, rs.GetImage(self));
|
||||||
overlay.PlayRepeating(info.Sequence);
|
overlay.PlayRepeating(info.Sequence);
|
||||||
rs.anims.Add("idle_overlay_{0}".F(info.Sequence),
|
rs.Add("idle_overlay_{0}".F(info.Sequence),
|
||||||
new AnimationWithOffset(overlay,
|
new AnimationWithOffset(overlay,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !buildComplete,
|
() => !buildComplete,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||||
overlay = new Animation(self.World, rs.GetImage(self));
|
overlay = new Animation(self.World, rs.GetImage(self));
|
||||||
overlay.Play(info.Sequence);
|
overlay.Play(info.Sequence);
|
||||||
rs.anims.Add("repair_{0}".F(info.Sequence),
|
rs.Add("repair_{0}".F(info.Sequence),
|
||||||
new AnimationWithOffset(overlay,
|
new AnimationWithOffset(overlay,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !buildComplete,
|
() => !buildComplete,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Ore) / (10 * playerResources.OreCapacity)
|
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Ore) / (10 * playerResources.OreCapacity)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
rs.anims.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset(
|
rs.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset(
|
||||||
anim, null, () => !buildComplete, 1024));
|
anim, null, () => !buildComplete, 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Selling(Actor self) { rs.anims.Remove("resources_{0}".F(info.Sequence)); }
|
public void Selling(Actor self) { rs.Remove("resources_{0}".F(info.Sequence)); }
|
||||||
public void Sold(Actor self) { }
|
public void Sold(Actor self) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
rotorAnim = new Animation(self.World, rs.GetImage(self));
|
rotorAnim = new Animation(self.World, rs.GetImage(self));
|
||||||
rotorAnim.PlayRepeating(info.Sequence);
|
rotorAnim.PlayRepeating(info.Sequence);
|
||||||
rs.anims.Add(info.Id, new AnimationWithOffset(rotorAnim,
|
rs.Add(info.Id, new AnimationWithOffset(rotorAnim,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
var rs = self.Trait<RenderSprites>();
|
var rs = self.Trait<RenderSprites>();
|
||||||
|
|
||||||
anim = new Animation(self.World, "smoke_m");
|
anim = new Animation(self.World, "smoke_m");
|
||||||
rs.anims.Add("smoke", new AnimationWithOffset(anim, null, () => !isSmoking));
|
rs.Add("smoke", new AnimationWithOffset(anim, null, () => !isSmoking));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
anim = new Animation(self.World, rs.GetImage(self), () => t.turretFacing);
|
anim = new Animation(self.World, rs.GetImage(self), () => t.turretFacing);
|
||||||
anim.Play(info.Sequence);
|
anim.Play(info.Sequence);
|
||||||
rs.anims.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
rs.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
||||||
anim, () => TurretOffset(self), null, () => false, p => ZOffsetFromCenter(self, p, 1)));
|
anim, () => TurretOffset(self), null, () => false, p => ZOffsetFromCenter(self, p, 1)));
|
||||||
|
|
||||||
// Restrict turret facings to match the sprite
|
// Restrict turret facings to match the sprite
|
||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var sequence = ab.IsAttacking ? info.AimSequence : info.Sequence;
|
var sequence = ab.IsAttacking ? info.AimSequence : info.Sequence;
|
||||||
rs.anims["turret_{0}".F(info.Turret)].Animation.ReplaceAnim(sequence);
|
anim.ReplaceAnim(sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public int ZOffsetFromCenter(Actor self, WPos pos, int offset)
|
static public int ZOffsetFromCenter(Actor self, WPos pos, int offset)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
var anim = new Animation(init.world, rs.GetImage(self), () => (int)facing);
|
var anim = new Animation(init.world, rs.GetImage(self), () => (int)facing);
|
||||||
anim.PlayRepeating(info.Anim);
|
anim.PlayRepeating(info.Anim);
|
||||||
rs.anims.Add(info.Anim, new AnimationWithOffset(anim, () => pos, null));
|
rs.Add(info.Anim, new AnimationWithOffset(anim, () => pos, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
|
|||||||
Reference in New Issue
Block a user