Change Crate.Lifetime from 'seconds' to ticks
As far as I could tell, this was the last place that still used 'seconds' instead of ticks, apart from some sound notification intervals (which are better converted to real [milli]seconds). Also renamed ScaredyCat.PanicLength to PanicDuration for consistency and easier finding.
This commit is contained in:
@@ -20,9 +20,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
public class CrateInfo : TraitInfo, IPositionableInfo, Requires<RenderSpritesInfo>
|
public class CrateInfo : TraitInfo, IPositionableInfo, Requires<RenderSpritesInfo>
|
||||||
{
|
{
|
||||||
[Desc("Length of time (in seconds) until the crate gets removed automatically. " +
|
[Desc("Length of time (in ticks) until the crate gets removed automatically. " +
|
||||||
"A value of zero disables auto-removal.")]
|
"A value of zero disables auto-removal.")]
|
||||||
public readonly int Lifetime = 0;
|
public readonly int Duration = 0;
|
||||||
|
|
||||||
[Desc("Allowed to land on.")]
|
[Desc("Allowed to land on.")]
|
||||||
public readonly HashSet<string> TerrainTypes = new HashSet<string>();
|
public readonly HashSet<string> TerrainTypes = new HashSet<string>();
|
||||||
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (info.Lifetime != 0 && self.IsInWorld && ++ticks >= info.Lifetime * 25)
|
if (info.Duration != 0 && self.IsInWorld && ++ticks >= info.Duration)
|
||||||
self.Dispose();
|
self.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.World.ActorMap.AddInfluence(self, this);
|
self.World.ActorMap.AddInfluence(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return self.Location == location && ticks + 1 == info.Lifetime * 25; }
|
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return self.Location == location && ticks + 1 == info.Duration; }
|
||||||
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
|
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
|
||||||
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
|
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly int PanicChance = 100;
|
public readonly int PanicChance = 100;
|
||||||
|
|
||||||
[Desc("How long (in ticks) the actor should panic for.")]
|
[Desc("How long (in ticks) the actor should panic for.")]
|
||||||
public readonly int PanicLength = 250;
|
public readonly int PanicDuration = 250;
|
||||||
|
|
||||||
[Desc("Panic movement speed as a percentage of the normal speed.")]
|
[Desc("Panic movement speed as a percentage of the normal speed.")]
|
||||||
public readonly int PanicSpeedModifier = 200;
|
public readonly int PanicSpeedModifier = 200;
|
||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!Panicking)
|
if (!Panicking)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (self.World.WorldTick >= panicStartedTick + info.PanicLength)
|
if (self.World.WorldTick >= panicStartedTick + info.PanicDuration)
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
panicStartedTick = 0;
|
panicStartedTick = 0;
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2021 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 ReplaceCrateSecondsWithTicks : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name => "Changed Crate Lifetime to Duration and use ticks and renamed PanicLength to PanicDuration.";
|
||||||
|
|
||||||
|
public override string Description =>
|
||||||
|
"Crate.Lifetime was the last non-sound-related place to still use 'seconds'\n" +
|
||||||
|
"by multiplying with 25 internally. Converted to use ticks like everything else.\n" +
|
||||||
|
"Also renamed Lifetime to Duration and ScaredyCat.PanicLength to PanicDuration to match other places.";
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
foreach (var crateNode in actorNode.ChildrenMatching("Crate"))
|
||||||
|
{
|
||||||
|
foreach (var lifetimeNode in crateNode.ChildrenMatching("Lifetime"))
|
||||||
|
{
|
||||||
|
var lifetime = lifetimeNode.NodeValue<int>();
|
||||||
|
lifetimeNode.Value.Value = FieldSaver.FormatValue(lifetime * 25);
|
||||||
|
lifetimeNode.RenameKey("Duration");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var scNode in actorNode.ChildrenMatching("ScaredyCat"))
|
||||||
|
{
|
||||||
|
scNode.RenameChildrenMatching("PanicLength", "PanicDuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,6 +94,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new RemoveResourceType(),
|
new RemoveResourceType(),
|
||||||
new ConvertBoundsToWDist(),
|
new ConvertBoundsToWDist(),
|
||||||
new RemoveSmokeTrailWhenDamaged(),
|
new RemoveSmokeTrailWhenDamaged(),
|
||||||
|
new ReplaceCrateSecondsWithTicks(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ CRATE.plain:
|
|||||||
CRATE:
|
CRATE:
|
||||||
Inherits: ^Crate
|
Inherits: ^Crate
|
||||||
Crate:
|
Crate:
|
||||||
Lifetime: 240
|
Duration: 6000
|
||||||
GiveCashCrateAction:
|
GiveCashCrateAction:
|
||||||
Amount: 1000
|
Amount: 1000
|
||||||
SelectionShares: 20
|
SelectionShares: 20
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ crate:
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Crate
|
Name: Crate
|
||||||
Crate:
|
Crate:
|
||||||
Lifetime: 120
|
Duration: 3000
|
||||||
TerrainTypes: Sand, Rock, Transition, Spice, SpiceSand, Dune, Concrete
|
TerrainTypes: Sand, Rock, Transition, Spice, SpiceSand, Dune, Concrete
|
||||||
GiveCashCrateAction@1:
|
GiveCashCrateAction@1:
|
||||||
Amount: 750
|
Amount: 750
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ HARV:
|
|||||||
|
|
||||||
^Crate:
|
^Crate:
|
||||||
Crate:
|
Crate:
|
||||||
Lifetime: 0
|
Duration: 0
|
||||||
|
|
||||||
MONEYCRATE:
|
MONEYCRATE:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
|
|||||||
@@ -1129,7 +1129,7 @@
|
|||||||
GenericName: Crate
|
GenericName: Crate
|
||||||
ShowOwnerRow: false
|
ShowOwnerRow: false
|
||||||
Crate:
|
Crate:
|
||||||
Lifetime: 180
|
Duration: 4500
|
||||||
TerrainTypes: Clear, Rough, Road, Ore, Beach, Water
|
TerrainTypes: Clear, Rough, Road, Ore, Beach, Water
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Palette: effect
|
Palette: effect
|
||||||
|
|||||||
@@ -458,7 +458,7 @@
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Crate
|
Name: Crate
|
||||||
Crate:
|
Crate:
|
||||||
Lifetime: 180
|
Duration: 4500
|
||||||
TerrainTypes: Clear, Rough, Sand, Road, DirtRoad, Tiberium, BlueTiberium, Veins, Green, Pavement
|
TerrainTypes: Clear, Rough, Sand, Road, DirtRoad, Tiberium, BlueTiberium, Veins, Green, Pavement
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Palette: terraindecoration
|
Palette: terraindecoration
|
||||||
|
|||||||
Reference in New Issue
Block a user