Clean up property names + defaults of smudge smoke
This commit is contained in:
@@ -32,13 +32,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Sprite sequence name")]
|
[Desc("Sprite sequence name")]
|
||||||
public readonly string Sequence = "scorch";
|
public readonly string Sequence = "scorch";
|
||||||
|
|
||||||
public readonly int SmokePercentage = 25;
|
[Desc("Chance of smoke rising from the ground")]
|
||||||
|
public readonly int SmokeChance = 0;
|
||||||
|
|
||||||
[Desc("Sprite sequence name")]
|
[Desc("Smoke sprite image name")]
|
||||||
public readonly string SmokeType = "smoke_m";
|
public readonly string SmokeImage = null;
|
||||||
|
|
||||||
[SequenceReference(nameof(SmokeType))]
|
[SequenceReference(nameof(SmokeImage))]
|
||||||
public readonly string SmokeSequence = "idle";
|
[Desc("Smoke sprite sequences randomly chosen from")]
|
||||||
|
public readonly string[] SmokeSequences = { };
|
||||||
|
|
||||||
[PaletteReference]
|
[PaletteReference]
|
||||||
public readonly string SmokePalette = "effect";
|
public readonly string SmokePalette = "effect";
|
||||||
@@ -89,6 +91,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
readonly Dictionary<CPos, Smudge> dirty = new Dictionary<CPos, Smudge>();
|
readonly Dictionary<CPos, Smudge> dirty = new Dictionary<CPos, Smudge>();
|
||||||
readonly Dictionary<string, ISpriteSequence> smudges = new Dictionary<string, ISpriteSequence>();
|
readonly Dictionary<string, ISpriteSequence> smudges = new Dictionary<string, ISpriteSequence>();
|
||||||
readonly World world;
|
readonly World world;
|
||||||
|
readonly bool hasSmoke;
|
||||||
|
|
||||||
TerrainSpriteLayer render;
|
TerrainSpriteLayer render;
|
||||||
bool disposed;
|
bool disposed;
|
||||||
@@ -97,6 +100,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
world = self.World;
|
world = self.World;
|
||||||
|
hasSmoke = !string.IsNullOrEmpty(info.SmokeImage) && info.SmokeSequences.Any();
|
||||||
|
|
||||||
var sequenceProvider = world.Map.Rules.Sequences;
|
var sequenceProvider = world.Map.Rules.Sequences;
|
||||||
var types = sequenceProvider.Sequences(Info.Sequence);
|
var types = sequenceProvider.Sequences(Info.Sequence);
|
||||||
@@ -144,8 +148,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!world.Map.Contains(loc))
|
if (!world.Map.Contains(loc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
|
if (hasSmoke && Game.CosmeticRandom.Next(0, 100) <= Info.SmokeChance)
|
||||||
world.AddFrameEndTask(w => w.Add(new SpriteEffect(world.Map.CenterOfCell(loc), w, Info.SmokeType, Info.SmokeSequence, Info.SmokePalette)));
|
world.AddFrameEndTask(w => w.Add(new SpriteEffect(
|
||||||
|
w.Map.CenterOfCell(loc), w, Info.SmokeImage, Info.SmokeSequences.Random(w.SharedRandom), Info.SmokePalette)));
|
||||||
|
|
||||||
// A null Sequence indicates a deleted smudge.
|
// A null Sequence indicates a deleted smudge.
|
||||||
if ((!dirty.ContainsKey(loc) || dirty[loc].Sequence == null) && !tiles.ContainsKey(loc))
|
if ((!dirty.ContainsKey(loc) || dirty[loc].Sequence == null) && !tiles.ContainsKey(loc))
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2020 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 RenameSmudgeSmokeFields : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "Renamed smoke-related properties on SmudgeLayer."; } }
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Renamed smoke-related properties on SmudgeLayer to be in line with comparable properties.\n" +
|
||||||
|
"Additionally, set the *Chance, *Image and *Sequences defaults to null.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
foreach (var layer in actorNode.ChildrenMatching("SmudgeLayer"))
|
||||||
|
{
|
||||||
|
var chance = layer.LastChildMatching("SmokePercentage");
|
||||||
|
if (chance != null)
|
||||||
|
chance.RenameKey("SmokeChance");
|
||||||
|
else
|
||||||
|
layer.AddNode("SmokeChance", FieldSaver.FormatValue("25"));
|
||||||
|
|
||||||
|
var image = layer.LastChildMatching("SmokeType");
|
||||||
|
if (image != null)
|
||||||
|
image.RenameKey("SmokeImage");
|
||||||
|
else
|
||||||
|
layer.AddNode("SmokeImage", FieldSaver.FormatValue("smoke_m"));
|
||||||
|
|
||||||
|
var sequences = layer.LastChildMatching("SmokeSequence");
|
||||||
|
if (sequences != null)
|
||||||
|
sequences.RenameKey("SmokeSequences");
|
||||||
|
else
|
||||||
|
layer.AddNode("SmokeSequences", FieldSaver.FormatValue("idle"));
|
||||||
|
}
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,6 +74,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new ReplaceBurns(),
|
new ReplaceBurns(),
|
||||||
new RemoveMuzzleSplitFacings(),
|
new RemoveMuzzleSplitFacings(),
|
||||||
new RemoveTurnToDock(),
|
new RemoveTurnToDock(),
|
||||||
|
new RenameSmudgeSmokeFields(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1038,7 +1038,7 @@ ATWR:
|
|||||||
-RenderRangeCircle:
|
-RenderRangeCircle:
|
||||||
WithRangeCircle:
|
WithRangeCircle:
|
||||||
Range: 7c0
|
Range: 7c0
|
||||||
Color: FFFF0080
|
Color: FFFF0080
|
||||||
WithBuildingBib:
|
WithBuildingBib:
|
||||||
HasMinibib: true
|
HasMinibib: true
|
||||||
Turreted:
|
Turreted:
|
||||||
|
|||||||
@@ -179,10 +179,15 @@ World:
|
|||||||
SmudgeLayer@SCORCH:
|
SmudgeLayer@SCORCH:
|
||||||
Type: Scorch
|
Type: Scorch
|
||||||
Sequence: scorches
|
Sequence: scorches
|
||||||
SmokePercentage: 50
|
SmokeChance: 50
|
||||||
|
SmokeImage: smoke_m
|
||||||
|
SmokeSequences: idle
|
||||||
SmudgeLayer@CRATER:
|
SmudgeLayer@CRATER:
|
||||||
Type: Crater
|
Type: Crater
|
||||||
Sequence: craters
|
Sequence: craters
|
||||||
|
SmokeChance: 25
|
||||||
|
SmokeImage: smoke_m
|
||||||
|
SmokeSequences: idle
|
||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
WarheadDebugOverlay:
|
WarheadDebugOverlay:
|
||||||
|
|||||||
@@ -151,11 +151,9 @@ World:
|
|||||||
SmudgeLayer@Rock:
|
SmudgeLayer@Rock:
|
||||||
Type: RockCrater
|
Type: RockCrater
|
||||||
Sequence: rockcraters
|
Sequence: rockcraters
|
||||||
SmokePercentage: 0
|
|
||||||
SmudgeLayer@Sand:
|
SmudgeLayer@Sand:
|
||||||
Type: SandCrater
|
Type: SandCrater
|
||||||
Sequence: sandcraters
|
Sequence: sandcraters
|
||||||
SmokePercentage: 0
|
|
||||||
MapCreeps:
|
MapCreeps:
|
||||||
CheckboxLabel: Worms
|
CheckboxLabel: Worms
|
||||||
CheckboxDescription: Worms roam the map and devour unprepared forces
|
CheckboxDescription: Worms roam the map and devour unprepared forces
|
||||||
|
|||||||
@@ -200,10 +200,15 @@ World:
|
|||||||
SmudgeLayer@SCORCH:
|
SmudgeLayer@SCORCH:
|
||||||
Type: Scorch
|
Type: Scorch
|
||||||
Sequence: scorches
|
Sequence: scorches
|
||||||
SmokePercentage: 50
|
SmokeChance: 50
|
||||||
|
SmokeImage: smoke_m
|
||||||
|
SmokeSequences: idle
|
||||||
SmudgeLayer@CRATER:
|
SmudgeLayer@CRATER:
|
||||||
Type: Crater
|
Type: Crater
|
||||||
Sequence: craters
|
Sequence: craters
|
||||||
|
SmokeChance: 25
|
||||||
|
SmokeImage: smoke_m
|
||||||
|
SmokeSequences: idle
|
||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
WarheadDebugOverlay:
|
WarheadDebugOverlay:
|
||||||
|
|||||||
@@ -254,29 +254,29 @@ World:
|
|||||||
SmudgeLayer@SMALLSCORCH:
|
SmudgeLayer@SMALLSCORCH:
|
||||||
Type: SmallScorch
|
Type: SmallScorch
|
||||||
Sequence: smallscorches
|
Sequence: smallscorches
|
||||||
SmokeType: smallfire
|
SmokeImage: smallfire
|
||||||
SmokePercentage: 50
|
SmokeSequences: idle
|
||||||
|
SmokeChance: 50
|
||||||
SmudgeLayer@MEDIUMSCORCH:
|
SmudgeLayer@MEDIUMSCORCH:
|
||||||
Type: MediumScorch
|
Type: MediumScorch
|
||||||
Sequence: mediumscorches
|
Sequence: mediumscorches
|
||||||
SmokeType: mediumfire
|
SmokeImage: mediumfire
|
||||||
SmokePercentage: 75
|
SmokeSequences: idle
|
||||||
|
SmokeChance: 75
|
||||||
SmudgeLayer@LARGESCORCH:
|
SmudgeLayer@LARGESCORCH:
|
||||||
Type: LargeScorch
|
Type: LargeScorch
|
||||||
Sequence: largescorches
|
Sequence: largescorches
|
||||||
SmokeType: largefire
|
SmokeImage: largefire
|
||||||
SmokePercentage: 100
|
SmokeSequences: idle
|
||||||
|
SmokeChance: 100
|
||||||
SmudgeLayer@SMALLCRATER:
|
SmudgeLayer@SMALLCRATER:
|
||||||
Type: SmallCrater
|
Type: SmallCrater
|
||||||
SmokeType: smallsmoke
|
|
||||||
Sequence: smallcraters
|
Sequence: smallcraters
|
||||||
SmudgeLayer@MEDIUMCRATER:
|
SmudgeLayer@MEDIUMCRATER:
|
||||||
Type: MediumCrater
|
Type: MediumCrater
|
||||||
SmokeType: smallsmoke
|
|
||||||
Sequence: mediumcraters
|
Sequence: mediumcraters
|
||||||
SmudgeLayer@LARGECRATER:
|
SmudgeLayer@LARGECRATER:
|
||||||
Type: LargeCrater
|
Type: LargeCrater
|
||||||
SmokeType: largesmoke
|
|
||||||
Sequence: largecraters
|
Sequence: largecraters
|
||||||
ResourceLayer:
|
ResourceLayer:
|
||||||
BridgeLayer:
|
BridgeLayer:
|
||||||
|
|||||||
Reference in New Issue
Block a user