BIM/UIM become traits on World; Added World.WorldActor
This commit is contained in:
@@ -108,7 +108,7 @@ namespace OpenRa.Graphics
|
|||||||
for (var y = 0; y < 128; y++)
|
for (var y = 0; y < 128; y++)
|
||||||
for (var x = 0; x < 128; x++)
|
for (var x = 0; x < 128; x++)
|
||||||
{
|
{
|
||||||
var b = world.BuildingInfluence.GetBuildingAt(new int2(x, y));
|
var b = world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(new int2(x, y));
|
||||||
if (b != null)
|
if (b != null)
|
||||||
*(c + (y * bitmapData.Stride >> 2) + x) =
|
*(c + (y * bitmapData.Stride >> 2) + x) =
|
||||||
(b.Owner != null ? playerColors[(int)b.Owner.Palette] : colors[4]).ToArgb();
|
(b.Owner != null ? playerColors[(int)b.Owner.Palette] : colors[4]).ToArgb();
|
||||||
|
|||||||
@@ -160,7 +160,6 @@
|
|||||||
<Compile Include="Traits\Activities\ReturnToBase.cs" />
|
<Compile Include="Traits\Activities\ReturnToBase.cs" />
|
||||||
<Compile Include="Traits\Activities\Sell.cs" />
|
<Compile Include="Traits\Activities\Sell.cs" />
|
||||||
<Compile Include="Traits\Activities\Teleport.cs" />
|
<Compile Include="Traits\Activities\Teleport.cs" />
|
||||||
<Compile Include="BuildingInfluenceMap.cs" />
|
|
||||||
<Compile Include="Orders\IOrderGenerator.cs" />
|
<Compile Include="Orders\IOrderGenerator.cs" />
|
||||||
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
||||||
<Compile Include="Player.cs" />
|
<Compile Include="Player.cs" />
|
||||||
@@ -202,6 +201,7 @@
|
|||||||
<Compile Include="Traits\Bridge.cs" />
|
<Compile Include="Traits\Bridge.cs" />
|
||||||
<Compile Include="Traits\Buildable.cs" />
|
<Compile Include="Traits\Buildable.cs" />
|
||||||
<Compile Include="Traits\Building.cs" />
|
<Compile Include="Traits\Building.cs" />
|
||||||
|
<Compile Include="Traits\BuildingInfluence.cs" />
|
||||||
<Compile Include="Traits\CanPowerDown.cs" />
|
<Compile Include="Traits\CanPowerDown.cs" />
|
||||||
<Compile Include="Traits\Cargo.cs" />
|
<Compile Include="Traits\Cargo.cs" />
|
||||||
<Compile Include="Traits\Chronoshiftable.cs" />
|
<Compile Include="Traits\Chronoshiftable.cs" />
|
||||||
@@ -258,6 +258,7 @@
|
|||||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||||
<Compile Include="Traits\Turreted.cs" />
|
<Compile Include="Traits\Turreted.cs" />
|
||||||
<Compile Include="Traits\Unit.cs" />
|
<Compile Include="Traits\Unit.cs" />
|
||||||
|
<Compile Include="Traits\UnitInfluence.cs" />
|
||||||
<Compile Include="Traits\WaterPaletteRotation.cs" />
|
<Compile Include="Traits\WaterPaletteRotation.cs" />
|
||||||
<Compile Include="Traits\WithShadow.cs" />
|
<Compile Include="Traits\WithShadow.cs" />
|
||||||
<Compile Include="Network\UnitOrders.cs" />
|
<Compile Include="Network\UnitOrders.cs" />
|
||||||
@@ -266,7 +267,6 @@
|
|||||||
<Compile Include="Graphics\Util.cs" />
|
<Compile Include="Graphics\Util.cs" />
|
||||||
<Compile Include="Graphics\Vertex.cs" />
|
<Compile Include="Graphics\Vertex.cs" />
|
||||||
<Compile Include="Graphics\Viewport.cs" />
|
<Compile Include="Graphics\Viewport.cs" />
|
||||||
<Compile Include="UnitInfluenceMap.cs" />
|
|
||||||
<Compile Include="Orders\UnitOrderGenerator.cs" />
|
<Compile Include="Orders\UnitOrderGenerator.cs" />
|
||||||
<Compile Include="World.cs" />
|
<Compile Include="World.cs" />
|
||||||
<Compile Include="WorldUtils.cs" />
|
<Compile Include="WorldUtils.cs" />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenRa.FileFormats;
|
using OpenRa.FileFormats;
|
||||||
|
using OpenRa.Traits;
|
||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
@@ -28,7 +29,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static bool OreCanSpreadInto(this World world, int i, int j)
|
public static bool OreCanSpreadInto(this World world, int i, int j)
|
||||||
{
|
{
|
||||||
if (world.BuildingInfluence.GetBuildingAt(new int2(i, j)) != null)
|
if (world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(new int2(i, j)) != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return TerrainCosts.Cost(UnitMovementType.Wheel,
|
return TerrainCosts.Cost(UnitMovementType.Wheel,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRa
|
|||||||
return q =>
|
return q =>
|
||||||
p != q &&
|
p != q &&
|
||||||
((p - q).LengthSquared < dist * dist) &&
|
((p - q).LengthSquared < dist * dist) &&
|
||||||
(world.UnitInfluence.GetUnitsAt(q).Any());
|
(world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(q).Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<int2> FindPath( PathSearch search )
|
public List<int2> FindPath( PathSearch search )
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using IjwFramework.Collections;
|
using IjwFramework.Collections;
|
||||||
using OpenRa.Graphics;
|
using OpenRa.Graphics;
|
||||||
|
using OpenRa.Traits;
|
||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
@@ -47,7 +48,7 @@ namespace OpenRa
|
|||||||
if (thisCost == float.PositiveInfinity)
|
if (thisCost == float.PositiveInfinity)
|
||||||
return p.Location;
|
return p.Location;
|
||||||
|
|
||||||
foreach( int2 d in Util.directions )
|
foreach( int2 d in Graphics.Util.directions )
|
||||||
{
|
{
|
||||||
int2 newHere = p.Location + d;
|
int2 newHere = p.Location + d;
|
||||||
|
|
||||||
@@ -61,14 +62,14 @@ namespace OpenRa
|
|||||||
if (costHere == float.PositiveInfinity)
|
if (costHere == float.PositiveInfinity)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!world.BuildingInfluence.CanMoveHere(newHere) &&
|
if (!world.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(newHere) &&
|
||||||
world.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
|
world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(newHere) != ignoreBuilding)
|
||||||
continue;
|
continue;
|
||||||
if (world.Map.IsOverlaySolid(newHere))
|
if (world.Map.IsOverlaySolid(newHere))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Replicate real-ra behavior of not being able to enter a cell if there is a mixture of crushable and uncrushable units
|
// Replicate real-ra behavior of not being able to enter a cell if there is a mixture of crushable and uncrushable units
|
||||||
if (checkForBlocked && (world.UnitInfluence.GetUnitsAt(newHere).Any(a => !world.IsActorPathableToCrush(a, umt))))
|
if (checkForBlocked && (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(newHere).Any(a => !world.IsActorPathableToCrush(a, umt))))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (customBlock != null && customBlock(newHere))
|
if (customBlock != null && customBlock(newHere))
|
||||||
|
|||||||
@@ -57,13 +57,13 @@ namespace OpenRa.Traits.Activities
|
|||||||
|
|
||||||
bool CanEnterCell( int2 c, Actor self )
|
bool CanEnterCell( int2 c, Actor self )
|
||||||
{
|
{
|
||||||
if (!self.World.BuildingInfluence.CanMoveHere(c)
|
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(c)
|
||||||
&& self.World.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding)
|
&& self.World.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(c) != ignoreBuilding)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Cannot enter a cell if any unit inside is uncrushable
|
// Cannot enter a cell if any unit inside is uncrushable
|
||||||
// This will need to be updated for multiple-infantry-in-a-cell
|
// This will need to be updated for multiple-infantry-in-a-cell
|
||||||
return (!self.World.UnitInfluence.GetUnitsAt(c).Any(a => a != self && !self.World.IsActorCrushableByActor(a, self)));
|
return (!self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(c).Any(a => a != self && !self.World.IsActorCrushableByActor(a, self)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActivity Tick( Actor self )
|
public IActivity Tick( Actor self )
|
||||||
@@ -144,10 +144,10 @@ namespace OpenRa.Traits.Activities
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.World.UnitInfluence.Remove( self, mobile );
|
self.World.WorldActor.traits.Get<UnitInfluence>().Remove( self, mobile );
|
||||||
var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList();
|
var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList();
|
||||||
|
|
||||||
self.World.UnitInfluence.Add( self, mobile );
|
self.World.WorldActor.traits.Get<UnitInfluence>().Add( self, mobile );
|
||||||
if (newPath.Count != 0)
|
if (newPath.Count != 0)
|
||||||
path = newPath;
|
path = newPath;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
int2? ChooseExitTile(Actor self)
|
int2? ChooseExitTile(Actor self)
|
||||||
{
|
{
|
||||||
// is anyone still hogging this tile?
|
// is anyone still hogging this tile?
|
||||||
if (self.World.UnitInfluence.GetUnitsAt(self.Location).Count() > 1)
|
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(self.Location).Count() > 1)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (var i = -1; i < 2; i++)
|
for (var i = -1; i < 2; i++)
|
||||||
|
|||||||
25
OpenRa.Game/BuildingInfluenceMap.cs → OpenRa.Game/Traits/BuildingInfluence.cs
Normal file → Executable file
25
OpenRa.Game/BuildingInfluenceMap.cs → OpenRa.Game/Traits/BuildingInfluence.cs
Normal file → Executable file
@@ -1,19 +1,27 @@
|
|||||||
using OpenRa.GameRules;
|
using System;
|
||||||
using OpenRa.Traits;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using OpenRa.GameRules;
|
||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa.Traits
|
||||||
{
|
{
|
||||||
public class BuildingInfluenceMap
|
public class BuildingInfluenceInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public object Create( Actor self ) { return new BuildingInfluence( self ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BuildingInfluence
|
||||||
{
|
{
|
||||||
bool[,] blocked = new bool[128, 128];
|
bool[,] blocked = new bool[128, 128];
|
||||||
Actor[,] influence = new Actor[128, 128];
|
Actor[,] influence = new Actor[128, 128];
|
||||||
|
|
||||||
public BuildingInfluenceMap( World world )
|
public BuildingInfluence( Actor self )
|
||||||
{
|
{
|
||||||
world.ActorAdded +=
|
self.World.ActorAdded +=
|
||||||
a => { if (a.traits.Contains<Building>())
|
a => { if (a.traits.Contains<Building>())
|
||||||
ChangeInfluence(a, a.traits.Get<Building>(), true); };
|
ChangeInfluence(a, a.traits.Get<Building>(), true); };
|
||||||
world.ActorRemoved +=
|
self.World.ActorRemoved +=
|
||||||
a => { if (a.traits.Contains<Building>())
|
a => { if (a.traits.Contains<Building>())
|
||||||
ChangeInfluence(a, a.traits.Get<Building>(), false); };
|
ChangeInfluence(a, a.traits.Get<Building>(), false); };
|
||||||
}
|
}
|
||||||
@@ -44,5 +52,4 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
return IsValid(cell) && !blocked[cell.X, cell.Y];
|
return IsValid(cell) && !blocked[cell.X, cell.Y];
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
@@ -52,10 +52,10 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public bool CanEnterCell(int2 a)
|
public bool CanEnterCell(int2 a)
|
||||||
{
|
{
|
||||||
if (!self.World.BuildingInfluence.CanMoveHere(a)) return false;
|
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(a)) return false;
|
||||||
|
|
||||||
var crushable = true;
|
var crushable = true;
|
||||||
foreach (Actor actor in self.World.UnitInfluence.GetUnitsAt(a))
|
foreach (Actor actor in self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a))
|
||||||
{
|
{
|
||||||
if (actor == self) continue;
|
if (actor == self) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRa.Traits
|
|||||||
public Crate(Actor self)
|
public Crate(Actor self)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
self.World.UnitInfluence.Add(self, this);
|
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRa.Traits
|
|||||||
public int2 fromCell
|
public int2 fromCell
|
||||||
{
|
{
|
||||||
get { return __fromCell; }
|
get { return __fromCell; }
|
||||||
set { self.World.UnitInfluence.Remove(self, this); __fromCell = value; self.World.UnitInfluence.Add(self, this); }
|
set { self.World.WorldActor.traits.Get<UnitInfluence>().Remove(self, this); __fromCell = value; self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this); }
|
||||||
}
|
}
|
||||||
public int2 toCell
|
public int2 toCell
|
||||||
{
|
{
|
||||||
@@ -28,11 +28,11 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
if (self.Location != value)
|
if (self.Location != value)
|
||||||
{
|
{
|
||||||
self.World.UnitInfluence.Remove(self, this);
|
self.World.WorldActor.traits.Get<UnitInfluence>().Remove(self, this);
|
||||||
self.Location = value;
|
self.Location = value;
|
||||||
self.Owner.Shroud.Explore(self);
|
self.Owner.Shroud.Explore(self);
|
||||||
}
|
}
|
||||||
self.World.UnitInfluence.Add(self, this);
|
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace OpenRa.Traits
|
|||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
__fromCell = toCell;
|
__fromCell = toCell;
|
||||||
self.World.UnitInfluence.Add(self, this);
|
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TeleportTo(Actor self, int2 xy)
|
public void TeleportTo(Actor self, int2 xy)
|
||||||
@@ -91,10 +91,10 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public bool CanEnterCell(int2 a)
|
public bool CanEnterCell(int2 a)
|
||||||
{
|
{
|
||||||
if (!self.World.BuildingInfluence.CanMoveHere(a)) return false;
|
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(a)) return false;
|
||||||
|
|
||||||
var crushable = true;
|
var crushable = true;
|
||||||
foreach (Actor actor in self.World.UnitInfluence.GetUnitsAt(a))
|
foreach (Actor actor in self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a))
|
||||||
{
|
{
|
||||||
if (actor == self) continue;
|
if (actor == self) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRa.Traits
|
|||||||
public bool Produce( Actor self, ActorInfo producee )
|
public bool Produce( Actor self, ActorInfo producee )
|
||||||
{
|
{
|
||||||
var location = CreationLocation( self, producee );
|
var location = CreationLocation( self, producee );
|
||||||
if( location == null || self.World.UnitInfluence.GetUnitsAt( location.Value ).Any() )
|
if( location == null || self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt( location.Value ).Any() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner );
|
var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner );
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRa.Traits
|
|||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var b = self.GetBounds(false);
|
var b = self.GetBounds(false);
|
||||||
if (isOpen && !self.World.UnitInfluence.GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any())
|
if (isOpen && !self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any())
|
||||||
{
|
{
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
roof.PlayBackwardsThen(GetPrefix(self) + "build-top", () => roof.Play(GetPrefix(self) + "idle-top"));
|
roof.PlayBackwardsThen(GetPrefix(self) + "build-top", () => roof.Play(GetPrefix(self) + "idle-top"));
|
||||||
|
|||||||
31
OpenRa.Game/UnitInfluenceMap.cs → OpenRa.Game/Traits/UnitInfluence.cs
Normal file → Executable file
31
OpenRa.Game/UnitInfluenceMap.cs → OpenRa.Game/Traits/UnitInfluence.cs
Normal file → Executable file
@@ -1,33 +1,36 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRa.Traits;
|
using System.Text;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa.Traits
|
||||||
{
|
{
|
||||||
public class UnitInfluenceMap
|
public class UnitInfluenceInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public object Create( Actor self ) { return new UnitInfluence( self ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnitInfluence : ITick
|
||||||
{
|
{
|
||||||
readonly World world;
|
|
||||||
List<Actor>[,] influence = new List<Actor>[128, 128];
|
List<Actor>[,] influence = new List<Actor>[128, 128];
|
||||||
readonly int2 searchDistance = new int2(2,2);
|
readonly int2 searchDistance = new int2(2,2);
|
||||||
|
|
||||||
public UnitInfluenceMap( World world )
|
public UnitInfluence( Actor self )
|
||||||
{
|
{
|
||||||
this.world = world;
|
|
||||||
for (int i = 0; i < 128; i++)
|
for (int i = 0; i < 128; i++)
|
||||||
for (int j = 0; j < 128; j++)
|
for (int j = 0; j < 128; j++)
|
||||||
influence[ i, j ] = new List<Actor>();
|
influence[ i, j ] = new List<Actor>();
|
||||||
|
|
||||||
world.ActorRemoved += a => Remove( a, a.traits.GetOrDefault<IOccupySpace>() );
|
self.World.ActorRemoved += a => Remove( a, a.traits.GetOrDefault<IOccupySpace>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick()
|
public void Tick( Actor self )
|
||||||
{
|
{
|
||||||
// Does this belong here? NO, but it's your mess.
|
// Does this belong here? NO, but it's your mess.
|
||||||
|
|
||||||
// Get the crushable actors
|
// Get the crushable actors
|
||||||
foreach (var a in world.Actors.Where(b => b.traits.Contains<ICrushable>()))
|
foreach (var a in self.World.Actors.Where(b => b.traits.Contains<ICrushable>()))
|
||||||
{
|
{
|
||||||
// Are there any units in the same cell that can crush this?
|
// Are there any units in the same cell that can crush this?
|
||||||
foreach( var ios in a.traits.WithInterface<IOccupySpace>() )
|
foreach( var ios in a.traits.WithInterface<IOccupySpace>() )
|
||||||
@@ -35,7 +38,7 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
// There should only be one (counterexample: An infantry and a tank try to pick up a crate at the same time.)
|
// There should only be one (counterexample: An infantry and a tank try to pick up a crate at the same time.)
|
||||||
// If there is more than one, do action on the first crusher
|
// If there is more than one, do action on the first crusher
|
||||||
var crusher = GetUnitsAt(cell).Where(b => a != b && world.IsActorCrushableByActor(a, b)).FirstOrDefault();
|
var crusher = GetUnitsAt(cell).Where(b => a != b && self.World.IsActorCrushableByActor(a, b)).FirstOrDefault();
|
||||||
if (crusher != null)
|
if (crusher != null)
|
||||||
{
|
{
|
||||||
Log.Write("{0} crushes {1}", crusher.Info.Name, a.Info.Name);
|
Log.Write("{0} crushes {1}", crusher.Info.Name, a.Info.Name);
|
||||||
@@ -45,11 +48,11 @@ namespace OpenRa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SanityCheck();
|
SanityCheck( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
[Conditional( "SANITY_CHECKS" )]
|
[Conditional( "SANITY_CHECKS" )]
|
||||||
void SanityCheck()
|
void SanityCheck( Actor self )
|
||||||
{
|
{
|
||||||
for( int y = 0 ; y < 128 ; y++ )
|
for( int y = 0 ; y < 128 ; y++ )
|
||||||
for( int x = 0 ; x < 128 ; x++ )
|
for( int x = 0 ; x < 128 ; x++ )
|
||||||
@@ -58,7 +61,7 @@ namespace OpenRa
|
|||||||
if (!a.traits.Get<IOccupySpace>().OccupiedCells().Contains( new int2( x, y ) ) )
|
if (!a.traits.Get<IOccupySpace>().OccupiedCells().Contains( new int2( x, y ) ) )
|
||||||
throw new InvalidOperationException( "UIM: Sanity check failed A" );
|
throw new InvalidOperationException( "UIM: Sanity check failed A" );
|
||||||
|
|
||||||
foreach( Actor a in world.Actors )
|
foreach( Actor a in self.World.Actors )
|
||||||
foreach( var ios in a.traits.WithInterface<IOccupySpace>() )
|
foreach( var ios in a.traits.WithInterface<IOccupySpace>() )
|
||||||
foreach( var cell in ios.OccupiedCells() )
|
foreach( var cell in ios.OccupiedCells() )
|
||||||
if (!influence[cell.X, cell.Y].Contains(a))
|
if (!influence[cell.X, cell.Y].Contains(a))
|
||||||
@@ -39,7 +39,7 @@ namespace OpenRa
|
|||||||
if (ShowUnitDebug)
|
if (ShowUnitDebug)
|
||||||
for (var j = 0; j < 128; j++)
|
for (var j = 0; j < 128; j++)
|
||||||
for (var i = 0; i < 128; i++)
|
for (var i = 0; i < 128; i++)
|
||||||
if (world.UnitInfluence.GetUnitsAt(new int2(i, j)).Any())
|
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(new int2(i, j)).Any())
|
||||||
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0);
|
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ namespace OpenRa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly BuildingInfluenceMap BuildingInfluence;
|
public readonly Actor WorldActor;
|
||||||
public readonly UnitInfluenceMap UnitInfluence;
|
|
||||||
|
|
||||||
public readonly PathFinder PathFinder;
|
public readonly PathFinder PathFinder;
|
||||||
|
|
||||||
@@ -60,16 +59,12 @@ namespace OpenRa
|
|||||||
SpriteSheetBuilder.Initialize( Map );
|
SpriteSheetBuilder.Initialize( Map );
|
||||||
Timer.Time( "Tileset: {0}" );
|
Timer.Time( "Tileset: {0}" );
|
||||||
|
|
||||||
BuildingInfluence = new BuildingInfluenceMap( this );
|
|
||||||
UnitInfluence = new UnitInfluenceMap( this );
|
|
||||||
Timer.Time( "BIM/UIM: {0}" );
|
|
||||||
|
|
||||||
oreFrequency = (int)(Rules.General.GrowthRate * 60 * 25);
|
oreFrequency = (int)(Rules.General.GrowthRate * 60 * 25);
|
||||||
oreTicks = oreFrequency;
|
oreTicks = oreFrequency;
|
||||||
Map.InitOreDensity();
|
Map.InitOreDensity();
|
||||||
Timer.Time( "Ore: {0}" );
|
Timer.Time( "Ore: {0}" );
|
||||||
|
|
||||||
CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
WorldActor = CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
players[i] = new Player(this, i, Game.LobbyInfo.Clients.FirstOrDefault(a => a.Index == i));
|
players[i] = new Player(this, i, Game.LobbyInfo.Clients.FirstOrDefault(a => a.Index == i));
|
||||||
@@ -133,8 +128,6 @@ namespace OpenRa
|
|||||||
frameEndActions = new List<Action<World>>();
|
frameEndActions = new List<Action<World>>();
|
||||||
foreach (var a in acts) a(this);
|
foreach (var a in acts) a(this);
|
||||||
|
|
||||||
UnitInfluence.Tick();
|
|
||||||
|
|
||||||
Minimap.Update();
|
Minimap.Update();
|
||||||
foreach (var player in players.Values)
|
foreach (var player in players.Values)
|
||||||
player.Tick();
|
player.Tick();
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static bool IsCellBuildable(this World world, int2 a, UnitMovementType umt, Actor toIgnore)
|
public static bool IsCellBuildable(this World world, int2 a, UnitMovementType umt, Actor toIgnore)
|
||||||
{
|
{
|
||||||
if (world.BuildingInfluence.GetBuildingAt(a) != null) return false;
|
if (world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(a) != null) return false;
|
||||||
if (world.UnitInfluence.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||||
|
|
||||||
return world.Map.IsInMap(a.X, a.Y) &&
|
return world.Map.IsInMap(a.X, a.Y) &&
|
||||||
TerrainCosts.Cost(umt,
|
TerrainCosts.Cost(umt,
|
||||||
@@ -130,7 +130,7 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
for( int x = scanStart.X ; x < scanEnd.X ; x++ )
|
for( int x = scanStart.X ; x < scanEnd.X ; x++ )
|
||||||
{
|
{
|
||||||
var at = world.BuildingInfluence.GetBuildingAt( new int2( x, y ) );
|
var at = world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt( new int2( x, y ) );
|
||||||
if( at != null && at.Owner == p )
|
if( at != null && at.Owner == p )
|
||||||
nearnessCandidates.Add( new int2( x, y ) );
|
nearnessCandidates.Add( new int2( x, y ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRa.Mods.RA
|
|||||||
public Mine(Actor self)
|
public Mine(Actor self)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
self.World.UnitInfluence.Add(self, this);
|
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRa.Mods.RA
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Ensure that the cell is empty except for the minelayer
|
// Ensure that the cell is empty except for the minelayer
|
||||||
if (self.World.UnitInfluence.GetUnitsAt(xy).Any(a => a != self))
|
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(xy).Any(a => a != self))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Right && underCursor == self)
|
if (mi.Button == MouseButton.Right && underCursor == self)
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ World:
|
|||||||
WaterPaletteRotation:
|
WaterPaletteRotation:
|
||||||
ChronoshiftPaletteEffect:
|
ChronoshiftPaletteEffect:
|
||||||
LightPaletteRotator:
|
LightPaletteRotator:
|
||||||
|
BuildingInfluence:
|
||||||
|
UnitInfluence:
|
||||||
|
|
||||||
MGG:
|
MGG:
|
||||||
GeneratesGap:
|
GeneratesGap:
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ World:
|
|||||||
WaterPaletteRotation:
|
WaterPaletteRotation:
|
||||||
ChronoshiftPaletteEffect:
|
ChronoshiftPaletteEffect:
|
||||||
LightPaletteRotator:
|
LightPaletteRotator:
|
||||||
|
BuildingInfluence:
|
||||||
|
UnitInfluence:
|
||||||
|
|
||||||
MGG:
|
MGG:
|
||||||
GeneratesGap:
|
GeneratesGap:
|
||||||
|
|||||||
Reference in New Issue
Block a user