New types for cell and pixel coordinate position/vectors.

This commit is contained in:
James Dunne
2012-06-20 23:22:27 -05:00
parent 0b98a8ce5e
commit 9c49143534
162 changed files with 1291 additions and 865 deletions

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Mods.Cnc
readonly RenderUnit ru;
State state;
int2 startDock;
int2 endDock;
PPos startDock;
PPos endDock;
public HarvesterDockSequence(Actor self, Actor proc)
{
this.proc = proc;
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Cnc
harv = self.Trait<Harvester>();
ru = self.Trait<RenderUnit>();
startDock = self.Trait<IHasLocation>().PxPosition;
endDock = proc.Trait<IHasLocation>().PxPosition + new int2(-15,8);
endDock = proc.Trait<IHasLocation>().PxPosition + new PVecInt(-15,8);
}
public override Activity Tick(Actor self)

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Cnc.Effects
Animation anim;
Actor firedBy;
public IonCannon(Actor firedBy, World world, int2 location)
public IonCannon(Actor firedBy, World world, CPos location)
{
this.firedBy = firedBy;
target = Target.FromCell(location);
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Effects
public IEnumerable<Renderable> Render()
{
yield return new Renderable(anim.Image,
target.CenterLocation - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
target.CenterLocation.ToFloat2() - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
"effect", (int)target.CenterLocation.Y);
}

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc
{
self.World.AddFrameEndTask(w =>
{
Sound.Play(Info.LaunchSound, Game.CellSize * order.TargetLocation.ToFloat2());
Sound.Play(Info.LaunchSound, order.TargetLocation.ToPPos());
w.Add(new IonCannon(self, w, order.TargetLocation));
});
}

View File

@@ -22,13 +22,13 @@ namespace OpenRA.Mods.RA
class CncShellmapScript: IWorldLoaded, ITick
{
Dictionary<string, Actor> Actors;
static int2 ViewportOrigin;
static CPos ViewportOrigin;
public void WorldLoaded(World w)
{
var b = w.Map.Bounds;
ViewportOrigin = new int2(b.Left + b.Width/2, b.Top + b.Height/2);
Game.MoveViewport(ViewportOrigin);
ViewportOrigin = new CPos(b.Left + b.Width/2, b.Top + b.Height/2);
Game.MoveViewport(ViewportOrigin.ToFloat2());
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA
void SetViewport()
{
var t = (ticks + 45) % (360f * speed) * (Math.PI / 180) * 1f / speed;
var loc = ViewportOrigin + new float2(-15,4) * float2.FromAngle( (float)t );
var loc = ViewportOrigin.ToFloat2() + (new float2(-15,4) * float2.FromAngle( (float)t ));
Game.viewport.Center(loc);
}
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA
}));
}
void LoopTrack(Actor self, int2 left, int2 right)
void LoopTrack(Actor self, CPos left, CPos right)
{
var mobile = self.Trait<Mobile>();
self.QueueActivity(mobile.ScriptedMove(left));

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc
Players = w.Players.ToDictionary(p => p.InternalName);
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
var b = w.Map.Bounds;
Game.MoveViewport(new int2(b.Left + b.Width/2, b.Top + b.Height/2));
Game.MoveViewport(new CPos(b.Left + b.Width/2, b.Top + b.Height/2).ToFloat2());
Scripting.Media.PlayFMVFullscreen(w, "gdi1.vqa",
() => Scripting.Media.PlayFMVFullscreen(w, "landing.vqa", () =>
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Cnc
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new CPos(53, 53),
new string[] {"e1","e1","e1"},
Players["GoodGuy"]);
}
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Cnc
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new CPos(53, 53),
new string[] {"e1","e1","e1"},
Players["GoodGuy"]);
}
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Cnc
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new CPos(53, 53),
new string[] {"jeep"},
Players["GoodGuy"]);
}
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.Cnc
ReinforceFromSea(self.World,
Actors["lstStart"].Location,
Actors["lstEnd"].Location,
new int2(53,53),
new CPos(53, 53),
new string[] {"jeep"},
Players["GoodGuy"]);
}
@@ -177,7 +177,7 @@ namespace OpenRA.Mods.Cnc
self.QueueActivity(new CallFunc(() => SetGunboatPath()));
}
void ReinforceFromSea(World world, int2 startPos, int2 endPos, int2 unload, string[] items, Player player)
void ReinforceFromSea(World world, CPos startPos, CPos endPos, CPos unload, string[] items, Player player)
{
world.AddFrameEndTask(w =>
{

View File

@@ -36,8 +36,8 @@ namespace OpenRA.Mods.Cnc
// Start a fixed distance away: the width of the map.
// This makes the production timing independent of spawnpoint
var startPos = self.Location + new int2(owner.World.Map.Bounds.Width, 0);
var endPos = new int2(owner.World.Map.Bounds.Left - 5, self.Location.Y);
var startPos = self.Location + new CVec(owner.World.Map.Bounds.Width, 0);
var endPos = new CPos(owner.World.Map.Bounds.Left - 5, self.Location.Y);
// Assume a single exit point for simplicity
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Cnc
new AltitudeInit( Rules.Info[actorType].Traits.Get<PlaneInfo>().CruiseAltitude ),
});
a.QueueActivity(Fly.ToCell(self.Location + new int2(6,0)));
a.QueueActivity(Fly.ToCell(self.Location + new CVec(6, 0)));
a.QueueActivity(new Land(Target.FromActor(self)));
a.QueueActivity(new CallFunc(() =>
{

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public void UpdateMouseover()
{
TooltipType = WorldTooltipType.None;
var cell = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();
var cell = Game.viewport.ViewToWorld(Viewport.LastMousePos);
if (!world.Map.IsInMap(cell))
return;