range circles for base defenses

This commit is contained in:
Chris Forbes
2010-03-31 18:00:27 +13:00
parent 9270a85619
commit 939ec0408e
5 changed files with 45 additions and 4 deletions

View File

@@ -339,5 +339,32 @@ namespace OpenRA.Graphics
} }
} }
} }
public void DrawRangeCircle(Actor selectedUnit)
{
if (selectedUnit.Owner != world.LocalPlayer)
return;
var range = (int)selectedUnit.GetPrimaryWeapon().Range;
var r2 = range * range;
var c = Color.FromArgb(128, Color.Yellow);
foreach (var t in world.FindTilesInCircle(selectedUnit.Location, range))
{
if ((selectedUnit.Location - t - new int2(-1, 0)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)),
c,c);
if ((selectedUnit.Location - t - new int2(1, 0)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1,0)), Game.CellSize * (t + new int2(1, 1)),
c,c);
if ((selectedUnit.Location - t - new int2(0,-1)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1,0)),
c,c);
if ((selectedUnit.Location - t - new int2(0,1)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0,1)), Game.CellSize * (t + new int2(1, 1)),
c,c);
}
}
} }
} }

View File

@@ -42,8 +42,12 @@ namespace OpenRA.Orders
public void Render( World world ) public void Render( World world )
{ {
foreach( var a in Game.controller.selection.Actors ) foreach (var a in Game.controller.selection.Actors)
world.WorldRenderer.DrawSelectionBox( a, Color.White, true ); {
world.WorldRenderer.DrawSelectionBox(a, Color.White, true);
if (a.traits.Contains<RenderRangeCircle>())
world.WorldRenderer.DrawRangeCircle(a);
}
} }
public string GetCursor( World world, int2 xy, MouseInput mi ) public string GetCursor( World world, int2 xy, MouseInput mi )

View File

@@ -64,4 +64,7 @@ namespace OpenRA.Traits
} }
} }
} }
class RenderRangeCircleInfo : StatelessTraitInfo<RenderRangeCircle> { }
class RenderRangeCircle { }
} }

View File

@@ -568,6 +568,7 @@ TSLA:
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
-RenderBuilding: -RenderBuilding:
RenderRangeCircle:
AGUN: AGUN:
RequiresPower: RequiresPower:
@@ -598,6 +599,7 @@ AGUN:
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
-RenderBuilding: -RenderBuilding:
RenderRangeCircle:
DOME: DOME:
RequiresPower: RequiresPower:
@@ -1304,6 +1306,7 @@ PBOX:
PrimaryWeapon: Vulcan PrimaryWeapon: Vulcan
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
RenderRangeCircle:
HBOX: HBOX:
Inherits: ^Building Inherits: ^Building
@@ -1324,6 +1327,7 @@ HBOX:
PrimaryWeapon: Vulcan PrimaryWeapon: Vulcan
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
RenderRangeCircle:
GUN: GUN:
Inherits: ^Building Inherits: ^Building
@@ -1349,6 +1353,7 @@ GUN:
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
-RenderBuilding: -RenderBuilding:
RenderRangeCircle:
FTUR: FTUR:
Inherits: ^Building Inherits: ^Building
@@ -1370,6 +1375,7 @@ FTUR:
PrimaryOffset: 0,0,12,8 PrimaryOffset: 0,0,12,8
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
RenderRangeCircle:
SAM: SAM:
Inherits: ^Building Inherits: ^Building
@@ -1397,6 +1403,7 @@ SAM:
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
-RenderBuilding: -RenderBuilding:
RenderRangeCircle:
ATEK: ATEK:
Inherits: ^Building Inherits: ^Building

View File

@@ -37,7 +37,7 @@ technique high_quality {
VertexProgram = compile latest Simple_vp(); VertexProgram = compile latest Simple_vp();
FragmentProgram = compile latest Simple_fp(); FragmentProgram = compile latest Simple_fp();
//SrcBlend = SrcAlpha; BlendEquation = FuncAdd;
//DestBlend = InvSrcAlpha; BlendFunc = int2( SrcAlpha, OneMinusSrcAlpha );
} }
} }