Introducing per-player shrouds.
- Each player has their own shroud and their visibility does not extend outside of the shroud. - Units and buildings can no longer target other units outside of their visibility. Buildings can still be targetted if they have been explored. - GPS will provide visibility in the fog-of-war. - Spies that infiltrate radar domes will gain their victim's exploration and reset it on all clients (if the victim does not have GPS)
This commit is contained in:
@@ -45,9 +45,8 @@ namespace OpenRA.Mods.RA
|
||||
var targetCell = target.Location + (order.TargetLocation - order.ExtraLocation);
|
||||
var cpi = Info as ChronoshiftPowerInfo;
|
||||
|
||||
if (cs.CanChronoshiftTo(target, targetCell, true))
|
||||
cs.Teleport(target, targetCell,
|
||||
cpi.Duration * 25, cpi.KillCargo, self);
|
||||
if (self.Owner.Shroud.IsExplored(targetCell) && cs.CanChronoshiftTo(target, targetCell))
|
||||
cs.Teleport(target, targetCell, cpi.Duration * 25, cpi.KillCargo, self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +60,48 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
return units.Distinct().Where(a => a.HasTrait<Chronoshiftable>());
|
||||
}
|
||||
|
||||
|
||||
public bool SimilarTerrain(CPos xy, CPos sourceLocation) {
|
||||
|
||||
if (!self.Owner.Shroud.IsExplored(xy))
|
||||
return false;
|
||||
|
||||
int range = (Info as ChronoshiftPowerInfo).Range;
|
||||
var sourceTiles = self.World.FindTilesInCircle(xy, range);
|
||||
var destTiles = self.World.FindTilesInCircle(sourceLocation, range);
|
||||
List<string> sourceTerrain = new List<string>();
|
||||
List<string> destTerrain = new List<string>();
|
||||
|
||||
int j = 0;
|
||||
foreach (var t in sourceTiles) {
|
||||
j = j + 1;
|
||||
if (!self.Owner.Shroud.IsExplored(t))
|
||||
return false;
|
||||
sourceTerrain.Add(self.World.GetTerrainType( t ));
|
||||
}
|
||||
j = 0;
|
||||
foreach (var t in destTiles) {
|
||||
j = j + 1;
|
||||
if (!self.Owner.Shroud.IsExplored(t)) {
|
||||
return false;
|
||||
}
|
||||
self.World.GetTerrainType( t );
|
||||
destTerrain.Add(self.World.GetTerrainType( t ));
|
||||
}
|
||||
|
||||
// HACK but I don't want to write a comparison function
|
||||
if (sourceTerrain.Count != destTerrain.Count)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < sourceTerrain.Count; i++) {
|
||||
if (!sourceTerrain[i].Equals(destTerrain[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
class SelectTarget : IOrderGenerator
|
||||
{
|
||||
@@ -99,8 +140,11 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var targetUnits = power.UnitsInRange(xy);
|
||||
foreach (var unit in targetUnits)
|
||||
wr.DrawSelectionBox(unit, Color.Red);
|
||||
foreach (var unit in targetUnits) {
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility()) {
|
||||
wr.DrawSelectionBox(unit, Color.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world)
|
||||
@@ -175,8 +219,11 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world)
|
||||
{
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||
wr.DrawSelectionBox(unit, Color.Red);
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation)) {
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility()) {
|
||||
wr.DrawSelectionBox(unit, Color.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world)
|
||||
@@ -194,20 +241,24 @@ namespace OpenRA.Mods.RA
|
||||
// Unit previews
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||
{
|
||||
var targetCell = unit.Location + (xy - sourceLocation);
|
||||
foreach (var r in unit.Render())
|
||||
r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location).ToFloat2() + Traits.Util.CenterOfCell(targetCell).ToFloat2(),
|
||||
wr.GetPaletteIndex(r.Palette),
|
||||
r.Scale*r.Sprite.size);
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit)) {
|
||||
var targetCell = unit.Location + (xy - sourceLocation);
|
||||
foreach (var r in unit.Render())
|
||||
r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location).ToFloat2() + Traits.Util.CenterOfCell(targetCell).ToFloat2(),
|
||||
wr.GetPaletteIndex(r.Palette),
|
||||
r.Scale*r.Sprite.size);
|
||||
}
|
||||
}
|
||||
|
||||
// Unit tiles
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||
{
|
||||
var targetCell = unit.Location + (xy - sourceLocation);
|
||||
var canEnter = unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell, false);
|
||||
var tile = canEnter ? validTile : invalidTile;
|
||||
tile.DrawAt( wr, targetCell.ToPPos().ToFloat2(), "terrain" );
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit)) {
|
||||
var targetCell = unit.Location + (xy - sourceLocation);
|
||||
var canEnter = ((manager.self.Owner.Shroud.IsExplored(targetCell) || manager.self.Owner.HasFogVisibility())&& unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell));
|
||||
var tile = canEnter ? validTile : invalidTile;
|
||||
tile.DrawAt( wr, targetCell.ToPPos().ToFloat2(), "terrain" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,12 +268,18 @@ namespace OpenRA.Mods.RA
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||
{
|
||||
var targetCell = unit.Location + (xy - sourceLocation);
|
||||
if (unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell, false))
|
||||
if (manager.self.Owner.Shroud.IsExplored(targetCell) && unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell))
|
||||
{
|
||||
canTeleport = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!canTeleport) {
|
||||
// Check the terrain types. This will allow chronoshifts to occur on empty terrain to terrain of
|
||||
// a similar type. This also keeps the cursor from changing in non-visible property, alerting the
|
||||
// chronoshifter of enemy unit presence
|
||||
canTeleport = power.SimilarTerrain(sourceLocation,xy);
|
||||
}
|
||||
return canTeleport;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,15 +58,12 @@ namespace OpenRA.Mods.RA
|
||||
public void RefreshGps(Actor atek)
|
||||
{
|
||||
RefreshGranted();
|
||||
|
||||
|
||||
foreach (TraitPair<GpsWatcher> i in atek.World.ActorsWithTrait<GpsWatcher>())
|
||||
i.Trait.RefreshGranted();
|
||||
|
||||
if (atek.World.LocalPlayer == null)
|
||||
return;
|
||||
|
||||
if ((Granted || GrantedAllies) && (atek.World.LocalPlayer.Stances[atek.Owner] == Stance.Ally))
|
||||
atek.World.WorldActor.Trait<Shroud>().ExploreAll(atek.World);
|
||||
if ((Granted || GrantedAllies) && atek.World.LocalPlayer != null && (atek.World.LocalPlayer.Stances[atek.Owner] == Stance.Ally))
|
||||
atek.Owner.Shroud.ExploreAll(atek.World);
|
||||
}
|
||||
|
||||
void RefreshGranted()
|
||||
@@ -74,6 +71,9 @@ namespace OpenRA.Mods.RA
|
||||
Granted = (actors.Count > 0 && Launched);
|
||||
GrantedAllies = owner.World.ActorsWithTrait<GpsWatcher>().Any(p =>
|
||||
p.Actor.Owner.Stances[owner] == Stance.Ally && p.Trait.Granted);
|
||||
|
||||
if (Granted || GrantedAllies)
|
||||
owner.Shroud.ExploreAll(owner.World);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,32 +131,38 @@ namespace OpenRA.Mods.RA
|
||||
Key = key;
|
||||
}
|
||||
|
||||
static bool InstanceDisabled(SupportPower sp)
|
||||
{
|
||||
return sp.self.TraitsImplementing<IDisable>().Any(d => d.Disabled);
|
||||
}
|
||||
|
||||
bool notifiedCharging;
|
||||
bool notifiedReady;
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
Active = !Disabled && Instances.Any(i => !i.self.IsDisabled());
|
||||
if (!Active)
|
||||
return;
|
||||
|
||||
if (Manager.devMode.FastCharge && RemainingTime > 25)
|
||||
RemainingTime = 25;
|
||||
|
||||
if (RemainingTime > 0) --RemainingTime;
|
||||
|
||||
var power = Instances.First();
|
||||
|
||||
if (!notifiedCharging)
|
||||
if (Active)
|
||||
{
|
||||
power.Charging(power.self, Key);
|
||||
notifiedCharging = true;
|
||||
}
|
||||
var power = Instances.First();
|
||||
if (Manager.devMode.FastCharge && RemainingTime > 25)
|
||||
RemainingTime = 25;
|
||||
|
||||
if (RemainingTime == 0 && !notifiedReady)
|
||||
{
|
||||
power.Charged(power.self, Key);
|
||||
notifiedReady = true;
|
||||
if (RemainingTime > 0) --RemainingTime;
|
||||
if (!notifiedCharging)
|
||||
{
|
||||
power.Charging(power.self, Key);
|
||||
notifiedCharging = true;
|
||||
}
|
||||
|
||||
if (RemainingTime == 0
|
||||
&& !notifiedReady)
|
||||
{
|
||||
power.Charged(power.self, Key);
|
||||
notifiedReady = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +179,7 @@ namespace OpenRA.Mods.RA
|
||||
if (!Ready)
|
||||
return;
|
||||
|
||||
var power = Instances.First(i => !i.self.IsDisabled());
|
||||
var power = Instances.First(i => !InstanceDisabled(i));
|
||||
|
||||
// Note: order.Subject is the *player* actor
|
||||
power.Activate(power.self, order);
|
||||
|
||||
Reference in New Issue
Block a user