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>
|
||||
{
|
||||
[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.")]
|
||||
public readonly int Lifetime = 0;
|
||||
public readonly int Duration = 0;
|
||||
|
||||
[Desc("Allowed to land on.")]
|
||||
public readonly HashSet<string> TerrainTypes = new HashSet<string>();
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
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 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;
|
||||
|
||||
[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.")]
|
||||
public readonly int PanicSpeedModifier = 200;
|
||||
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!Panicking)
|
||||
return;
|
||||
|
||||
if (self.World.WorldTick >= panicStartedTick + info.PanicLength)
|
||||
if (self.World.WorldTick >= panicStartedTick + info.PanicDuration)
|
||||
{
|
||||
self.CancelActivity();
|
||||
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 ConvertBoundsToWDist(),
|
||||
new RemoveSmokeTrailWhenDamaged(),
|
||||
new ReplaceCrateSecondsWithTicks(),
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user