Merge pull request #8691 from Mailaender/wrange-renamings

Renamed WRange to WDist in the Lua API and documentation
This commit is contained in:
Oliver Brakmann
2015-07-09 23:03:45 +02:00
24 changed files with 51 additions and 38 deletions

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Activities
var diff = new WVec(radius, radius, WDist.Zero);
var candidates = self.World.ActorMap.ActorsInBox(self.CenterPosition - diff, self.CenterPosition + diff)
.Where(primaryFilter).Select(a => new { Actor = a, Ls = (self.CenterPosition - a.CenterPosition).HorizontalLengthSquared })
.Where(p => p.Ls <= radius.RangeSquared).OrderBy(p => p.Ls).Select(p => p.Actor);
.Where(p => p.Ls <= radius.LengthSquared).OrderBy(p => p.Ls).Select(p => p.Actor);
if (preferenceFilters != null)
foreach (var filter in preferenceFilters)
{

View File

@@ -48,8 +48,8 @@ namespace OpenRA.Mods.Common.Activities
var maxCells = (maxRange.Length + 1023) / 1024;
var minCells = minRange.Length / 1024;
var outerSq = maxRange.RangeSquared;
var innerSq = minRange.RangeSquared;
var outerSq = maxRange.LengthSquared;
var innerSq = minRange.LengthSquared;
var center = Target.CenterPosition;
return map.FindTilesInAnnulus(targetPosition, minCells + 1, maxCells).Where(c =>

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Effects
{
public class BulletInfo : IProjectileInfo
{
[Desc("Projectile speed in WRange / tick, two values indicate variable velocity.")]
[Desc("Projectile speed in WDist / tick, two values indicate variable velocity.")]
public readonly WDist[] Speed = { new WDist(17) };
[Desc("Maximum offset at the maximum range.")]
public readonly WDist Inaccuracy = WDist.Zero;

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Effects
[SequenceReference("Image")] public readonly string Sequence = "idle";
public readonly string Palette = "effect";
public readonly bool Shadow = false;
[Desc("Projectile speed in WRange / tick")]
[Desc("Projectile speed in WDist / tick")]
public readonly WDist Speed = new WDist(8);
[Desc("Maximum vertical pitch when changing altitude.")]
public readonly WAngle MaximumPitch = WAngle.FromDegrees(30);
@@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Effects
var cell = world.Map.CellContaining(pos);
var shouldExplode = (pos.Z < 0) // Hit the ground
|| (dist.LengthSquared < info.CloseEnough.RangeSquared) // Within range
|| (dist.LengthSquared < info.CloseEnough.LengthSquared) // Within range
|| (info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel
|| (info.Blockable && world.ActorMap.GetUnitsAt(cell).Any(a => a.HasTrait<IBlocksProjectiles>())) // Hit a wall or other blocking obstacle
|| !world.Map.Contains(cell) // This also avoids an IndexOutOfRangeException in GetTerrainInfo below.

View File

@@ -59,15 +59,27 @@ namespace OpenRA.Mods.Common.Scripting
public WVec Zero { get { return WVec.Zero; } }
}
[ScriptGlobal("WDist")]
public class WDistGlobal : ScriptGlobal
{
public WDistGlobal(ScriptContext context) : base(context) { }
[Desc("Create a new WDist.")]
public WDist New(int r) { return new WDist(r); }
[Desc("Create a new WDist by cell distance")]
public WDist FromCells(int numCells) { return WDist.FromCells(numCells); }
}
[ScriptGlobal("WRange")]
public class WRangeGlobal : ScriptGlobal
{
public WRangeGlobal(ScriptContext context) : base(context) { }
[Desc("Create a new WRange.")]
public WDist New(int r) { return new WDist(r); }
[Desc("Create a new WRange. DEPRECATED! Will be removed.")]
public WDist New(int r) { Game.Debug("WRange is deprecated. Use WDist instead."); return new WDist(r); }
[Desc("Create a new WRange by cell distance")]
public WDist FromCells(int numCells) { return WDist.FromCells(numCells); }
[Desc("Create a new WRange by cell distance. DEPRECATED! Will be removed.")]
public WDist FromCells(int numCells) { Game.Debug("WRange is deprecated. Use WDist instead."); return WDist.FromCells(numCells); }
}
}

View File

@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits
var d = self.CenterPosition - other.CenterPosition;
var distSq = d.HorizontalLengthSquared;
if (distSq > info.IdealSeparation.RangeSquared)
if (distSq > info.IdealSeparation.LengthSquared)
return WVec.Zero;
if (distSq < 1)

View File

@@ -268,7 +268,7 @@ namespace OpenRA.Mods.Common.Traits
if (modifiers.HasModifier(TargetModifiers.ForceAttack))
{
var targetRange = (self.World.Map.CenterOfCell(location) - self.CenterPosition).HorizontalLengthSquared;
if (targetRange > ab.GetMaximumRange().RangeSquared)
if (targetRange > ab.GetMaximumRange().LengthSquared)
cursor = ab.Info.OutsideRangeCursor;
return true;

View File

@@ -144,7 +144,7 @@ namespace OpenRA.Mods.Common.Traits
return;
var targetCell = self.World.Map.CellContaining(target.CenterPosition);
if ((self.CenterPosition - target.CenterPosition).LengthSquared < transport.MinimumDistance.RangeSquared)
if ((self.CenterPosition - target.CenterPosition).LengthSquared < transport.MinimumDistance.LengthSquared)
return;
transport.RequestTransport(targetCell, nextActivity);

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Travel time - split equally between ascent and descent")]
public readonly int FlightDelay = 400;
[Desc("Visual ascent velocity in WRange / tick")]
[Desc("Visual ascent velocity in WDist / tick")]
public readonly WDist FlightVelocity = new WDist(512);
[Desc("Descend immediately on the target, with half the FlightDelay")]

View File

@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Traits
public void UnitProducedByOther(Actor self, Actor producer, Actor produced)
{
// Work around for actors produced within the region not triggering until the second tick
if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= info.Range.RangeSquared)
if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= info.Range.LengthSquared)
{
var stance = self.Owner.Stances[produced.Owner];
if (!info.ValidStances.HasFlag(stance))

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
// Select only the tiles that are within range from the requested SubCell
// This assumes that the SubCell does not change during the path traversal
var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Length / 1024 + 1)
.Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= range.RangeSquared
.Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= range.LengthSquared
&& mi.CanEnterCell(self.World as World, self as Actor, t));
// See if there is any cell within range that does not involve a cross-domain request

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Warheads
continue;
// If the impact position is within any actor's health radius, we have a direct hit
if ((unit.CenterPosition - pos).LengthSquared <= healthInfo.Radius.RangeSquared)
if ((unit.CenterPosition - pos).LengthSquared <= healthInfo.Radius.LengthSquared)
return true;
}