Skip shroud/fog calculations when both are disabled via lobby option.

This commit is contained in:
reaperrr
2015-03-19 00:06:37 +01:00
parent dc3f82f537
commit 4fc58b4491
2 changed files with 16 additions and 4 deletions

View File

@@ -15,22 +15,28 @@ namespace OpenRA.Traits
public class CreatesShroudInfo : ITraitInfo
{
public readonly WRange Range = WRange.Zero;
public object Create(ActorInitializer init) { return new CreatesShroud(this); }
public object Create(ActorInitializer init) { return new CreatesShroud(init.Self, this); }
}
public class CreatesShroud : ITick, ISync
{
readonly CreatesShroudInfo info;
readonly bool lobbyShroudFogDisabled;
[Sync] CPos cachedLocation;
[Sync] bool cachedDisabled;
public CreatesShroud(CreatesShroudInfo info)
public CreatesShroud(Actor self, CreatesShroudInfo info)
{
this.info = info;
lobbyShroudFogDisabled = !self.World.LobbyInfo.GlobalSettings.Shroud && !self.World.LobbyInfo.GlobalSettings.Fog;
}
public void Tick(Actor self)
{
if (lobbyShroudFogDisabled)
return;
var disabled = self.TraitsImplementing<IDisable>().Any(d => d.Disabled);
if (cachedLocation != self.Location || cachedDisabled != disabled)
{

View File

@@ -15,21 +15,27 @@ namespace OpenRA.Traits
public class RevealsShroudInfo : ITraitInfo
{
public readonly WRange Range = WRange.Zero;
public object Create(ActorInitializer init) { return new RevealsShroud(this); }
public object Create(ActorInitializer init) { return new RevealsShroud(init.Self, this); }
}
public class RevealsShroud : ITick, ISync
{
readonly RevealsShroudInfo info;
readonly bool lobbyShroudFogDisabled;
[Sync] CPos cachedLocation;
public RevealsShroud(RevealsShroudInfo info)
public RevealsShroud(Actor self, RevealsShroudInfo info)
{
this.info = info;
lobbyShroudFogDisabled = !self.World.LobbyInfo.GlobalSettings.Shroud && !self.World.LobbyInfo.GlobalSettings.Fog;
}
public void Tick(Actor self)
{
if (lobbyShroudFogDisabled)
return;
if (cachedLocation != self.Location)
{
cachedLocation = self.Location;