Remove conversions between legacy and world types.

This commit is contained in:
Paul Chote
2014-04-25 23:55:21 +12:00
parent 9487f49cd5
commit a256e722d5
11 changed files with 26 additions and 31 deletions

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Buildings
public readonly int Adjacent = 2;
[Desc("x means space it blocks, _ is a part that is passable by actors.")]
public readonly string Footprint = "x";
public readonly int2 Dimensions = new int2(1, 1);
public readonly CVec Dimensions = new CVec(1, 1);
public readonly bool RequiresBaseProvider = false;
public readonly bool AllowInvalidPlacement = false;
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Buildings
if (RequiresBaseProvider && FindBaseProvider(world, p, topLeft) == null)
return false;
var buildingMaxBounds = (CVec)Dimensions;
var buildingMaxBounds = Dimensions;
var buildingTraits = world.Map.Rules.Actors[buildingName].Traits;
if (buildingTraits.Contains<BibInfo>() && !(buildingTraits.Get<BibInfo>().HasMinibib))
buildingMaxBounds += new CVec(0, 1);

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
[Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")]
public readonly string InitialActivity = null;
[Desc("Offset relative to structure-center in 2D (e.g. 1, 2)")]
public readonly int2 SpawnOffset = int2.Zero;
public readonly CVec SpawnOffset = CVec.Zero;
[Desc("Which direction the unit should face.")]
public readonly int Facing = 0;
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA
var a = w.CreateActor(info.Actor, new TypeDictionary
{
new ParentActorInit(init.self),
new LocationInit(init.self.Location + (CVec)info.SpawnOffset),
new LocationInit(init.self.Location + info.SpawnOffset),
new OwnerInit(init.self.Owner),
new FacingInit(info.Facing),
});

View File

@@ -104,7 +104,7 @@ namespace OpenRA.Mods.RA
var p = end - start;
var q = new float2(p.Y, -p.X);
q = (start != end) ? (1 / q.Length) * q : new float2(1, 0);
var c = -float2.Dot(q, start.ToInt2());
var c = -float2.Dot(q, new float2(start.X, start.Y));
/* return all points such that |ax + by + c| < depth */

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA
{
public class OreRefineryInfo : ITraitInfo
{
public readonly int2 DockOffset = new int2(1, 2);
public readonly CVec DockOffset = new CVec(1, 2);
public readonly bool ShowTicks = true;
public readonly int TickLifetime = 30;
@@ -44,8 +44,7 @@ namespace OpenRA.Mods.RA
[Sync] bool preventDock = false;
public bool AllowDocking { get { return !preventDock; } }
public CVec DeliverOffset { get { return (CVec)Info.DockOffset; } }
public CVec DeliverOffset { get { return Info.DockOffset; } }
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, Info.DockAngle); }

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
class TransformsInfo : ITraitInfo
{
[ActorReference] public readonly string IntoActor = null;
public readonly int2 Offset = int2.Zero;
public readonly CVec Offset = CVec.Zero;
public readonly int Facing = 96;
public readonly string[] TransformSounds = { };
public readonly string[] NoTransformSounds = { };
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA
if (b != null && b.Locked)
return false;
return bi == null || self.World.CanPlaceBuilding(info.IntoActor, bi, self.Location + (CVec)info.Offset, self);
return bi == null || self.World.CanPlaceBuilding(info.IntoActor, bi, self.Location + info.Offset, self);
}
public IEnumerable<IOrderTargeter> Orders
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
if (rb != null && self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation)
self.QueueActivity(new MakeAnimation(self, true, () => rb.PlayCustomAnim(self, "make")));
self.QueueActivity(new Transform(self, info.IntoActor) { Offset = (CVec)info.Offset, Facing = info.Facing, Sounds = info.TransformSounds, Race = race });
self.QueueActivity(new Transform(self, info.IntoActor) { Offset = info.Offset, Facing = info.Facing, Sounds = info.TransformSounds, Race = race });
}
public void ResolveOrder(Actor self, Order order)

View File

@@ -242,18 +242,18 @@ namespace OpenRA.Mods.RA.Widgets
int2 CellToMinimapPixel(CPos p)
{
var viewOrigin = new float2(mapRect.X, mapRect.Y);
var mapOrigin = new CPos(world.Map.Bounds.Left, world.Map.Bounds.Top);
var mapOffset = p - mapOrigin;
return (viewOrigin + previewScale * (p - mapOrigin).ToFloat2()).ToInt2();
return new int2(mapRect.X, mapRect.Y) + (previewScale * new float2(mapOffset.X, mapOffset.Y)).ToInt2();
}
CPos MinimapPixelToCell(int2 p)
{
var viewOrigin = new float2(mapRect.X, mapRect.Y);
var mapOrigin = new CPos(world.Map.Bounds.Left, world.Map.Bounds.Top);
return (CPos)(mapOrigin.ToFloat2() + (1f / previewScale) * (p - viewOrigin)).ToInt2();
var mapOrigin = new float2(world.Map.Bounds.Left, world.Map.Bounds.Top);
var fcell = mapOrigin + (1f / previewScale) * (p - viewOrigin);
return new CPos((int)fcell.X, (int)fcell.Y);
}
}
}