Refactor SpiceBloom
- Remove SpiceBloom.RespawnDelay It is basically redundant (giving the spice bloom spawner a longer self-kill delay at yaml level has the same effect) and uses the savegame-blocking DelayedAction, so just removing it is the cleanest solution. - Rename SpiceBloom GrowthDelay to Lifetime - Refactor spicebloom.spawnpoint to not use SpiceBloom trait and make it visible in editor with corresponding tooltip.
This commit is contained in:
@@ -781,6 +781,26 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (node.Key.StartsWith("UpgradeOverlay", StringComparison.Ordinal))
|
||||
RenameNodeKey(node, "WithColoredOverlay" + node.Key.Substring(14));
|
||||
|
||||
// Remove SpiceBloom.RespawnDelay to get rid of DelayedAction, and rename GrowthDelay to Lifetime
|
||||
if (engineVersion < 20170203)
|
||||
{
|
||||
var spiceBloom = node.Value.Nodes.FirstOrDefault(n => n.Key == "SpiceBloom");
|
||||
if (spiceBloom != null)
|
||||
{
|
||||
var respawnDelay = spiceBloom.Value.Nodes.FirstOrDefault(n => n.Key == "RespawnDelay");
|
||||
if (respawnDelay != null)
|
||||
{
|
||||
spiceBloom.Value.Nodes.Remove(respawnDelay);
|
||||
Console.WriteLine("RespawnDelay has been removed from SpiceBloom for technical reasons.");
|
||||
Console.WriteLine("Increase self-kill delay of the spice bloom spawnpoint actor instead.");
|
||||
}
|
||||
|
||||
var growthDelay = spiceBloom.Value.Nodes.FirstOrDefault(n => n.Key == "GrowthDelay");
|
||||
if (growthDelay != null)
|
||||
growthDelay.Key = "Lifetime";
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,8 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
[SequenceReference]
|
||||
public readonly string[] GrowthSequences = { "grow1", "grow2", "grow3" };
|
||||
|
||||
[Desc("The range of time (in ticks) that the spicebloom will take to respawn.")]
|
||||
public readonly int[] RespawnDelay = { 1500, 2500 };
|
||||
|
||||
[Desc("The range of time (in ticks) that the spicebloom will take to grow.")]
|
||||
public readonly int[] GrowthDelay = { 1000, 3000 };
|
||||
[Desc("The range of time (in ticks) that the spicebloom will take to grow until it blows up.")]
|
||||
public readonly int[] Lifetime = { 1000, 3000 };
|
||||
|
||||
public readonly string ResourceType = "Spice";
|
||||
|
||||
@@ -72,7 +69,6 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
readonly ResourceLayer resLayer;
|
||||
readonly AnimationWithOffset anim;
|
||||
|
||||
readonly int respawnTicks;
|
||||
readonly int growTicks;
|
||||
int ticks;
|
||||
|
||||
@@ -88,8 +84,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead);
|
||||
render.Add(anim);
|
||||
|
||||
respawnTicks = self.World.SharedRandom.Next(info.RespawnDelay[0], info.RespawnDelay[1]);
|
||||
growTicks = self.World.SharedRandom.Next(info.GrowthDelay[0], info.GrowthDelay[1]);
|
||||
growTicks = self.World.SharedRandom.Next(info.Lifetime[0], info.Lifetime[1]);
|
||||
anim.Animation.Play(info.GrowthSequences[0]);
|
||||
}
|
||||
|
||||
@@ -163,19 +158,17 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
if (!string.IsNullOrEmpty(info.Weapon))
|
||||
SeedResources(self);
|
||||
|
||||
self.World.AddFrameEndTask(t => t.Add(new DelayedAction(respawnTicks, () =>
|
||||
var td = new TypeDictionary
|
||||
{
|
||||
var td = new TypeDictionary
|
||||
{
|
||||
new ParentActorInit(self),
|
||||
new LocationInit(self.Location),
|
||||
new CenterPositionInit(self.CenterPosition),
|
||||
new OwnerInit(self.Owner),
|
||||
new FactionInit(self.Owner.Faction.InternalName),
|
||||
new SkipMakeAnimsInit()
|
||||
};
|
||||
self.World.CreateActor(info.SpawnActor, td);
|
||||
})));
|
||||
new ParentActorInit(self),
|
||||
new LocationInit(self.Location),
|
||||
new CenterPositionInit(self.CenterPosition),
|
||||
new OwnerInit(self.Owner),
|
||||
new FactionInit(self.Owner.Faction.InternalName),
|
||||
new SkipMakeAnimsInit()
|
||||
};
|
||||
|
||||
self.World.AddFrameEndTask(w => w.CreateActor(info.SpawnActor, td));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
spicebloom.spawnpoint:
|
||||
HiddenUnderShroud:
|
||||
Type: CenterPosition
|
||||
EditorOnlyTooltip:
|
||||
Name: Spice Bloom spawnpoint
|
||||
AlwaysVisible:
|
||||
RenderSpritesEditorOnly:
|
||||
Image: spicebloom
|
||||
WithSpriteBody:
|
||||
Sequence: grow1
|
||||
BodyOrientation:
|
||||
QuantizedFacings: 1
|
||||
RenderSprites:
|
||||
Image: spicebloom
|
||||
SpiceBloom:
|
||||
GrowthTerrainTypes: SpiceSand
|
||||
SpawnActor: spicebloom
|
||||
GrowthSequences: grow0
|
||||
GrowthDelay: 250, 750
|
||||
RespawnDelay: 1, 2
|
||||
ConditionManager:
|
||||
GrantConditionOnTerrain:
|
||||
Condition: clearsand
|
||||
TerrainTypes: SpiceSand
|
||||
KillsSelf:
|
||||
RequiresCondition: clearsand
|
||||
Delay: 1750, 3250
|
||||
SpawnActorOnDeath:
|
||||
Actor: spicebloom
|
||||
Explodes:
|
||||
Weapon: BloomSpawn
|
||||
EmptyWeapon: BloomSpawn
|
||||
|
||||
Reference in New Issue
Block a user