give Gap Generator to allies
This commit is contained in:
committed by
Chris Forbes
parent
beb6b01796
commit
891cba456b
@@ -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>
|
||||
@@ -150,6 +150,7 @@
|
||||
<Compile Include="TraitDictionary.cs" />
|
||||
<Compile Include="Traits\Activity.cs" />
|
||||
<Compile Include="Traits\Armor.cs" />
|
||||
<Compile Include="Traits\CreatesShroud.cs" />
|
||||
<Compile Include="Traits\DrawLineToTarget.cs" />
|
||||
<Compile Include="Traits\EditorAppearance.cs" />
|
||||
<Compile Include="Traits\EditorTilesetFilter.cs" />
|
||||
@@ -240,4 +241,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
36
OpenRA.Game/Traits/CreatesShroud.cs
Normal file
36
OpenRA.Game/Traits/CreatesShroud.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class CreatesShroudInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Range = 0;
|
||||
public object Create(ActorInitializer init) { return new CreatesShroud(this); }
|
||||
}
|
||||
|
||||
class CreatesShroud : ITick
|
||||
{
|
||||
CreatesShroudInfo Info;
|
||||
|
||||
public CreatesShroud(CreatesShroudInfo info)
|
||||
{
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (!self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
|
||||
self.World.WorldActor.Trait<Shroud>().HideActor(self, Info.Range);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,6 +112,24 @@ namespace OpenRA.Traits
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public void HideActor(Actor a, int range)
|
||||
{
|
||||
if (a.Owner.World.LocalPlayer == null
|
||||
|| a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally) return;
|
||||
|
||||
var v = new ActorVisibility
|
||||
{
|
||||
vis = GetVisOrigins(a).ToArray()
|
||||
};
|
||||
|
||||
foreach (var p in v.vis)
|
||||
foreach (var q in FindVisibleTiles(a.World, p, range))
|
||||
exploredCells[q.X, q.Y] = visibleCells[q.X, q.Y] > 0;
|
||||
|
||||
if (!Disabled)
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public void UpdatePlayerStance(World w, Player player, Stance oldStance, Stance newStance)
|
||||
{
|
||||
if (oldStance == newStance)
|
||||
|
||||
Reference in New Issue
Block a user