Remove CrateEffect in favor of using updated SpriteEffect
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Mods.Common.Effects
|
||||
{
|
||||
public class CrateEffect : IEffect, ISpatiallyPartitionable
|
||||
{
|
||||
readonly string palette;
|
||||
readonly Actor a;
|
||||
readonly Animation anim;
|
||||
|
||||
public CrateEffect(Actor a, string seq, string palette)
|
||||
{
|
||||
this.a = a;
|
||||
this.palette = palette;
|
||||
|
||||
anim = new Animation(a.World, "crate-effects");
|
||||
anim.PlayThen(seq, () => a.World.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); }));
|
||||
a.World.ScreenMap.Add(this, a.CenterPosition, anim.Image);
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
anim.Tick();
|
||||
world.ScreenMap.Update(this, a.CenterPosition, anim.Image);
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||
{
|
||||
if (!a.IsInWorld || a.World.FogObscures(a.CenterPosition))
|
||||
return SpriteRenderable.None;
|
||||
|
||||
return anim.Render(a.CenterPosition, wr.Palette(palette));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,6 @@
|
||||
<Compile Include="AudioLoaders\WavLoader.cs" />
|
||||
<Compile Include="Effects\Beacon.cs" />
|
||||
<Compile Include="Effects\ContrailFader.cs" />
|
||||
<Compile Include="Effects\CrateEffect.cs" />
|
||||
<Compile Include="Effects\RevealShroudEffect.cs" />
|
||||
<Compile Include="Effects\FlashTarget.cs" />
|
||||
<Compile Include="Effects\FloatingText.cs" />
|
||||
@@ -942,6 +941,7 @@
|
||||
<Compile Include="UpdateRules\Rules\20180923\AddRearmable.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20180923\MergeAttackPlaneAndHeli.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20180923\ExtractHackyAIModules.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20180923\DefineLevelUpImageDefault.cs" />
|
||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||
<Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" />
|
||||
<Compile Include="Traits\Render\WithBuildingRepairDecoration.cs" />
|
||||
|
||||
@@ -20,8 +20,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Chance of getting this crate, assuming the collector is compatible.")]
|
||||
public readonly int SelectionShares = 10;
|
||||
|
||||
[Desc("An animation defined in sequence yaml(s) to draw.")]
|
||||
public readonly string Effect = null;
|
||||
[Desc("Image containing the crate effect animation sequence.")]
|
||||
public readonly string Image = "crate-effects";
|
||||
|
||||
[Desc("Animation sequence played when collected. Leave empty for no effect.")]
|
||||
[SequenceReference("Image")] public readonly string Sequence = null;
|
||||
|
||||
[Desc("Palette to draw the animation in.")]
|
||||
[PaletteReference] public readonly string Palette = "effect";
|
||||
@@ -84,8 +87,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, collector.Owner, "Speech",
|
||||
Info.Notification, collector.Owner.Faction.InternalName);
|
||||
|
||||
if (Info.Effect != null)
|
||||
collector.World.AddFrameEndTask(w => w.Add(new CrateEffect(collector, Info.Effect, Info.Palette)));
|
||||
if (Info.Image != null && Info.Sequence != null)
|
||||
collector.World.AddFrameEndTask(w => w.Add(new SpriteEffect(collector, w, Info.Image, Info.Sequence, Info.Palette)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[GrantedConditionReference]
|
||||
public IEnumerable<string> LinterConditions { get { return Conditions.Values; } }
|
||||
|
||||
[Desc("Image for the level up sprite.")]
|
||||
public readonly string LevelUpImage = null;
|
||||
|
||||
[Desc("Sequence for the level up sprite. Needs to be present on Image.")]
|
||||
[SequenceReference("Image")] public readonly string LevelUpSequence = "levelup";
|
||||
|
||||
[Desc("Palette for the level up sprite.")]
|
||||
[PaletteReference] public readonly string LevelUpPalette = "effect";
|
||||
|
||||
@@ -107,7 +113,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!silent)
|
||||
{
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", info.LevelUpNotification, self.Owner.Faction.InternalName);
|
||||
self.World.AddFrameEndTask(w => w.Add(new CrateEffect(self, "levelup", info.LevelUpPalette)));
|
||||
if (info.LevelUpImage != null && info.LevelUpSequence != null)
|
||||
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(self, w, info.LevelUpImage, info.LevelUpSequence, info.LevelUpPalette)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class DefineLevelUpImageDefault : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "Unhardcoded LevelUpImage and LevelUpSequence on GainsExperience"; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "GainsExperience was hardcoded to play a 'levelup' crate effect from 'crate-effects' image.";
|
||||
}
|
||||
}
|
||||
|
||||
static readonly string[] CrateActionTraits =
|
||||
{
|
||||
"DuplicateUnitCrateAction",
|
||||
"ExplodeCrateAction",
|
||||
"GiveCashCrateAction",
|
||||
"GiveMcvCrateAction",
|
||||
"GiveUnitCrateAction",
|
||||
"GrantExternalConditionCrateAction",
|
||||
"HealUnitsCrateAction",
|
||||
"HideMapCrateAction",
|
||||
"LevelUpCrateAction",
|
||||
"RevealMapCrateAction",
|
||||
"SupportPowerCrateAction"
|
||||
};
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
var levelUpImageNode = new MiniYamlNode("LevelUpImage", "crate-effects");
|
||||
foreach (var ge in actorNode.ChildrenMatching("GainsExperience"))
|
||||
ge.AddNode(levelUpImageNode);
|
||||
|
||||
foreach (var t in CrateActionTraits)
|
||||
{
|
||||
foreach (var ca in actorNode.ChildrenMatching(t))
|
||||
{
|
||||
var effect = ca.LastChildMatching("Effect");
|
||||
if (effect != null)
|
||||
effect.RenameKey("Sequence");
|
||||
}
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
new ExtractHackyAIModules(),
|
||||
new RemoveNegativeDamageFullHealthCheck(),
|
||||
new RemoveResourceExplodeModifier(),
|
||||
new DefineLevelUpImageDefault(),
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user