Remove unnecessary parentheses
This commit is contained in:
@@ -539,7 +539,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return new WVec(1024, 0, 0).Rotate(rot);
|
||||
}
|
||||
|
||||
return (d * 1024 * 8) / (int)distSq;
|
||||
return d * 1024 * 8 / (int)distSq;
|
||||
}
|
||||
|
||||
public Actor GetActorBelow()
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
var totalReloadDelay = arm.Weapon.ReloadDelay + (arm.Weapon.BurstDelays[0] * (burst - 1)).Clamp(1, 200);
|
||||
var damageWarheads = arm.Weapon.Warheads.OfType<DamageWarhead>();
|
||||
foreach (var warhead in damageWarheads)
|
||||
sumOfDamage += (warhead.Damage * burst / totalReloadDelay) * 100;
|
||||
sumOfDamage += warhead.Damage * burst / totalReloadDelay * 100;
|
||||
}
|
||||
|
||||
return sumOfDamage;
|
||||
@@ -239,7 +239,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
if (!own.Any())
|
||||
return 0.0f;
|
||||
|
||||
var relative = (relativeFunc(own, getValue) / relativeFunc(enemy, getValue)) * normalizeByValue;
|
||||
var relative = relativeFunc(own, getValue) / relativeFunc(enemy, getValue) * normalizeByValue;
|
||||
return relative.Clamp(0.0f, 999.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
var checkIndices = Exts.MakeArray(columnCount * rowCount, i => i).Shuffle(owner.World.LocalRandom);
|
||||
foreach (var i in checkIndices)
|
||||
{
|
||||
var pos = new MPos((i % columnCount) * dangerRadius + dangerRadius / 2, (i / columnCount) * dangerRadius + dangerRadius / 2).ToCPos(map);
|
||||
var pos = new MPos(i % columnCount * dangerRadius + dangerRadius / 2, i / columnCount * dangerRadius + dangerRadius / 2).ToCPos(map);
|
||||
|
||||
if (NearToPosSafely(owner, map.CenterOfCell(pos), out detectedEnemyTarget))
|
||||
{
|
||||
|
||||
@@ -215,10 +215,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var offset = buildingInfo.CenterOffset(self.World).Y + 1024;
|
||||
|
||||
return footprint.Select(c => (IRenderable)(new SpriteRenderable(
|
||||
return footprint.Select(c => (IRenderable)new SpriteRenderable(
|
||||
terrainRenderer.TileSprite(new TerrainTile(template, c.Value)),
|
||||
wr.World.Map.CenterOfCell(c.Key), WVec.Zero, -offset, palette, 1f, 1f,
|
||||
float3.Ones, TintModifiers.None, true))).ToArray();
|
||||
float3.Ones, TintModifiers.None, true)).ToArray();
|
||||
}
|
||||
|
||||
bool initialized;
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public WVec CenterOffset(World w)
|
||||
{
|
||||
var off = (w.Map.CenterOfCell(new CPos(Dimensions.X, Dimensions.Y)) - w.Map.CenterOfCell(new CPos(1, 1))) / 2;
|
||||
return (off - new WVec(0, 0, off.Z)) + LocalCenterOffset;
|
||||
return off - new WVec(0, 0, off.Z) + LocalCenterOffset;
|
||||
}
|
||||
|
||||
public BaseProvider FindBaseProvider(World world, Player p, CPos topLeft)
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var bounds = map.Bounds;
|
||||
var center = new MPos(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2).ToCPos(map);
|
||||
var spawnVec = owner.HomeLocation - center;
|
||||
startPos = owner.HomeLocation + spawnVec * (Exts.ISqrt((bounds.Height * bounds.Height + bounds.Width * bounds.Width) / (4 * spawnVec.LengthSquared)));
|
||||
startPos = owner.HomeLocation + spawnVec * Exts.ISqrt((bounds.Height * bounds.Height + bounds.Width * bounds.Width) / (4 * spawnVec.LengthSquared));
|
||||
endPos = startPos;
|
||||
var spawnDirection = new WVec((self.Location - startPos).X, (self.Location - startPos).Y, 0);
|
||||
spawnFacing = spawnDirection.Yaw;
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var hpToRepair = Math.Min(Info.RepairStep, health.MaxHP - health.HP);
|
||||
|
||||
// Cast to long to avoid overflow when multiplying by the health
|
||||
var cost = Math.Max(1, (int)(((long)hpToRepair * Info.RepairPercent * buildingValue) / (health.MaxHP * 100L)));
|
||||
var cost = Math.Max(1, (int)((long)hpToRepair * Info.RepairPercent * buildingValue / (health.MaxHP * 100L)));
|
||||
|
||||
// TakeCash will return false if the player can't pay, and will stop him from contributing this Tick
|
||||
var activePlayers = Repairers.Count(player => player.PlayerActor.Trait<PlayerResources>().TakeCash(cost, true));
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.Count(p => !p.Trait.IsTraitDisabled && !p.Trait.IsTraitPaused && p.Actor.Owner == self.Owner && p.Trait.Info.Produces.Contains(type));
|
||||
|
||||
var speedModifier = selfsameProductionsCount.Clamp(1, info.BuildingCountBuildTimeMultipliers.Length) - 1;
|
||||
time = (time * info.BuildingCountBuildTimeMultipliers[speedModifier]) / 100;
|
||||
time = time * info.BuildingCountBuildTimeMultipliers[speedModifier] / 100;
|
||||
}
|
||||
|
||||
return time;
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.Count(p => !p.Trait.IsTraitDisabled && !p.Trait.IsTraitPaused && p.Actor.Owner == self.Owner && p.Trait.Info.Produces.Contains(type));
|
||||
|
||||
var speedModifier = selfsameProductionsCount.Clamp(1, info.BuildTimeSpeedReduction.Length) - 1;
|
||||
time = (time * info.BuildTimeSpeedReduction[speedModifier]) / 100;
|
||||
time = time * info.BuildTimeSpeedReduction[speedModifier] / 100;
|
||||
}
|
||||
|
||||
return time;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
if (blinkPattern != null && blinkPattern.Length > 0)
|
||||
{
|
||||
var i = (self.World.WorldTick / Info.BlinkInterval) % blinkPattern.Length;
|
||||
var i = self.World.WorldTick / Info.BlinkInterval % blinkPattern.Length;
|
||||
if (blinkPattern[i] != BlinkState.On)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var a = new Animation(self.World, rs.GetImage(self));
|
||||
a.PlayFetchIndex(info.Sequence, () =>
|
||||
playerResources.ResourceCapacity != 0 ?
|
||||
((10 * a.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) :
|
||||
(10 * a.CurrentSequence.Length - 1) * playerResources.Resources / (10 * playerResources.ResourceCapacity) :
|
||||
0);
|
||||
|
||||
anim = new AnimationWithOffset(a, null, () => IsTraitDisabled, 1024);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence),
|
||||
() => playerResources.ResourceCapacity != 0
|
||||
? ((info.Stages * DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources) / (info.Stages * playerResources.ResourceCapacity)
|
||||
? (info.Stages * DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources / (info.Stages * playerResources.ResourceCapacity)
|
||||
: 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
.Select(ma => ((IModifyableRenderable)ma).WithTint(shadowColor, ((IModifyableRenderable)ma).TintModifiers | TintModifiers.ReplaceColor)
|
||||
.WithAlpha(shadowAlpha)
|
||||
.OffsetBy(info.Offset - new WVec(0, 0, height))
|
||||
.WithZOffset(ma.ZOffset + (height + info.ZOffset))
|
||||
.WithZOffset(ma.ZOffset + height + info.ZOffset)
|
||||
.AsDecoration());
|
||||
|
||||
return shadowSprites.Concat(r);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Cast to long to avoid overflow when multiplying by the health
|
||||
var hp = health != null ? (long)health.Value.HP : 1L;
|
||||
var maxHP = health != null ? (long)health.Value.MaxHP : 1L;
|
||||
var refund = (int)((sellValue * info.RefundPercent * hp) / (100 * maxHP));
|
||||
var refund = (int)(sellValue * info.RefundPercent * hp / (100 * maxHP));
|
||||
|
||||
return "Refund: $" + refund;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (speed > 0)
|
||||
{
|
||||
var nodesDict = t.Value.ToDictionary();
|
||||
var cost = (nodesDict.ContainsKey("PathingCost")
|
||||
var cost = nodesDict.ContainsKey("PathingCost")
|
||||
? FieldLoader.GetValue<short>("cost", nodesDict["PathingCost"].Value)
|
||||
: 10000 / speed);
|
||||
: 10000 / speed;
|
||||
ret.Add(t.Key, new TerrainInfo(speed, (short)cost));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,9 +214,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// All tiles are visible in the editor
|
||||
if (w.Type == WorldType.Editor)
|
||||
cellVisibility = puv => (map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Explored);
|
||||
cellVisibility = puv => map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Explored;
|
||||
else
|
||||
cellVisibility = puv => (map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden);
|
||||
cellVisibility = puv => map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden;
|
||||
|
||||
var shroudBlend = shroudSprites[0].Sprite.BlendMode;
|
||||
if (shroudSprites.Any(s => s.Sprite.BlendMode != shroudBlend))
|
||||
@@ -309,7 +309,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
else
|
||||
{
|
||||
// Visible under shroud: Explored. Visible under fog: Visible.
|
||||
cellVisibility = puv => (map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden);
|
||||
cellVisibility = puv => map.Contains(puv) ? Shroud.CellVisibility.Visible | Shroud.CellVisibility.Explored : Shroud.CellVisibility.Hidden;
|
||||
}
|
||||
|
||||
shroud = newShroud;
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
for (var x = 0; x < template.Size.X; x++)
|
||||
{
|
||||
var tile = new TerrainTile(template.Id, (byte)(i++));
|
||||
var tile = new TerrainTile(template.Id, (byte)i++);
|
||||
if (!terrainInfo.TryGetTileInfo(tile, out var tileInfo))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user