reinstate range circles; IRenderSelection allows arb. plugging in of these things
This commit is contained in:
@@ -37,26 +37,11 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLine(start,end,startColor,endColor);
|
||||
}
|
||||
|
||||
public int GetPaletteIndex(string name)
|
||||
{
|
||||
return palette.GetPaletteIndex(name);
|
||||
}
|
||||
|
||||
public Palette GetPalette(string name)
|
||||
{
|
||||
return palette.GetPalette(name);
|
||||
}
|
||||
|
||||
public void AddPalette(string name, Palette pal)
|
||||
{
|
||||
palette.AddPalette(name, pal);
|
||||
}
|
||||
|
||||
public void UpdatePalette(string name, Palette pal)
|
||||
{
|
||||
palette.UpdatePalette(name, pal);
|
||||
}
|
||||
public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); }
|
||||
public Palette GetPalette(string name) { return palette.GetPalette(name); }
|
||||
public void AddPalette(string name, Palette pal) { palette.AddPalette(name, pal); }
|
||||
public void UpdatePalette(string name, Palette pal) { palette.UpdatePalette(name, pal); }
|
||||
|
||||
void DrawSpriteList(IEnumerable<Renderable> images)
|
||||
{
|
||||
@@ -369,7 +354,7 @@ namespace OpenRA.Graphics
|
||||
var prev = location + Game.CellSize * range * float2.FromAngle(0);
|
||||
for (var i = 1; i <= 32; i++)
|
||||
{
|
||||
var pos = location + Game.CellSize * range * float2.FromAngle((float)(Math.PI * i) / 8);
|
||||
var pos = location + Game.CellSize * range * float2.FromAngle((float)(Math.PI * i) / 16);
|
||||
Game.Renderer.LineRenderer.DrawLine(prev, pos, c, c);
|
||||
prev = pos;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -81,7 +81,6 @@
|
||||
<Compile Include="Orders\GenericSelectTarget.cs" />
|
||||
<Compile Include="Server\ProtocolVersion.cs" />
|
||||
<Compile Include="Traits\BaseBuilding.cs" />
|
||||
<Compile Include="Traits\DetectCloaked.cs" />
|
||||
<Compile Include="Traits\LintAttributes.cs" />
|
||||
<Compile Include="Traits\Modifiers\FrozenUnderFog.cs" />
|
||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||
|
||||
@@ -41,15 +41,8 @@ namespace OpenRA.Orders
|
||||
{
|
||||
world.WorldRenderer.DrawSelectionBox(a, Color.White, true);
|
||||
if (a.Owner == world.LocalPlayer)
|
||||
{
|
||||
//if (a.traits.Contains<RenderRangeCircle>())
|
||||
// world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
|
||||
// a.CenterLocation, (int)a.GetPrimaryWeapon().Range);
|
||||
|
||||
if (a.traits.Contains<DetectCloaked>())
|
||||
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.LimeGreen),
|
||||
a.CenterLocation, a.Info.Traits.Get<DetectCloakedInfo>().Range);
|
||||
}
|
||||
foreach (var t in a.traits.WithInterface<IRenderSelection>())
|
||||
t.Render(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class DetectCloakedInfo : TraitInfo<DetectCloaked>
|
||||
{
|
||||
public readonly int Interval = 12; // ~.5s
|
||||
public readonly float DecloakTime = 2f; // 2s
|
||||
public readonly int Range = 5;
|
||||
public readonly bool AffectOwnUnits = true;
|
||||
}
|
||||
|
||||
class DetectCloaked : ITick
|
||||
{
|
||||
[Sync] int ticks;
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
var info = self.Info.Traits.Get<DetectCloakedInfo>();
|
||||
ticks = info.Interval;
|
||||
|
||||
var toDecloak = self.World.FindUnitsInCircle(self.CenterLocation, info.Range * Game.CellSize)
|
||||
.Where(a => a.traits.Contains<Cloak>());
|
||||
|
||||
if (!info.AffectOwnUnits)
|
||||
toDecloak = toDecloak.Where(a => self.Owner.Stances[a.Owner] != Stance.Ally);
|
||||
|
||||
foreach (var a in toDecloak)
|
||||
a.traits.Get<Cloak>().Decloak((int)(25 * info.DecloakTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle> { }
|
||||
class RenderRangeCircle { }
|
||||
}
|
||||
@@ -166,6 +166,8 @@ namespace OpenRA.Traits
|
||||
public interface IVictoryConditions { }
|
||||
public interface IBlocksBullets { }
|
||||
|
||||
public interface IRenderSelection { void Render(Actor self); }
|
||||
|
||||
public struct Target // a target: either an actor, or a fixed location.
|
||||
{
|
||||
Actor actor;
|
||||
|
||||
Reference in New Issue
Block a user