Merge pull request #10163 from teees/cruising
Added cruising upgrade to aircraft
This commit is contained in:
@@ -55,6 +55,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("The upgrades to grant to self while airborne.")]
|
[Desc("The upgrades to grant to self while airborne.")]
|
||||||
public readonly string[] AirborneUpgrades = { };
|
public readonly string[] AirborneUpgrades = { };
|
||||||
|
|
||||||
|
[UpgradeGrantedReference]
|
||||||
|
[Desc("The upgrades to grant to self while at cruise altitude.")]
|
||||||
|
public readonly string[] CruisingUpgrades = { };
|
||||||
|
|
||||||
[Desc("Can the actor hover in place mid-air? If not, then the actor will have to remain in motion (circle around).")]
|
[Desc("Can the actor hover in place mid-air? If not, then the actor will have to remain in motion (circle around).")]
|
||||||
public readonly bool CanHover = false;
|
public readonly bool CanHover = false;
|
||||||
|
|
||||||
@@ -100,29 +104,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public int ROT { get { return Info.ROT; } }
|
public int ROT { get { return Info.ROT; } }
|
||||||
|
|
||||||
bool airborne;
|
bool airborne;
|
||||||
bool IsAirborne
|
bool cruising;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return airborne;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (airborne == value)
|
|
||||||
return;
|
|
||||||
airborne = value;
|
|
||||||
if (um != null)
|
|
||||||
{
|
|
||||||
if (airborne)
|
|
||||||
foreach (var u in Info.AirborneUpgrades)
|
|
||||||
um.GrantUpgrade(self, u, this);
|
|
||||||
else
|
|
||||||
foreach (var u in Info.AirborneUpgrades)
|
|
||||||
um.RevokeUpgrade(self, u, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Aircraft(ActorInitializer init, AircraftInfo info)
|
public Aircraft(ActorInitializer init, AircraftInfo info)
|
||||||
{
|
{
|
||||||
@@ -149,8 +131,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.World.ActorMap.AddInfluence(self, this);
|
self.World.ActorMap.AddInfluence(self, this);
|
||||||
self.World.ActorMap.AddPosition(self, this);
|
self.World.ActorMap.AddPosition(self, this);
|
||||||
self.World.ScreenMap.Add(self);
|
self.World.ScreenMap.Add(self);
|
||||||
if (self.World.Map.DistanceAboveTerrain(CenterPosition).Length >= Info.MinAirborneAltitude)
|
var altitude = self.World.Map.DistanceAboveTerrain(CenterPosition);
|
||||||
IsAirborne = true;
|
if (altitude.Length >= Info.MinAirborneAltitude)
|
||||||
|
OnAirborneAltitudeReached();
|
||||||
|
if (altitude == Info.CruiseAltitude)
|
||||||
|
OnCruisingAltitudeReached();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool firstTick = true;
|
bool firstTick = true;
|
||||||
@@ -369,7 +354,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
self.World.ScreenMap.Update(self);
|
self.World.ScreenMap.Update(self);
|
||||||
self.World.ActorMap.UpdatePosition(self, this);
|
self.World.ActorMap.UpdatePosition(self, this);
|
||||||
IsAirborne = self.World.Map.DistanceAboveTerrain(CenterPosition).Length >= Info.MinAirborneAltitude;
|
var altitude = self.World.Map.DistanceAboveTerrain(CenterPosition);
|
||||||
|
var isAirborne = altitude.Length >= Info.MinAirborneAltitude;
|
||||||
|
if (isAirborne && !airborne)
|
||||||
|
OnAirborneAltitudeReached();
|
||||||
|
else if (!isAirborne && airborne)
|
||||||
|
OnAirborneAltitudeLeft();
|
||||||
|
var isCruising = altitude == Info.CruiseAltitude;
|
||||||
|
if (isCruising && !cruising)
|
||||||
|
OnCruisingAltitudeReached();
|
||||||
|
else if (!isCruising && cruising)
|
||||||
|
OnCruisingAltitudeLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -610,9 +605,58 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.World.ActorMap.RemoveInfluence(self, this);
|
self.World.ActorMap.RemoveInfluence(self, this);
|
||||||
self.World.ActorMap.RemovePosition(self, this);
|
self.World.ActorMap.RemovePosition(self, this);
|
||||||
self.World.ScreenMap.Remove(self);
|
self.World.ScreenMap.Remove(self);
|
||||||
IsAirborne = false;
|
OnCruisingAltitudeLeft();
|
||||||
|
OnAirborneAltitudeLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Airborne upgrades
|
||||||
|
|
||||||
|
void OnAirborneAltitudeReached()
|
||||||
|
{
|
||||||
|
if (airborne)
|
||||||
|
return;
|
||||||
|
airborne = true;
|
||||||
|
if (um != null)
|
||||||
|
foreach (var u in Info.AirborneUpgrades)
|
||||||
|
um.GrantUpgrade(self, u, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnAirborneAltitudeLeft()
|
||||||
|
{
|
||||||
|
if (!airborne)
|
||||||
|
return;
|
||||||
|
airborne = false;
|
||||||
|
if (um != null)
|
||||||
|
foreach (var u in Info.AirborneUpgrades)
|
||||||
|
um.RevokeUpgrade(self, u, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Cruising upgrades
|
||||||
|
|
||||||
|
void OnCruisingAltitudeReached()
|
||||||
|
{
|
||||||
|
if (cruising)
|
||||||
|
return;
|
||||||
|
cruising = true;
|
||||||
|
if (um != null)
|
||||||
|
foreach (var u in Info.CruisingUpgrades)
|
||||||
|
um.GrantUpgrade(self, u, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnCruisingAltitudeLeft()
|
||||||
|
{
|
||||||
|
if (!cruising)
|
||||||
|
return;
|
||||||
|
cruising = false;
|
||||||
|
if (um != null)
|
||||||
|
foreach (var u in Info.CruisingUpgrades)
|
||||||
|
um.RevokeUpgrade(self, u, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Disposing(Actor self)
|
public void Disposing(Actor self)
|
||||||
{
|
{
|
||||||
UnReserve();
|
UnReserve();
|
||||||
|
|||||||
@@ -135,6 +135,7 @@
|
|||||||
RepairBuildings: hpad
|
RepairBuildings: hpad
|
||||||
LandWhenIdle: false
|
LandWhenIdle: false
|
||||||
AirborneUpgrades: airborne
|
AirborneUpgrades: airborne
|
||||||
|
CruisingUpgrades: cruising
|
||||||
CanHover: True
|
CanHover: True
|
||||||
HiddenUnderFog:
|
HiddenUnderFog:
|
||||||
Type: CenterPosition
|
Type: CenterPosition
|
||||||
@@ -150,7 +151,9 @@
|
|||||||
GenericName: Helicopter
|
GenericName: Helicopter
|
||||||
WithFacingSpriteBody:
|
WithFacingSpriteBody:
|
||||||
WithShadow:
|
WithShadow:
|
||||||
Hovers:
|
Hovers@CRUISING:
|
||||||
|
UpgradeTypes: cruising
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
Voiced:
|
Voiced:
|
||||||
VoiceSet: VehicleVoice
|
VoiceSet: VehicleVoice
|
||||||
|
|||||||
@@ -353,6 +353,7 @@
|
|||||||
RepairBuildings: fix
|
RepairBuildings: fix
|
||||||
RearmBuildings: afld
|
RearmBuildings: afld
|
||||||
AirborneUpgrades: airborne
|
AirborneUpgrades: airborne
|
||||||
|
CruisingUpgrades: cruising
|
||||||
Targetable@GROUND:
|
Targetable@GROUND:
|
||||||
TargetTypes: Ground, Repair, Vehicle
|
TargetTypes: Ground, Repair, Vehicle
|
||||||
UpgradeTypes: airborne
|
UpgradeTypes: airborne
|
||||||
@@ -396,7 +397,9 @@
|
|||||||
CanHover: True
|
CanHover: True
|
||||||
GpsDot:
|
GpsDot:
|
||||||
String: Helicopter
|
String: Helicopter
|
||||||
Hovers:
|
Hovers@CRUISING:
|
||||||
|
UpgradeTypes: cruising
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
^BasicBuilding:
|
^BasicBuilding:
|
||||||
Inherits@1: ^ExistsInWorld
|
Inherits@1: ^ExistsInWorld
|
||||||
@@ -625,6 +628,7 @@
|
|||||||
GenericName: Destroyed Plane
|
GenericName: Destroyed Plane
|
||||||
Aircraft:
|
Aircraft:
|
||||||
AirborneUpgrades: airborne
|
AirborneUpgrades: airborne
|
||||||
|
CruisingUpgrades: cruising
|
||||||
FallsToEarth:
|
FallsToEarth:
|
||||||
Spins: False
|
Spins: False
|
||||||
Moves: True
|
Moves: True
|
||||||
@@ -637,6 +641,7 @@
|
|||||||
GenericName: Destroyed Helicopter
|
GenericName: Destroyed Helicopter
|
||||||
Aircraft:
|
Aircraft:
|
||||||
AirborneUpgrades: airborne
|
AirborneUpgrades: airborne
|
||||||
|
CruisingUpgrades: cruising
|
||||||
CanHover: True
|
CanHover: True
|
||||||
FallsToEarth:
|
FallsToEarth:
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ DSHP:
|
|||||||
MaxWeight: 5
|
MaxWeight: 5
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
UnloadVoice: Move
|
UnloadVoice: Move
|
||||||
Hovers:
|
|
||||||
|
|
||||||
ORCA:
|
ORCA:
|
||||||
Inherits: ^Helicopter
|
Inherits: ^Helicopter
|
||||||
@@ -98,9 +97,6 @@ ORCA:
|
|||||||
PipTypeEmpty: AmmoEmpty
|
PipTypeEmpty: AmmoEmpty
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Hovers@AIRBORNE:
|
|
||||||
UpgradeTypes: airborne
|
|
||||||
UpgradeMinEnabledLevel: 1
|
|
||||||
|
|
||||||
ORCAB:
|
ORCAB:
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
@@ -144,8 +140,8 @@ ORCAB:
|
|||||||
PipTypeEmpty: AmmoEmpty
|
PipTypeEmpty: AmmoEmpty
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Hovers@AIRBORNE:
|
Hovers@CRUISING:
|
||||||
UpgradeTypes: airborne
|
UpgradeTypes: cruising
|
||||||
UpgradeMinEnabledLevel: 1
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
ORCATRAN:
|
ORCATRAN:
|
||||||
@@ -179,9 +175,6 @@ ORCATRAN:
|
|||||||
MaxWeight: 5
|
MaxWeight: 5
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
UnloadVoice: Move
|
UnloadVoice: Move
|
||||||
Hovers@AIRBORNE:
|
|
||||||
UpgradeTypes: airborne
|
|
||||||
UpgradeMinEnabledLevel: 1
|
|
||||||
|
|
||||||
TRNSPORT:
|
TRNSPORT:
|
||||||
Inherits: ^Helicopter
|
Inherits: ^Helicopter
|
||||||
@@ -211,9 +204,6 @@ TRNSPORT:
|
|||||||
Range: 2c0
|
Range: 2c0
|
||||||
Type: CenterPosition
|
Type: CenterPosition
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Hovers@AIRBORNE:
|
|
||||||
UpgradeTypes: airborne
|
|
||||||
UpgradeMinEnabledLevel: 1
|
|
||||||
Selectable:
|
Selectable:
|
||||||
Bounds: 44,32,0,-8
|
Bounds: 44,32,0,-8
|
||||||
|
|
||||||
@@ -298,9 +288,6 @@ APACHE:
|
|||||||
WithSpriteRotorOverlay:
|
WithSpriteRotorOverlay:
|
||||||
Offset: 85,0,384
|
Offset: 85,0,384
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Hovers@AIRBORNE:
|
|
||||||
UpgradeTypes: airborne
|
|
||||||
UpgradeMinEnabledLevel: 1
|
|
||||||
|
|
||||||
HUNTER:
|
HUNTER:
|
||||||
Inherits@1: ^GainsExperience
|
Inherits@1: ^GainsExperience
|
||||||
@@ -331,7 +318,9 @@ HUNTER:
|
|||||||
RenderSprites:
|
RenderSprites:
|
||||||
Image: GGHUNT
|
Image: GGHUNT
|
||||||
WithFacingSpriteBody:
|
WithFacingSpriteBody:
|
||||||
Hovers:
|
Hovers@CRUISING:
|
||||||
|
UpgradeTypes: cruising
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
QuantizeFacingsFromSequence:
|
QuantizeFacingsFromSequence:
|
||||||
AutoSelectionSize:
|
AutoSelectionSize:
|
||||||
DrawLineToTarget:
|
DrawLineToTarget:
|
||||||
|
|||||||
@@ -472,6 +472,13 @@
|
|||||||
Selectable:
|
Selectable:
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
Palette: pips
|
Palette: pips
|
||||||
|
Aircraft:
|
||||||
|
AirborneUpgrades: airborne
|
||||||
|
CruisingUpgrades: cruising
|
||||||
|
RepairBuildings: gadept
|
||||||
|
RearmBuildings: gahpad, nahpad
|
||||||
|
LandWhenIdle: no
|
||||||
|
Voice: Move
|
||||||
Voiced:
|
Voiced:
|
||||||
VoiceSet: Heli
|
VoiceSet: Heli
|
||||||
HiddenUnderFog:
|
HiddenUnderFog:
|
||||||
@@ -492,23 +499,18 @@
|
|||||||
^Helicopter:
|
^Helicopter:
|
||||||
Inherits: ^Aircraft
|
Inherits: ^Aircraft
|
||||||
Aircraft:
|
Aircraft:
|
||||||
RepairBuildings: gadept
|
|
||||||
RearmBuildings: gahpad, nahpad
|
|
||||||
LandWhenIdle: no
|
LandWhenIdle: no
|
||||||
CruiseAltitude: 2048
|
CruiseAltitude: 2048
|
||||||
Voice: Move
|
|
||||||
AirborneUpgrades: airborne
|
|
||||||
CanHover: True
|
CanHover: True
|
||||||
|
Hovers@CRUISING:
|
||||||
|
UpgradeTypes: cruising
|
||||||
|
UpgradeMinEnabledLevel: 1
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
Inherits: ^Aircraft
|
Inherits: ^Aircraft
|
||||||
Aircraft:
|
Aircraft:
|
||||||
RepairBuildings: gadept
|
|
||||||
RearmBuildings: gahpad, nahpad
|
|
||||||
LandWhenIdle: no
|
LandWhenIdle: no
|
||||||
CruiseAltitude: 2560
|
CruiseAltitude: 2560
|
||||||
Voice: Move
|
|
||||||
AirborneUpgrades: airborne
|
|
||||||
ReturnOnIdle:
|
ReturnOnIdle:
|
||||||
|
|
||||||
^Viceroid:
|
^Viceroid:
|
||||||
|
|||||||
Reference in New Issue
Block a user