Refactor Spin to MaximumSpinSpeed
Additionally, add descriptions to other FallsToEarth properties.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
@@ -20,15 +21,16 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly Aircraft aircraft;
|
||||
readonly FallsToEarthInfo info;
|
||||
int acceleration = 0;
|
||||
int spin = 0;
|
||||
|
||||
int acceleration;
|
||||
int spin;
|
||||
|
||||
public FallToEarth(Actor self, FallsToEarthInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
IsInterruptible = false;
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
if (info.Spins)
|
||||
if (info.MaximumSpinSpeed != 0)
|
||||
acceleration = self.World.SharedRandom.Next(2) * 2 - 1;
|
||||
}
|
||||
|
||||
@@ -47,9 +49,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return true;
|
||||
}
|
||||
|
||||
if (info.Spins)
|
||||
if (info.MaximumSpinSpeed != 0)
|
||||
{
|
||||
spin += acceleration;
|
||||
if (info.MaximumSpinSpeed < 0 || Math.Abs(spin) < info.MaximumSpinSpeed)
|
||||
spin += acceleration; // TODO: Possibly unhardcode this
|
||||
|
||||
aircraft.Facing = (aircraft.Facing + spin) % 256;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class FallsToEarthInfo : ITraitInfo, IRulesetLoaded, Requires<AircraftInfo>
|
||||
{
|
||||
[WeaponReference]
|
||||
[Desc("Explosion weapon that triggers when hitting ground.")]
|
||||
public readonly string Explosion = "UnitExplode";
|
||||
|
||||
public readonly bool Spins = true;
|
||||
[Desc("Limit the maximum spin (in facing units per tick) that can be achieved while crashing.",
|
||||
"0 disables spinning. Negative values imply no limit.")]
|
||||
public readonly int MaximumSpinSpeed = -1;
|
||||
|
||||
[Desc("Does the aircraft (husk) move forward at aircraft speed?")]
|
||||
public readonly bool Moves = false;
|
||||
|
||||
[Desc("Velocity (per tick) at which aircraft falls to ground.")]
|
||||
public readonly WDist Velocity = new WDist(43);
|
||||
|
||||
public WeaponInfo ExplosionWeapon { get; private set; }
|
||||
|
||||
60
OpenRA.Mods.Common/UpdateRules/Rules/RenameSpins.cs
Normal file
60
OpenRA.Mods.Common/UpdateRules/Rules/RenameSpins.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2019 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 System.Linq;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class RenameSpins : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "FallsToEarth.Spins has been refactored to MaximumSpinSpeed."; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "The FallsToEarth.Spins property has been refactored to MaximumSpinSpeed.";
|
||||
}
|
||||
}
|
||||
|
||||
readonly List<string> locations = new List<string>();
|
||||
|
||||
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||
{
|
||||
if (locations.Any())
|
||||
yield return "The Spins property has been refactored to MaximumSpinSpeed.\n" +
|
||||
"MaximumSpinSpeed defaults to 'unlimited', while disabling is done by setting it to 0.\n" +
|
||||
"You may want to set a custom MaximumSpinSpeed limiting value in the following places:\n" +
|
||||
UpdateUtils.FormatMessageList(locations);
|
||||
|
||||
locations.Clear();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
foreach (var fallsToEarth in actorNode.ChildrenMatching("FallsToEarth"))
|
||||
{
|
||||
var spinsNode = fallsToEarth.LastChildMatching("Spins");
|
||||
if (spinsNode != null)
|
||||
{
|
||||
var spins = spinsNode.NodeValue<bool>();
|
||||
if (!spins)
|
||||
fallsToEarth.AddNode("MaximumSpinSpeed", "0");
|
||||
|
||||
fallsToEarth.RemoveNode(spinsNode);
|
||||
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
|
||||
}
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1087,7 +1087,6 @@
|
||||
VTOL: true
|
||||
CanSlide: True
|
||||
FallsToEarth:
|
||||
Spins: True
|
||||
Moves: False
|
||||
Explosion: HeliCrash
|
||||
Tooltip:
|
||||
|
||||
@@ -262,7 +262,7 @@
|
||||
GenericName: Unit
|
||||
WithShadow:
|
||||
FallsToEarth:
|
||||
Spins: False
|
||||
MaximumSpinSpeed: 0
|
||||
Moves: True
|
||||
Explosion: UnitExplodeLarge
|
||||
-MapEditorData:
|
||||
|
||||
@@ -1030,10 +1030,10 @@
|
||||
GenericName: Destroyed Plane
|
||||
Aircraft:
|
||||
FallsToEarth:
|
||||
Spins: False
|
||||
Moves: True
|
||||
Velocity: 86
|
||||
Explosion: UnitExplodePlane
|
||||
MaximumSpinSpeed: 0
|
||||
-MapEditorData:
|
||||
RevealOnDeath:
|
||||
Duration: 60
|
||||
|
||||
@@ -945,9 +945,9 @@
|
||||
Tooltip:
|
||||
GenericName: Destroyed Aircraft
|
||||
FallsToEarth:
|
||||
Spins: true
|
||||
Moves: true
|
||||
Velocity: 112
|
||||
MaximumSpinSpeed: 10
|
||||
HitShape:
|
||||
|
||||
^Visceroid:
|
||||
|
||||
@@ -30,8 +30,10 @@ ORCAB.Husk:
|
||||
Tooltip:
|
||||
Name: Orca Bomber
|
||||
Aircraft:
|
||||
TurnSpeed: 5
|
||||
TurnSpeed: 3
|
||||
Speed: 96
|
||||
FallsToEarth:
|
||||
MaximumSpinSpeed: 6
|
||||
RenderSprites:
|
||||
Image: orcab
|
||||
RenderVoxels:
|
||||
@@ -78,8 +80,10 @@ SCRIN.Husk:
|
||||
Tooltip:
|
||||
Name: Banshee Fighter
|
||||
Aircraft:
|
||||
TurnSpeed: 5
|
||||
TurnSpeed: 3
|
||||
Speed: 168
|
||||
FallsToEarth:
|
||||
MaximumSpinSpeed: 6
|
||||
RenderSprites:
|
||||
Image: scrin
|
||||
RenderVoxels:
|
||||
|
||||
Reference in New Issue
Block a user