reinstate range circles; IRenderSelection allows arb. plugging in of these things
This commit is contained in:
47
OpenRA.Mods.RA/DetectCloaked.cs
Normal file
47
OpenRA.Mods.RA/DetectCloaked.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#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;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="AttackBase.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="ConstructionYard.cs" />
|
||||
<Compile Include="DetectCloaked.cs" />
|
||||
<Compile Include="Effects\Bullet.cs" />
|
||||
<Compile Include="Effects\Explosion.cs" />
|
||||
<Compile Include="Effects\GravityBomb.cs" />
|
||||
@@ -91,6 +92,8 @@
|
||||
<Compile Include="LimitedAmmo.cs" />
|
||||
<Compile Include="Player\ActorGroupProxy.cs" />
|
||||
<Compile Include="Aircraft.cs" />
|
||||
<Compile Include="RenderDetectionCircle.cs" />
|
||||
<Compile Include="RenderRangeCircle.cs" />
|
||||
<Compile Include="Render\RenderBuilding.cs" />
|
||||
<Compile Include="Render\RenderBuildingTurreted.cs" />
|
||||
<Compile Include="Render\RenderUnit.cs" />
|
||||
@@ -232,6 +235,9 @@
|
||||
<Name>OpenRA.Game</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Chrome\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
@@ -246,8 +252,4 @@ copy "$(TargetPath)" "$(SolutionDir)mods/ra/"
|
||||
cd "$(SolutionDir)"
|
||||
ralint ra</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Widgets\" />
|
||||
<Folder Include="Widgets\Delegates\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
26
OpenRA.Mods.RA/RenderDetectionCircle.cs
Normal file
26
OpenRA.Mods.RA/RenderDetectionCircle.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
#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.Drawing;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderDetectionCircleInfo : TraitInfo<RenderDetectionCircle> { }
|
||||
class RenderDetectionCircle : IRenderSelection
|
||||
{
|
||||
public void Render(Actor self)
|
||||
{
|
||||
self.World.WorldRenderer.DrawRangeCircle(
|
||||
Color.FromArgb(128, Color.LimeGreen),
|
||||
self.CenterLocation, self.Info.Traits.Get<DetectCloakedInfo>().Range);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
OpenRA.Mods.RA/RenderRangeCircle.cs
Normal file
26
OpenRA.Mods.RA/RenderRangeCircle.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
#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.Drawing;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle> { }
|
||||
class RenderRangeCircle : IRenderSelection
|
||||
{
|
||||
public void Render(Actor self)
|
||||
{
|
||||
self.World.WorldRenderer.DrawRangeCircle(
|
||||
Color.FromArgb(128, Color.Yellow),
|
||||
self.CenterLocation, (int)self.GetPrimaryWeapon().Range);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user