Remove TechLevel from special powers, and identify the performance problem.
This commit is contained in:
@@ -22,7 +22,6 @@ namespace OpenRA.Traits
|
|||||||
public readonly string LongDesc = "";
|
public readonly string LongDesc = "";
|
||||||
[ActorReference]
|
[ActorReference]
|
||||||
public readonly string[] Prerequisites = { };
|
public readonly string[] Prerequisites = { };
|
||||||
public readonly int TechLevel = -1;
|
|
||||||
public readonly bool GivenAuto = true;
|
public readonly bool GivenAuto = true;
|
||||||
|
|
||||||
public readonly string OrderName;
|
public readonly string OrderName;
|
||||||
@@ -48,7 +47,8 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
protected readonly Actor Self;
|
protected readonly Actor Self;
|
||||||
protected readonly Player Owner;
|
protected readonly Player Owner;
|
||||||
|
string[] effectivePrereq = {};
|
||||||
|
|
||||||
bool notifiedCharging;
|
bool notifiedCharging;
|
||||||
bool notifiedReady;
|
bool notifiedReady;
|
||||||
|
|
||||||
@@ -59,6 +59,9 @@ namespace OpenRA.Traits
|
|||||||
Self = self;
|
Self = self;
|
||||||
Owner = self.Owner;
|
Owner = self.Owner;
|
||||||
|
|
||||||
|
effectivePrereq = Info.Prerequisites
|
||||||
|
.Select(a => a.ToLowerInvariant()).ToArray();
|
||||||
|
|
||||||
self.Trait<TechTreeCache>().Add( Info.OrderName, Info.Prerequisites.Select( a => a.ToLowerInvariant() ).ToList(), this );
|
self.Trait<TechTreeCache>().Add( Info.OrderName, Info.Prerequisites.Select( a => a.ToLowerInvariant() ).ToList(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,13 +69,14 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
if (Info.OneShot && IsUsed)
|
if (Info.OneShot && IsUsed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Info.GivenAuto)
|
|
||||||
IsAvailable = Info.TechLevel > -1 && hasPrerequisites;
|
|
||||||
|
|
||||||
|
if (Info.GivenAuto)
|
||||||
|
IsAvailable = hasPrerequisites;
|
||||||
|
|
||||||
if (IsAvailable && (!Info.RequiresPower || IsPowered()))
|
if (IsAvailable && (!Info.RequiresPower || IsPowered()))
|
||||||
{
|
{
|
||||||
if (Game.LobbyInfo.GlobalSettings.AllowCheats && self.Trait<DeveloperMode>().FastCharge) RemainingTime = 0;
|
if (Game.LobbyInfo.GlobalSettings.AllowCheats && self.Trait<DeveloperMode>().FastCharge) RemainingTime = 0;
|
||||||
|
|
||||||
if (RemainingTime > 0) --RemainingTime;
|
if (RemainingTime > 0) --RemainingTime;
|
||||||
if (!notifiedCharging)
|
if (!notifiedCharging)
|
||||||
{
|
{
|
||||||
@@ -93,15 +97,13 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
bool IsPowered()
|
bool IsPowered()
|
||||||
{
|
{
|
||||||
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
if (effectivePrereq.Count() == 0)
|
||||||
var effectivePrereq = Info.Prerequisites
|
|
||||||
.Select(a => a.ToLowerInvariant());
|
|
||||||
|
|
||||||
if (Info.Prerequisites.Count() == 0)
|
|
||||||
return Owner.PlayerActor.Trait<PlayerResources>().GetPowerState() == PowerState.Normal;
|
return Owner.PlayerActor.Trait<PlayerResources>().GetPowerState() == PowerState.Normal;
|
||||||
|
|
||||||
return effectivePrereq.Any() &&
|
// Takes 0.3ms on pchote's machine -- calling it every tick for every active special power is retarded
|
||||||
effectivePrereq.All(a => buildings[a].Any(b => !b.Trait<Building>().Disabled));
|
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
||||||
|
|
||||||
|
return effectivePrereq.All(a => buildings[a].Any(b => !b.Trait<Building>().Disabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishActivate()
|
public void FinishActivate()
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Player:
|
|||||||
Description: Atom Bomb
|
Description: Atom Bomb
|
||||||
LongDesc: Launches a nuclear missile at a target location.
|
LongDesc: Launches a nuclear missile at a target location.
|
||||||
Prerequisites: TMPL
|
Prerequisites: TMPL
|
||||||
TechLevel: 12
|
|
||||||
BeginChargeSound:
|
BeginChargeSound:
|
||||||
EndChargeSound: nukavail.aud
|
EndChargeSound: nukavail.aud
|
||||||
SelectTargetSound: select1.aud
|
SelectTargetSound: select1.aud
|
||||||
@@ -18,7 +17,6 @@ Player:
|
|||||||
Description: Ion Cannon
|
Description: Ion Cannon
|
||||||
LongDesc: Discharges the orbital Ion Cannon at your target.
|
LongDesc: Discharges the orbital Ion Cannon at your target.
|
||||||
Prerequisites: EYE
|
Prerequisites: EYE
|
||||||
TechLevel: 12
|
|
||||||
BeginChargeSound: ionchrg1.aud
|
BeginChargeSound: ionchrg1.aud
|
||||||
EndChargeSound: ionredy1.aud
|
EndChargeSound: ionredy1.aud
|
||||||
LaunchSound: ion1.aud
|
LaunchSound: ion1.aud
|
||||||
@@ -29,7 +27,6 @@ Player:
|
|||||||
Description: Airstrike
|
Description: Airstrike
|
||||||
LongDesc: Delivers a load of napalm on your target.
|
LongDesc: Delivers a load of napalm on your target.
|
||||||
Prerequisites: hq
|
Prerequisites: hq
|
||||||
TechLevel: 8
|
|
||||||
EndChargeSound: airredy1.aud
|
EndChargeSound: airredy1.aud
|
||||||
SelectTargetSound: select1.aud
|
SelectTargetSound: select1.aud
|
||||||
UnitType: a10
|
UnitType: a10
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ Player:
|
|||||||
Description: GPS Satellite
|
Description: GPS Satellite
|
||||||
LongDesc: Reveals the entire map
|
LongDesc: Reveals the entire map
|
||||||
Prerequisites: ATEK
|
Prerequisites: ATEK
|
||||||
TechLevel: 12
|
|
||||||
RevealDelay: 15
|
RevealDelay: 15
|
||||||
LaunchSound: satlnch1.aud
|
LaunchSound: satlnch1.aud
|
||||||
ChronoshiftPower:
|
ChronoshiftPower:
|
||||||
@@ -41,7 +40,6 @@ Player:
|
|||||||
Description: Chronoshift
|
Description: Chronoshift
|
||||||
LongDesc: Temporarily teleports a vehicle across \nthe map.
|
LongDesc: Temporarily teleports a vehicle across \nthe map.
|
||||||
Prerequisites: PDOX
|
Prerequisites: PDOX
|
||||||
TechLevel: 12
|
|
||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
BeginChargeSound: chrochr1.aud
|
BeginChargeSound: chrochr1.aud
|
||||||
EndChargeSound: chrordy1.aud
|
EndChargeSound: chrordy1.aud
|
||||||
@@ -51,7 +49,6 @@ Player:
|
|||||||
Description: Invulnerability
|
Description: Invulnerability
|
||||||
LongDesc: Makes a single unit invulnerable for a \nshort time.
|
LongDesc: Makes a single unit invulnerable for a \nshort time.
|
||||||
Prerequisites: IRON
|
Prerequisites: IRON
|
||||||
TechLevel: 12
|
|
||||||
Duration: .75
|
Duration: .75
|
||||||
SpyPlanePower:
|
SpyPlanePower:
|
||||||
Image: smigicon
|
Image: smigicon
|
||||||
@@ -59,14 +56,12 @@ Player:
|
|||||||
Description: Spy Plane
|
Description: Spy Plane
|
||||||
LongDesc: Reveals an area of the map.
|
LongDesc: Reveals an area of the map.
|
||||||
Prerequisites: AFLD
|
Prerequisites: AFLD
|
||||||
TechLevel: 5
|
|
||||||
ParatroopersPower:
|
ParatroopersPower:
|
||||||
Image: pinficon
|
Image: pinficon
|
||||||
ChargeTime: 6
|
ChargeTime: 6
|
||||||
Description: Paratroopers
|
Description: Paratroopers
|
||||||
LongDesc: A Badger drops a squad of Riflemen \nanywhere on the map
|
LongDesc: A Badger drops a squad of Riflemen \nanywhere on the map
|
||||||
Prerequisites: AFLD
|
Prerequisites: AFLD
|
||||||
TechLevel: 5
|
|
||||||
DropItems: E1,E1,E1,E3,E3
|
DropItems: E1,E1,E1,E3,E3
|
||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
NukePower:
|
NukePower:
|
||||||
@@ -75,7 +70,6 @@ Player:
|
|||||||
Description: Atom Bomb
|
Description: Atom Bomb
|
||||||
LongDesc: Launches a nuclear missile at a target location.
|
LongDesc: Launches a nuclear missile at a target location.
|
||||||
Prerequisites: MSLO
|
Prerequisites: MSLO
|
||||||
TechLevel: 12
|
|
||||||
BeginChargeSound: aprep1.aud
|
BeginChargeSound: aprep1.aud
|
||||||
EndChargeSound: aready1.aud
|
EndChargeSound: aready1.aud
|
||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
@@ -85,7 +79,6 @@ Player:
|
|||||||
ChargeTime: 10
|
ChargeTime: 10
|
||||||
Description: Sonar Pulse (Single Use)
|
Description: Sonar Pulse (Single Use)
|
||||||
LongDesc: Reveals all submarines on the map for a \nshort time.
|
LongDesc: Reveals all submarines on the map for a \nshort time.
|
||||||
TechLevel: 5
|
|
||||||
GivenAuto: no
|
GivenAuto: no
|
||||||
OneShot: yes
|
OneShot: yes
|
||||||
AirstrikePower:
|
AirstrikePower:
|
||||||
@@ -93,7 +86,6 @@ Player:
|
|||||||
ChargeTime: 5
|
ChargeTime: 5
|
||||||
Description: Parabombs (Single Use)
|
Description: Parabombs (Single Use)
|
||||||
LongDesc: A Badger drops a load of parachuted bombs on your target.
|
LongDesc: A Badger drops a load of parachuted bombs on your target.
|
||||||
TechLevel: 5
|
|
||||||
GivenAuto: no
|
GivenAuto: no
|
||||||
OneShot: yes
|
OneShot: yes
|
||||||
UnitType: badr.bomber
|
UnitType: badr.bomber
|
||||||
|
|||||||
Reference in New Issue
Block a user