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