Move initial map exploration to Shroud.
This commit is contained in:
@@ -107,7 +107,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
if (EnableAll)
|
if (EnableAll)
|
||||||
{
|
{
|
||||||
self.Owner.Shroud.ExploreAll(self.World);
|
self.Owner.Shroud.ExploreAll();
|
||||||
|
|
||||||
var amount = order.ExtraData != 0 ? (int)order.ExtraData : info.Cash;
|
var amount = order.ExtraData != 0 ? (int)order.ExtraData : info.Cash;
|
||||||
self.Trait<PlayerResources>().GiveCash(amount);
|
self.Trait<PlayerResources>().GiveCash(amount);
|
||||||
@@ -177,7 +177,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
case "DevGiveExploration":
|
case "DevGiveExploration":
|
||||||
{
|
{
|
||||||
self.Owner.Shroud.ExploreAll(self.World);
|
self.Owner.Shroud.ExploreAll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Traits
|
|||||||
public object Create(ActorInitializer init) { return new Shroud(init.Self); }
|
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;
|
public event Action<IEnumerable<PPos>> CellsChanged;
|
||||||
|
|
||||||
@@ -79,6 +79,12 @@ namespace OpenRA.Traits
|
|||||||
explored = new CellLayer<bool>(map);
|
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)
|
void Invalidate(IEnumerable<PPos> changed)
|
||||||
{
|
{
|
||||||
if (CellsChanged != null)
|
if (CellsChanged != null)
|
||||||
@@ -241,7 +247,7 @@ namespace OpenRA.Traits
|
|||||||
Invalidate(changed);
|
Invalidate(changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExploreAll(World world)
|
public void ExploreAll()
|
||||||
{
|
{
|
||||||
var changed = new List<PPos>();
|
var changed = new List<PPos>();
|
||||||
foreach (var puv in map.ProjectedCellBounds)
|
foreach (var puv in map.ProjectedCellBounds)
|
||||||
|
|||||||
@@ -184,10 +184,6 @@ namespace OpenRA
|
|||||||
MapUid = Map.Uid,
|
MapUid = Map.Uid,
|
||||||
MapTitle = Map.Title
|
MapTitle = Map.Title
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!LobbyInfo.GlobalSettings.Shroud)
|
|
||||||
foreach (var player in Players)
|
|
||||||
player.Shroud.ExploreAll(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddToMaps(Actor self, IOccupySpace ios)
|
public void AddToMaps(Actor self, IOccupySpace ios)
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
foreach (var player in collector.World.Players)
|
foreach (var player in collector.World.Players)
|
||||||
if (collector.Owner.IsAlliedWith(player))
|
if (collector.Owner.IsAlliedWith(player))
|
||||||
player.Shroud.ExploreAll(player.World);
|
player.Shroud.ExploreAll();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
collector.Owner.Shroud.ExploreAll(collector.World);
|
collector.Owner.Shroud.ExploreAll();
|
||||||
|
|
||||||
base.Activate(collector);
|
base.Activate(collector);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
i.Trait.RefreshGranted();
|
i.Trait.RefreshGranted();
|
||||||
|
|
||||||
if ((Granted || GrantedAllies) && atek.Owner.IsAlliedWith(owner))
|
if ((Granted || GrantedAllies) && atek.Owner.IsAlliedWith(owner))
|
||||||
atek.Owner.Shroud.ExploreAll(atek.World);
|
atek.Owner.Shroud.ExploreAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshGranted()
|
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));
|
GrantedAllies = owner.World.ActorsHavingTrait<GpsWatcher>(g => g.Granted).Any(p => p.Owner.IsAlliedWith(owner));
|
||||||
|
|
||||||
if (Granted || GrantedAllies)
|
if (Granted || GrantedAllies)
|
||||||
owner.Shroud.ExploreAll(owner.World);
|
owner.Shroud.ExploreAll();
|
||||||
|
|
||||||
if (wasGranted != Granted || wasGrantedAllies != GrantedAllies)
|
if (wasGranted != Granted || wasGrantedAllies != GrantedAllies)
|
||||||
foreach (var tp in notifyOnRefresh.ToList())
|
foreach (var tp in notifyOnRefresh.ToList())
|
||||||
|
|||||||
Reference in New Issue
Block a user