Move initial map exploration to Shroud.

This commit is contained in:
Paul Chote
2016-04-20 00:00:26 -04:00
parent dade84db85
commit a0b5b5ce66
5 changed files with 14 additions and 12 deletions

View File

@@ -107,7 +107,7 @@ namespace OpenRA.Traits
if (EnableAll)
{
self.Owner.Shroud.ExploreAll(self.World);
self.Owner.Shroud.ExploreAll();
var amount = order.ExtraData != 0 ? (int)order.ExtraData : info.Cash;
self.Trait<PlayerResources>().GiveCash(amount);
@@ -177,7 +177,7 @@ namespace OpenRA.Traits
case "DevGiveExploration":
{
self.Owner.Shroud.ExploreAll(self.World);
self.Owner.Shroud.ExploreAll();
break;
}

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Traits
public object Create(ActorInitializer init) { return new Shroud(init.Self); }
}
public class Shroud : ISync
public class Shroud : ISync, INotifyCreated
{
public event Action<IEnumerable<PPos>> CellsChanged;
@@ -79,6 +79,12 @@ namespace OpenRA.Traits
explored = new CellLayer<bool>(map);
}
void INotifyCreated.Created(Actor self)
{
if (!self.World.LobbyInfo.GlobalSettings.Shroud)
self.World.AddFrameEndTask(w => ExploreAll());
}
void Invalidate(IEnumerable<PPos> changed)
{
if (CellsChanged != null)
@@ -241,7 +247,7 @@ namespace OpenRA.Traits
Invalidate(changed);
}
public void ExploreAll(World world)
public void ExploreAll()
{
var changed = new List<PPos>();
foreach (var puv in map.ProjectedCellBounds)

View File

@@ -184,10 +184,6 @@ namespace OpenRA
MapUid = Map.Uid,
MapTitle = Map.Title
};
if (!LobbyInfo.GlobalSettings.Shroud)
foreach (var player in Players)
player.Shroud.ExploreAll(this);
}
public void AddToMaps(Actor self, IOccupySpace ios)

View File

@@ -36,10 +36,10 @@ namespace OpenRA.Mods.Common.Traits
{
foreach (var player in collector.World.Players)
if (collector.Owner.IsAlliedWith(player))
player.Shroud.ExploreAll(player.World);
player.Shroud.ExploreAll();
}
else
collector.Owner.Shroud.ExploreAll(collector.World);
collector.Owner.Shroud.ExploreAll();
base.Activate(collector);
}

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA.Traits
i.Trait.RefreshGranted();
if ((Granted || GrantedAllies) && atek.Owner.IsAlliedWith(owner))
atek.Owner.Shroud.ExploreAll(atek.World);
atek.Owner.Shroud.ExploreAll();
}
void RefreshGranted()
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA.Traits
GrantedAllies = owner.World.ActorsHavingTrait<GpsWatcher>(g => g.Granted).Any(p => p.Owner.IsAlliedWith(owner));
if (Granted || GrantedAllies)
owner.Shroud.ExploreAll(owner.World);
owner.Shroud.ExploreAll();
if (wasGranted != Granted || wasGrantedAllies != GrantedAllies)
foreach (var tp in notifyOnRefresh.ToList())