Fix IDE0032
This commit is contained in:
committed by
Pavel Penev
parent
9809f6ed08
commit
ed90322a0b
@@ -267,10 +267,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
{
|
||||
public readonly BuildingInfo Info;
|
||||
|
||||
[Sync]
|
||||
readonly CPos topLeft;
|
||||
|
||||
readonly Actor self;
|
||||
readonly BuildingInfluence influence;
|
||||
|
||||
@@ -278,13 +274,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly (CPos, SubCell)[] targetableCells;
|
||||
readonly CPos[] transitOnlyCells;
|
||||
|
||||
public CPos TopLeft => topLeft;
|
||||
[Sync]
|
||||
public CPos TopLeft { get; }
|
||||
public WPos CenterPosition { get; }
|
||||
|
||||
public Building(ActorInitializer init, BuildingInfo info)
|
||||
{
|
||||
self = init.Self;
|
||||
topLeft = init.GetValue<LocationInit, CPos>();
|
||||
TopLeft = init.GetValue<LocationInit, CPos>();
|
||||
Info = info;
|
||||
influence = self.World.WorldActor.Trait<BuildingInfluence>();
|
||||
|
||||
@@ -296,7 +293,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
transitOnlyCells = Info.TransitOnlyTiles(TopLeft).ToArray();
|
||||
|
||||
CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World);
|
||||
CenterPosition = init.World.Map.CenterOfCell(TopLeft) + Info.CenterOffset(init.World);
|
||||
}
|
||||
|
||||
public (CPos, SubCell)[] OccupiedCells() { return occupiedCells; }
|
||||
|
||||
@@ -60,47 +60,45 @@ namespace OpenRA.Mods.Common.Traits
|
||||
INotifyKilled[] notifyKilled;
|
||||
INotifyKilled[] notifyKilledPlayer;
|
||||
|
||||
[Sync]
|
||||
int hp;
|
||||
|
||||
public int DisplayHP { get; private set; }
|
||||
|
||||
public Health(ActorInitializer init, HealthInfo info)
|
||||
{
|
||||
Info = info;
|
||||
MaxHP = hp = info.HP > 0 ? info.HP : 1;
|
||||
MaxHP = HP = info.HP > 0 ? info.HP : 1;
|
||||
|
||||
// Cast to long to avoid overflow when multiplying by the health
|
||||
var healthInit = init.GetOrDefault<HealthInit>();
|
||||
if (healthInit != null)
|
||||
hp = (int)(healthInit.Value * (long)MaxHP / 100);
|
||||
HP = (int)(healthInit.Value * (long)MaxHP / 100);
|
||||
|
||||
DisplayHP = hp;
|
||||
DisplayHP = HP;
|
||||
}
|
||||
|
||||
public int HP => hp;
|
||||
[Sync]
|
||||
public int HP { get; private set; }
|
||||
public int MaxHP { get; }
|
||||
|
||||
public bool IsDead => hp <= 0;
|
||||
public bool IsDead => HP <= 0;
|
||||
public bool RemoveOnDeath = true;
|
||||
|
||||
public DamageState DamageState
|
||||
{
|
||||
get
|
||||
{
|
||||
if (hp == MaxHP)
|
||||
if (HP == MaxHP)
|
||||
return DamageState.Undamaged;
|
||||
|
||||
if (hp <= 0)
|
||||
if (HP <= 0)
|
||||
return DamageState.Dead;
|
||||
|
||||
if (hp * 100L < MaxHP * 25L)
|
||||
if (HP * 100L < MaxHP * 25L)
|
||||
return DamageState.Critical;
|
||||
|
||||
if (hp * 100L < MaxHP * 50L)
|
||||
if (HP * 100L < MaxHP * 50L)
|
||||
return DamageState.Heavy;
|
||||
|
||||
if (hp * 100L < MaxHP * 75L)
|
||||
if (HP * 100L < MaxHP * 75L)
|
||||
return DamageState.Medium;
|
||||
|
||||
return DamageState.Light;
|
||||
@@ -130,7 +128,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!IsDead)
|
||||
return;
|
||||
|
||||
hp = MaxHP;
|
||||
HP = MaxHP;
|
||||
|
||||
var ai = new AttackInfo
|
||||
{
|
||||
@@ -188,7 +186,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
damage = new Damage((int)appliedDamage, damage.DamageTypes);
|
||||
}
|
||||
|
||||
hp = (hp - damage.Value).Clamp(0, MaxHP);
|
||||
HP = (HP - damage.Value).Clamp(0, MaxHP);
|
||||
|
||||
var ai = new AttackInfo
|
||||
{
|
||||
@@ -215,7 +213,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
nd.AppliedDamage(attacker, self, ai);
|
||||
}
|
||||
|
||||
if (hp == 0)
|
||||
if (HP == 0)
|
||||
{
|
||||
foreach (var nd in notifyKilled)
|
||||
nd.Killed(self, ai);
|
||||
@@ -234,10 +232,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
if (hp >= DisplayHP)
|
||||
DisplayHP = hp;
|
||||
if (HP >= DisplayHP)
|
||||
DisplayHP = HP;
|
||||
else
|
||||
DisplayHP = (2 * DisplayHP + hp) / 3;
|
||||
DisplayHP = (2 * DisplayHP + HP) / 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,18 +31,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
sealed class Immobile : IOccupySpace, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
{
|
||||
[Sync]
|
||||
readonly CPos location;
|
||||
|
||||
[Sync]
|
||||
readonly WPos position;
|
||||
|
||||
readonly (CPos, SubCell)[] occupied;
|
||||
|
||||
public Immobile(ActorInitializer init, ImmobileInfo info)
|
||||
{
|
||||
location = init.GetValue<LocationInit, CPos>();
|
||||
position = init.World.Map.CenterOfCell(location);
|
||||
TopLeft = init.GetValue<LocationInit, CPos>();
|
||||
CenterPosition = init.World.Map.CenterOfCell(TopLeft);
|
||||
|
||||
if (info.OccupiesSpace)
|
||||
occupied = new[] { (TopLeft, SubCell.FullCell) };
|
||||
@@ -50,8 +44,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
occupied = Array.Empty<(CPos, SubCell)>();
|
||||
}
|
||||
|
||||
public CPos TopLeft => location;
|
||||
public WPos CenterPosition => position;
|
||||
[Sync]
|
||||
public CPos TopLeft { get; }
|
||||
[Sync]
|
||||
public WPos CenterPosition { get; }
|
||||
public (CPos, SubCell)[] OccupiedCells() { return occupied; }
|
||||
|
||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||
|
||||
@@ -42,16 +42,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Dictionary<Actor, int> powerDrain = new();
|
||||
|
||||
[Sync]
|
||||
int totalProvided;
|
||||
|
||||
public int PowerProvided => totalProvided;
|
||||
public int PowerProvided { get; private set; }
|
||||
|
||||
[Sync]
|
||||
int totalDrained;
|
||||
public int PowerDrained { get; private set; }
|
||||
|
||||
public int PowerDrained => totalDrained;
|
||||
|
||||
public int ExcessPower => totalProvided - totalDrained;
|
||||
public int ExcessPower => PowerProvided - PowerDrained;
|
||||
|
||||
public int PowerOutageRemainingTicks { get; private set; }
|
||||
public int PowerOutageTotalTicks { get; private set; }
|
||||
@@ -96,14 +92,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
if (old > 0)
|
||||
totalProvided -= old;
|
||||
PowerProvided -= old;
|
||||
else if (old < 0)
|
||||
totalDrained += old;
|
||||
PowerDrained += old;
|
||||
|
||||
if (amount > 0)
|
||||
totalProvided += amount;
|
||||
PowerProvided += amount;
|
||||
else if (amount < 0)
|
||||
totalDrained -= amount;
|
||||
PowerDrained -= amount;
|
||||
|
||||
UpdatePowerState();
|
||||
}
|
||||
@@ -122,9 +118,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
if (amount > 0)
|
||||
totalProvided -= amount;
|
||||
PowerProvided -= amount;
|
||||
else if (amount < 0)
|
||||
totalDrained += amount;
|
||||
PowerDrained += amount;
|
||||
|
||||
UpdatePowerState();
|
||||
}
|
||||
@@ -147,17 +143,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (wasHackEnabled != devMode.UnlimitedPower)
|
||||
{
|
||||
totalProvided = 0;
|
||||
totalDrained = 0;
|
||||
PowerProvided = 0;
|
||||
PowerDrained = 0;
|
||||
|
||||
if (!devMode.UnlimitedPower)
|
||||
{
|
||||
foreach (var kv in powerDrain)
|
||||
{
|
||||
if (kv.Value > 0)
|
||||
totalProvided += kv.Value;
|
||||
PowerProvided += kv.Value;
|
||||
else if (kv.Value < 0)
|
||||
totalDrained -= kv.Value;
|
||||
PowerDrained -= kv.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user