Add wrappers for RenderSprites anims dictionary.

This commit is contained in:
Paul Chote
2014-05-22 22:05:11 +12:00
parent 475aa93271
commit 4aa7376994
21 changed files with 36 additions and 26 deletions

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Render
// Additional 512 units move from center -> top of cell
var offset = FootprintUtils.CenterOffset(bi).Y + 512;
anims.Add("roof", new AnimationWithOffset(roof, null,
Add("roof", new AnimationWithOffset(roof, null,
() => !buildComplete, offset));
}
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.RA.Render
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) { }
}
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Render
var images = info.XmasImages.Any() && DateTime.Today.Month == 12 ? info.XmasImages : info.Images;
anim = new Animation(self.World, images.Random(Game.CosmeticRandom));
anim.Play("idle");
rs.anims.Add("", anim);
rs.Add("", anim);
}
public void OnLanded()

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Render
anim = new Animation(self.World, rs.GetImage(self), RenderSimple.MakeFacingFunc(self));
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))),
() => !visible,
() => false,

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Render
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
overlay = new Animation(self.World, rs.GetImage(self));
overlay.PlayRepeating(info.Sequence);
rs.anims.Add("idle_overlay_{0}".F(info.Sequence),
rs.Add("idle_overlay_{0}".F(info.Sequence),
new AnimationWithOffset(overlay,
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
() => !buildComplete,

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Render
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
overlay = new Animation(self.World, rs.GetImage(self));
overlay.Play(info.Sequence);
rs.anims.Add("repair_{0}".F(info.Sequence),
rs.Add("repair_{0}".F(info.Sequence),
new AnimationWithOffset(overlay,
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
() => !buildComplete,

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Render
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Ore) / (10 * playerResources.OreCapacity)
: 0);
rs.anims.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset(
rs.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset(
anim, null, () => !buildComplete, 1024));
}
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Render
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) { }
}
}

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Render
rotorAnim = new Animation(self.World, rs.GetImage(self));
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))),
null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
}

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Render
var rs = self.Trait<RenderSprites>();
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)

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Render
anim = new Animation(self.World, rs.GetImage(self), () => t.turretFacing);
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)));
// Restrict turret facings to match the sprite
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA.Render
return;
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)