Remove IFogVisibilityModifier.
This commit is contained in:
@@ -61,7 +61,6 @@ namespace OpenRA
|
|||||||
public Shroud Shroud;
|
public Shroud Shroud;
|
||||||
public World World { get; private set; }
|
public World World { get; private set; }
|
||||||
|
|
||||||
readonly IFogVisibilityModifier[] fogVisibilities;
|
|
||||||
readonly StanceColors stanceColors;
|
readonly StanceColors stanceColors;
|
||||||
|
|
||||||
static FactionInfo ChooseFaction(World world, string name, bool requireSelectable = true)
|
static FactionInfo ChooseFaction(World world, string name, bool requireSelectable = true)
|
||||||
@@ -134,8 +133,6 @@ namespace OpenRA
|
|||||||
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
|
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
|
||||||
Shroud = PlayerActor.Trait<Shroud>();
|
Shroud = PlayerActor.Trait<Shroud>();
|
||||||
|
|
||||||
fogVisibilities = PlayerActor.TraitsImplementing<IFogVisibilityModifier>().ToArray();
|
|
||||||
|
|
||||||
// Enable the bot logic on the host
|
// Enable the bot logic on the host
|
||||||
IsBot = BotType != null;
|
IsBot = BotType != null;
|
||||||
if (IsBot && Game.IsHost)
|
if (IsBot && Game.IsHost)
|
||||||
@@ -172,28 +169,9 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool CanTargetActor(Actor a)
|
public bool CanTargetActor(Actor a)
|
||||||
{
|
{
|
||||||
// PERF: Avoid LINQ.
|
|
||||||
if (HasFogVisibility)
|
|
||||||
foreach (var fogVisibility in fogVisibilities)
|
|
||||||
if (fogVisibility.IsVisible(a))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return CanViewActor(a);
|
return CanViewActor(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasFogVisibility
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// PERF: Avoid LINQ.
|
|
||||||
foreach (var fogVisibility in fogVisibilities)
|
|
||||||
if (fogVisibility.HasFogVisibility())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color PlayerStanceColor(Actor a)
|
public Color PlayerStanceColor(Actor a)
|
||||||
{
|
{
|
||||||
var player = a.World.RenderPlayer ?? a.World.LocalPlayer;
|
var player = a.World.RenderPlayer ?? a.World.LocalPlayer;
|
||||||
|
|||||||
@@ -190,12 +190,6 @@ namespace OpenRA.Traits
|
|||||||
public interface IDefaultVisibility { bool IsVisible(Actor self, Player byPlayer); }
|
public interface IDefaultVisibility { bool IsVisible(Actor self, Player byPlayer); }
|
||||||
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
|
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
|
||||||
|
|
||||||
public interface IFogVisibilityModifier
|
|
||||||
{
|
|
||||||
bool IsVisible(Actor actor);
|
|
||||||
bool HasFogVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IOccupySpaceInfo : ITraitInfoInterface
|
public interface IOccupySpaceInfo : ITraitInfoInterface
|
||||||
{
|
{
|
||||||
IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any);
|
IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any);
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Effects;
|
|
||||||
using OpenRA.Mods.Cnc.Effects;
|
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -26,7 +24,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
interface IOnGpsRefreshed { void OnGpsRefresh(Actor self, Player player); }
|
interface IOnGpsRefreshed { void OnGpsRefresh(Actor self, Player player); }
|
||||||
|
|
||||||
class GpsWatcher : ISync, IFogVisibilityModifier
|
class GpsWatcher : ISync, IPreventsShroudReset
|
||||||
{
|
{
|
||||||
[Sync] public bool Launched { get; private set; }
|
[Sync] public bool Launched { get; private set; }
|
||||||
[Sync] public bool GrantedAllies { get; private set; }
|
[Sync] public bool GrantedAllies { get; private set; }
|
||||||
@@ -92,20 +90,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
tp.Trait.OnGpsRefresh(tp.Actor, owner);
|
tp.Trait.OnGpsRefresh(tp.Actor, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasFogVisibility()
|
bool IPreventsShroudReset.PreventShroudReset(Actor self)
|
||||||
{
|
{
|
||||||
return Granted || GrantedAllies;
|
return Granted || GrantedAllies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsVisible(Actor actor)
|
|
||||||
{
|
|
||||||
var gpsDot = actor.TraitOrDefault<GpsDot>();
|
|
||||||
if (gpsDot == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return gpsDot.IsDotVisible(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegisterForOnGpsRefreshed(Actor actor, IOnGpsRefreshed toBeNotified)
|
public void RegisterForOnGpsRefreshed(Actor actor, IOnGpsRefreshed toBeNotified)
|
||||||
{
|
{
|
||||||
notifyOnRefresh.Add(new TraitPair<IOnGpsRefreshed>(actor, toBeNotified));
|
notifyOnRefresh.Add(new TraitPair<IOnGpsRefreshed>(actor, toBeNotified));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -22,7 +23,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
||||||
{
|
{
|
||||||
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
|
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
|
||||||
if (!self.Owner.HasFogVisibility)
|
var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
|
||||||
|
.Any(p => p.PreventShroudReset(self));
|
||||||
|
if (!preventReset)
|
||||||
self.Owner.Shroud.ResetExploration();
|
self.Owner.Shroud.ResetExploration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Hides the entire map in shroud.")]
|
[Desc("Hides the entire map in shroud.")]
|
||||||
@@ -33,7 +35,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override int GetSelectionShares(Actor collector)
|
public override int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
// Don't hide the map if the shroud is force-revealed
|
// Don't hide the map if the shroud is force-revealed
|
||||||
if (collector.Owner.HasFogVisibility || collector.Owner.Shroud.ExploreMapEnabled)
|
var preventReset = collector.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
|
||||||
|
.Any(p => p.PreventShroudReset(collector.Owner.PlayerActor));
|
||||||
|
if (preventReset || collector.Owner.Shroud.ExploreMapEnabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return base.GetSelectionShares(collector);
|
return base.GetSelectionShares(collector);
|
||||||
|
|||||||
@@ -382,4 +382,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
IEnumerable<Pair<CPos, SubCell>> TargetableCells();
|
IEnumerable<Pair<CPos, SubCell>> TargetableCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RequireExplicitImplementation]
|
||||||
|
public interface IPreventsShroudReset { bool PreventShroudReset(Actor self); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user