check for missing sequence entries using lint
This commit is contained in:
@@ -27,6 +27,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
[Desc("Maximum offset at the maximum range.")]
|
||||
public readonly WRange Inaccuracy = WRange.Zero;
|
||||
public readonly string Image = null;
|
||||
[SequenceReference("Image")] public readonly string Sequence = "idle";
|
||||
public readonly string Palette = "effect";
|
||||
public readonly bool Shadow = false;
|
||||
[Desc("Trail animation.")]
|
||||
@@ -138,7 +139,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (!string.IsNullOrEmpty(info.Trail) && --smokeTicks < 0)
|
||||
{
|
||||
var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length);
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail, trailPalette)));
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, delayedPos, info.Trail, trailPalette, info.Sequence)));
|
||||
smokeTicks = info.TrailInterval;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
class MissileInfo : IProjectileInfo
|
||||
{
|
||||
public readonly string Image = null;
|
||||
[SequenceReference("Image")] public readonly string Sequence = "idle";
|
||||
public readonly string Palette = "effect";
|
||||
public readonly bool Shadow = false;
|
||||
[Desc("Projectile speed in WRange / tick")]
|
||||
@@ -171,7 +172,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
if (!string.IsNullOrEmpty(info.Trail) && --ticksToNextSmoke < 0)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, info.Trail, trailPalette)));
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, pos - 3 * move / 2, info.Trail, trailPalette, info.Sequence)));
|
||||
ticksToNextSmoke = info.TrailInterval;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (parachuteSprite != null)
|
||||
{
|
||||
parachute = new Animation(cargo.World, parachuteSprite);
|
||||
parachute.PlayThen("open", () => parachute.PlayRepeating("idle"));
|
||||
parachute.PlayThen(parachutableInfo.ParachuteOpenSequence, () => parachute.PlayRepeating(parachutableInfo.ParachuteIdleSequence));
|
||||
}
|
||||
|
||||
var shadowSprite = parachutableInfo != null ? parachutableInfo.ShadowSequence : null;
|
||||
if (shadowSprite != null)
|
||||
{
|
||||
shadow = new Animation(cargo.World, shadowSprite);
|
||||
shadow.PlayRepeating("idle");
|
||||
shadow.PlayRepeating(parachutableInfo.ParachuteIdleSequence);
|
||||
}
|
||||
|
||||
if (parachutableInfo != null)
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace OpenRA.Mods.Common.Effects
|
||||
readonly Animation anim;
|
||||
readonly string palette;
|
||||
|
||||
public Smoke(World world, WPos pos, string trail, string palette)
|
||||
public Smoke(World world, WPos pos, string trail, string palette, string sequence)
|
||||
{
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
this.palette = palette;
|
||||
|
||||
anim = new Animation(world, trail);
|
||||
anim.PlayThen("idle",
|
||||
anim.PlayThen(sequence,
|
||||
() => world.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -17,9 +19,17 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
class CheckSequences : ILintPass
|
||||
{
|
||||
Action<string> emitWarning;
|
||||
|
||||
List<MiniYamlNode> sequenceDefinitions;
|
||||
|
||||
public void Run(Action<string> emitError, Action<string> emitWarning, Map map)
|
||||
{
|
||||
var sequences = MiniYaml.MergeLiberal(map.SequenceDefinitions, Game.ModData.Manifest.Sequences.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
|
||||
this.emitWarning = emitWarning;
|
||||
|
||||
sequenceDefinitions = MiniYaml.MergeLiberal(map.SequenceDefinitions,
|
||||
Game.ModData.Manifest.Sequences.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
|
||||
|
||||
var races = map.Rules.Actors["world"].Traits.WithInterface<CountryInfo>().Select(c => c.Race);
|
||||
|
||||
foreach (var actorInfo in map.Rules.Actors)
|
||||
@@ -29,11 +39,76 @@ namespace OpenRA.Mods.Common.Lint
|
||||
foreach (var race in races)
|
||||
{
|
||||
var image = renderInfo.GetImage(actorInfo.Value, map.Rules.Sequences[map.Tileset], race);
|
||||
if (!sequences.Any(s => s.Key == image.ToLowerInvariant()) && !actorInfo.Value.Name.Contains("^"))
|
||||
if (!sequenceDefinitions.Any(s => s.Key == image.ToLowerInvariant()) && !actorInfo.Value.Name.Contains("^"))
|
||||
emitWarning("Sprite image {0} from actor {1} on tileset {2} using race {3} has no sequence definition."
|
||||
.F(image, actorInfo.Value.Name, map.Tileset, race));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var traitInfo in actorInfo.Value.Traits.WithInterface<ITraitInfo>())
|
||||
{
|
||||
var fields = traitInfo.GetType().GetFields();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (field.HasAttribute<SequenceReferenceAttribute>())
|
||||
{
|
||||
var sequences = LintExts.GetFieldValues(traitInfo, field, emitError);
|
||||
foreach (var sequence in sequences)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sequence))
|
||||
continue;
|
||||
|
||||
var renderInfo = actorInfo.Value.Traits.WithInterface<RenderSpritesInfo>().FirstOrDefault();
|
||||
if (renderInfo == null)
|
||||
continue;
|
||||
|
||||
foreach (var race in races)
|
||||
{
|
||||
var sequenceReference = field.GetCustomAttributes<SequenceReferenceAttribute>(true).FirstOrDefault();
|
||||
if (sequenceReference != null && !string.IsNullOrEmpty(sequenceReference.ImageReference))
|
||||
{
|
||||
var imageField = fields.FirstOrDefault(f => f.Name == sequenceReference.ImageReference);
|
||||
if (imageField != null)
|
||||
{
|
||||
foreach (var imageOverride in LintExts.GetFieldValues(traitInfo, imageField, emitError))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(imageOverride) && !sequenceDefinitions.Any(s => s.Key == imageOverride.ToLowerInvariant()))
|
||||
emitWarning("Custom sprite image {0} from actor {1} has no sequence definition.".F(imageOverride, actorInfo.Value.Name));
|
||||
else
|
||||
CheckDefintions(imageOverride, sequenceReference, actorInfo, sequence, race, field, traitInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var image = renderInfo.GetImage(actorInfo.Value, map.SequenceProvider, race);
|
||||
CheckDefintions(image, sequenceReference, actorInfo, sequence, race, field, traitInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckDefintions(string image, SequenceReferenceAttribute sequenceReference,
|
||||
KeyValuePair<string, ActorInfo> actorInfo, string sequence, string race, FieldInfo field, ITraitInfo traitInfo)
|
||||
{
|
||||
var definitions = sequenceDefinitions.FirstOrDefault(n => n.Key == image.ToLowerInvariant());
|
||||
if (definitions != null)
|
||||
{
|
||||
if (sequenceReference != null && sequenceReference.Prefix)
|
||||
{
|
||||
if (!definitions.Value.Nodes.Any(n => n.Key.StartsWith(sequence)))
|
||||
emitWarning("Sprite image {0} from actor {1} of faction {2} does not define sequence prefix {3} from field {4} of {5}"
|
||||
.F(image, actorInfo.Value.Name, race, sequence, field.Name, traitInfo));
|
||||
}
|
||||
else if (!definitions.Value.Nodes.Any(n => n.Key == sequence))
|
||||
{
|
||||
emitWarning("Sprite image {0} from actor {1} of faction {2} does not define sequence {3} from field {4} of {5}"
|
||||
.F(image, actorInfo.Value.Name, race, sequence, field.Name, traitInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Chance (out of 100) the unit has to enter panic mode when attacked.")]
|
||||
public readonly int AttackPanicChance = 20;
|
||||
|
||||
[SequenceReference(null, true)] public readonly string PanicSequencePrefix = "panic-";
|
||||
|
||||
public object Create(ActorInitializer init) { return new ScaredyCat(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -36,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool Panicking { get { return panicStartedTick > 0; } }
|
||||
|
||||
public bool IsModifyingSequence { get { return Panicking; } }
|
||||
public string SequencePrefix { get { return "panic-"; } }
|
||||
public string SequencePrefix { get { return info.PanicSequencePrefix; } }
|
||||
|
||||
public ScaredyCat(Actor self, ScaredyCatInfo info)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public readonly WVec ProneOffset = new WVec(85, 0, -171);
|
||||
|
||||
public readonly string ProneSequencePrefix = "prone-";
|
||||
[SequenceReference(null, true)] public readonly string ProneSequencePrefix = "prone-";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new TakeCover(init, this); }
|
||||
|
||||
|
||||
@@ -19,16 +19,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("If we land on invalid terrain for my actor type should we be killed?")]
|
||||
public readonly bool KilledOnImpassableTerrain = true;
|
||||
|
||||
[Desc("Group where Ground/WaterCorpseSequence is looked up.")]
|
||||
public readonly string CorpseSequenceCollection = "explosion";
|
||||
|
||||
public readonly string GroundImpactSound = null;
|
||||
public readonly string GroundCorpseSequence = "corpse";
|
||||
[SequenceReference("CorpseSequenceCollection")] public readonly string GroundCorpseSequence = "corpse";
|
||||
public readonly string GroundCorpsePalette = "effect";
|
||||
|
||||
public readonly string WaterImpactSound = null;
|
||||
public readonly string WaterCorpseSequence = "small_splash";
|
||||
[SequenceReference("CorpseSequenceCollection")] public readonly string WaterCorpseSequence = null;
|
||||
public readonly string WaterCorpsePalette = "effect";
|
||||
|
||||
[Desc("Requires the sub-sequences \"open\" and \"idle\".")]
|
||||
public readonly string ParachuteSequence = null;
|
||||
[SequenceReference("ParachuteSequence")] public readonly string ParachuteOpenSequence = null;
|
||||
[SequenceReference("ParachuteSequence")] public readonly string ParachuteIdleSequence = null;
|
||||
|
||||
[Desc("Optional, otherwise defaults to the palette the actor is using.")]
|
||||
public readonly string ParachutePalette = null;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class RenderBuildingChargeInfo : RenderBuildingInfo
|
||||
{
|
||||
[Desc("Sequence to use for building charge animation.")]
|
||||
public readonly string ChargeSequence = "active";
|
||||
[SequenceReference] public readonly string ChargeSequence = "active";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init, this); }
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly string[] ImagesByFullness = { "harv" };
|
||||
|
||||
public readonly string HarvestSequence = "harvest";
|
||||
[SequenceReference("ImagesByFullness")] public readonly string HarvestSequence = "harvest";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RenderHarvester(init, this); }
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Basic render trait for immobile actors. Deprecated, use RenderSprites + WithSpriteBody instead.")]
|
||||
public class RenderSimpleInfo : RenderSpritesInfo, IRenderActorPreviewSpritesInfo, IQuantizeBodyOrientationInfo, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
public readonly string Sequence = "idle";
|
||||
[SequenceReference] public readonly string Sequence = "idle";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RenderSimple(init, this); }
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public string GetImage(ActorInfo actor, SequenceProvider sequenceProvider, string race)
|
||||
{
|
||||
if (RaceImages != null)
|
||||
if (RaceImages != null && !string.IsNullOrEmpty(race))
|
||||
{
|
||||
string raceImage = null;
|
||||
if (RaceImages.TryGetValue(race, out raceImage) && sequenceProvider.HasSequence(raceImage))
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithActiveAnimationInfo : ITraitInfo, Requires<RenderBuildingInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "active";
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
|
||||
public readonly int Interval = 750;
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace OpenRA.Mods.RA.Traits
|
||||
public readonly string Armament = "primary";
|
||||
|
||||
[Desc("Displayed while attacking.")]
|
||||
public readonly string AttackSequence = null;
|
||||
[SequenceReference] public readonly string AttackSequence = null;
|
||||
|
||||
[Desc("Displayed while targeting.")]
|
||||
public readonly string AimSequence = null;
|
||||
[SequenceReference] public readonly string AimSequence = null;
|
||||
|
||||
[Desc("Shown while reloading.")]
|
||||
public readonly string ReloadPrefix = null;
|
||||
[SequenceReference(null, true)] public readonly string ReloadPrefix = null;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithAttackAnimation(init, this); }
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
class WithBarrelInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "barrel";
|
||||
[SequenceReference] public readonly string Sequence = "barrel";
|
||||
|
||||
[Desc("Armament to use for recoil")]
|
||||
public readonly string Armament = "primary";
|
||||
|
||||
@@ -18,8 +18,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Display explosions over the building footprint when it is destroyed.")]
|
||||
class WithBuildingExplosionInfo : ITraitInfo, Requires<BuildingInfo>
|
||||
{
|
||||
[Desc("Group where Sequence is looked up.")]
|
||||
public readonly string SequenceCollection = "explosion";
|
||||
|
||||
[Desc("Explosion sequence name to use")]
|
||||
public readonly string Sequence = "building";
|
||||
[SequenceReference("SequenceCollection")] public readonly string Sequence = "building";
|
||||
|
||||
[Desc("Delay the explosions by this many ticks.")]
|
||||
public readonly int Delay = 0;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithBuildingPlacedAnimationInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "build";
|
||||
[SequenceReference] public readonly string Sequence = "build";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithBuildingPlacedOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "crane-overlay";
|
||||
[SequenceReference] public readonly string Sequence = "crane-overlay";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithChargeOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "active";
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
|
||||
[Desc("Custom palette name")]
|
||||
public readonly string Palette = null;
|
||||
|
||||
@@ -23,12 +23,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Easteregg sequences to use in december.")]
|
||||
public readonly string[] XmasImages = { };
|
||||
|
||||
[SequenceReference] public readonly string IdleSequence = "idle";
|
||||
public readonly string WaterSequence = null;
|
||||
public readonly string LandSequence = null;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithCrateBody(init.Self, this); }
|
||||
|
||||
public IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
{
|
||||
var anim = new Animation(init.World, rs.Image, () => 0);
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), "idle"));
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), IdleSequence));
|
||||
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
||||
}
|
||||
|
||||
@@ -39,22 +43,27 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly Animation anim;
|
||||
readonly WithCrateBodyInfo info;
|
||||
|
||||
public WithCrateBody(Actor self, WithCrateBodyInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
this.info = info;
|
||||
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var image = rs.GetImage(self);
|
||||
var images = info.XmasImages.Any() && DateTime.Today.Month == 12 ? info.XmasImages : new[] { image };
|
||||
|
||||
anim = new Animation(self.World, images.Random(Game.CosmeticRandom));
|
||||
anim.Play("idle");
|
||||
anim.Play(info.IdleSequence);
|
||||
rs.Add(anim);
|
||||
}
|
||||
|
||||
public void OnLanded()
|
||||
{
|
||||
var seq = self.World.Map.GetTerrainInfo(self.Location).IsWater ? "water" : "land";
|
||||
anim.PlayRepeating(seq);
|
||||
var sequence = self.World.Map.GetTerrainInfo(self.Location).IsWater ? info.WaterSequence : info.LandSequence;
|
||||
if (!string.IsNullOrEmpty(sequence))
|
||||
anim.PlayRepeating(sequence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("This actor has a death animation.")]
|
||||
public class WithDeathAnimationInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Sequence to play when this actor is killed by a warhead.")]
|
||||
public readonly string DeathSequence = "die";
|
||||
[Desc("Sequence prefix to play when this actor is killed by a warhead.")]
|
||||
[SequenceReference(null, true)] public readonly string DeathSequence = "die";
|
||||
|
||||
[Desc("The palette used for `DeathSequence`.")]
|
||||
public readonly string DeathSequencePalette = "player";
|
||||
@@ -29,10 +29,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly bool DeathPaletteIsPlayerPalette = true;
|
||||
|
||||
[Desc("Should DeathType-specific sequences be used (sequence name = DeathSequence + DeathType).")]
|
||||
public readonly bool UseDeathTypeSuffix = true;
|
||||
public readonly bool UseDeathTypeSuffix = true; // TODO: check the complete sequence with lint rules
|
||||
|
||||
[Desc("Sequence to play when this actor is crushed.")]
|
||||
public readonly string CrushedSequence = "die-crushed";
|
||||
[SequenceReference] public readonly string CrushedSequence = null;
|
||||
|
||||
[Desc("The palette used for `CrushedSequence`.")]
|
||||
public readonly string CrushedSequencePalette = "effect";
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithDockingOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "docking-overlay";
|
||||
[SequenceReference] public readonly string Sequence = "docking-overlay";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
class WithHarvestAnimationInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "harvest";
|
||||
[SequenceReference] public readonly string Sequence = "harvest";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithIdleOverlayInfo : UpgradableTraitInfo, ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "idle-overlay";
|
||||
[SequenceReference] public readonly string Sequence = "idle-overlay";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -21,10 +21,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly int MinIdleWaitTicks = 30;
|
||||
public readonly int MaxIdleWaitTicks = 110;
|
||||
public readonly string MoveSequence = "run";
|
||||
public readonly string AttackSequence = "shoot";
|
||||
public readonly string[] IdleSequences = { };
|
||||
public readonly string[] StandSequences = { "stand" };
|
||||
|
||||
[SequenceReference] public readonly string MoveSequence = "run";
|
||||
[SequenceReference] public readonly string AttackSequence = null;
|
||||
[SequenceReference] public readonly string[] IdleSequences = { };
|
||||
[SequenceReference] public readonly string[] StandSequences = { "stand" };
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new WithInfantryBody(init, this); }
|
||||
|
||||
@@ -93,9 +94,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Attacking(Actor self, Target target)
|
||||
{
|
||||
state = AnimationState.Attacking;
|
||||
if (DefaultAnimation.HasSequence(NormalizeInfantrySequence(self, Info.AttackSequence)))
|
||||
if (!string.IsNullOrEmpty(Info.AttackSequence) && DefaultAnimation.HasSequence(NormalizeInfantrySequence(self, Info.AttackSequence)))
|
||||
{
|
||||
state = AnimationState.Attacking;
|
||||
DefaultAnimation.PlayThen(NormalizeInfantrySequence(self, Info.AttackSequence), () => state = AnimationState.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithMakeAnimationInfo : ITraitInfo, Requires<BuildingInfo>, Requires<RenderBuildingInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "make";
|
||||
[SequenceReference] public readonly string Sequence = "make";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithMakeAnimation(init, this); }
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithMoveAnimationInfo : ITraitInfo, Requires<WithFacingSpriteBodyInfo>, Requires<IMoveInfo>
|
||||
{
|
||||
[Desc("Displayed while moving.")]
|
||||
public readonly string MoveSequence = "move";
|
||||
[SequenceReference] public readonly string MoveSequence = "move";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithMoveAnimation(init, this); }
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithProductionOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "production-overlay";
|
||||
[SequenceReference] public readonly string Sequence = "production-overlay";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithRepairAnimationInfo : ITraitInfo, Requires<RenderBuildingInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "active";
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
|
||||
public readonly bool PauseOnLowPower = false;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithRepairOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "active";
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
class WithResourcesInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "resources";
|
||||
[SequenceReference] public readonly string Sequence = "resources";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithResources(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class WithRotorInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use when flying")]
|
||||
public readonly string Sequence = "rotor";
|
||||
[SequenceReference] public readonly string Sequence = "rotor";
|
||||
|
||||
[Desc("Sequence name to use when landed")]
|
||||
public readonly string GroundSequence = "slow-rotor";
|
||||
[SequenceReference] public readonly string GroundSequence = "slow-rotor";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
@@ -16,19 +16,26 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Renders an overlay when the actor is taking heavy damage.")]
|
||||
public class WithSmokeInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Needs to define \"idle\", \"loop\" and \"end\" sub-sequences.")]
|
||||
public readonly string Sequence = "smoke_m";
|
||||
|
||||
[SequenceReference("Sequence")] public readonly string IdleSequence = "idle";
|
||||
[SequenceReference("Sequence")] public readonly string LoopSequence = "loop";
|
||||
[SequenceReference("Sequence")] public readonly string EndSequence = "end";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithSmoke(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithSmoke : INotifyDamage
|
||||
{
|
||||
readonly WithSmokeInfo info;
|
||||
readonly Animation anim;
|
||||
|
||||
bool isSmoking;
|
||||
Animation anim;
|
||||
|
||||
public WithSmoke(Actor self, WithSmokeInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
|
||||
anim = new Animation(self.World, info.Sequence);
|
||||
@@ -42,9 +49,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (e.DamageState < DamageState.Heavy) return;
|
||||
|
||||
isSmoking = true;
|
||||
anim.PlayThen("idle",
|
||||
() => anim.PlayThen("loop",
|
||||
() => anim.PlayBackwardsThen("end",
|
||||
anim.PlayThen(info.IdleSequence,
|
||||
() => anim.PlayThen(info.LoopSequence,
|
||||
() => anim.PlayBackwardsThen(info.EndSequence,
|
||||
() => isSmoking = false)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Animation to play when the actor is created.")]
|
||||
public readonly string StartSequence = null;
|
||||
[SequenceReference] public readonly string StartSequence = null;
|
||||
|
||||
[Desc("Animation to play when the actor is idle.")]
|
||||
public readonly string Sequence = "idle";
|
||||
[SequenceReference] public readonly string Sequence = "idle";
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new WithSpriteBody(init, this); }
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Requires<RenderSpritesInfo>, Requires<TurretedInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "turret";
|
||||
[SequenceReference] public readonly string Sequence = "turret";
|
||||
|
||||
[Desc("Sequence name to use when prepared to fire")]
|
||||
public readonly string AimSequence = null;
|
||||
[SequenceReference] public readonly string AimSequence = null;
|
||||
|
||||
[Desc("Turreted 'Turret' key to display")]
|
||||
public readonly string Turret = "primary";
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
public readonly int Interval = 3;
|
||||
public readonly string Sprite = "smokey";
|
||||
[SequenceReference("Sprite")] public readonly string Sequence = "idle";
|
||||
public readonly string Palette = "effect";
|
||||
public readonly DamageState MinDamage = DamageState.Heavy;
|
||||
|
||||
@@ -46,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
|
||||
var pos = position + body.LocalToWorld(offset);
|
||||
self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, info.Sprite, info.Palette)));
|
||||
self.World.AddFrameEndTask(w => w.Add(new Smoke(w, pos, info.Sprite, info.Palette, info.Sequence)));
|
||||
}
|
||||
|
||||
ticks = info.Interval;
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Sprite sequence name")]
|
||||
public readonly string SmokeType = "smoke_m";
|
||||
[SequenceReference("SmokeType")] public readonly string SmokeSequence = "idle";
|
||||
|
||||
public readonly string SmokePalette = "effect";
|
||||
|
||||
@@ -99,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void AddSmudge(CPos loc)
|
||||
{
|
||||
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, world.Map.CenterOfCell(loc), Info.SmokeType, Info.SmokePalette)));
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, world.Map.CenterOfCell(loc), Info.SmokeType, Info.SmokePalette, Info.SmokeSequence)));
|
||||
|
||||
if (!dirty.ContainsKey(loc) && !tiles.ContainsKey(loc))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user