Refactor UnitInfluence trait -> world.ActorMap
This commit is contained in:
@@ -13,15 +13,21 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
namespace OpenRA
|
||||
{
|
||||
public class UnitInfluenceInfo : ITraitInfo
|
||||
{
|
||||
public object Create( ActorInitializer init ) { return new UnitInfluence( init.world ); }
|
||||
}
|
||||
|
||||
public class UnitInfluence
|
||||
public enum SubCell
|
||||
{
|
||||
FullCell,
|
||||
TopLeft,
|
||||
TopRight,
|
||||
Center,
|
||||
BottomLeft,
|
||||
BottomRight
|
||||
}
|
||||
|
||||
public class ActorMap
|
||||
{
|
||||
class InfluenceNode
|
||||
{
|
||||
@@ -33,7 +39,7 @@ namespace OpenRA.Traits
|
||||
InfluenceNode[,] influence;
|
||||
Map map;
|
||||
|
||||
public UnitInfluence( World world )
|
||||
public ActorMap( World world )
|
||||
{
|
||||
map = world.Map;
|
||||
influence = new InfluenceNode[world.Map.MapSize.X, world.Map.MapSize.Y];
|
||||
@@ -136,7 +136,6 @@
|
||||
<Compile Include="Traits\Selectable.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||
<Compile Include="Traits\World\UnitInfluence.cs" />
|
||||
<Compile Include="Network\UnitOrders.cs" />
|
||||
<Compile Include="Traits\Util.cs" />
|
||||
<Compile Include="UiOverlay.cs" />
|
||||
@@ -185,6 +184,7 @@
|
||||
<Compile Include="Widgets\ScrollItem.cs" />
|
||||
<Compile Include="Widgets\DropDownButtonWidget.cs" />
|
||||
<Compile Include="Download.cs" />
|
||||
<Compile Include="ActorMap.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -84,13 +84,12 @@ namespace OpenRA.Orders
|
||||
|
||||
if( mi.Button == MouseButton.Right )
|
||||
{
|
||||
var uim = self.World.WorldActor.Trait<UnitInfluence>();
|
||||
foreach( var o in self.TraitsImplementing<IIssueOrder>()
|
||||
.SelectMany( trait => trait.Orders
|
||||
.Select( x => new { Trait = trait, Order = x } ) )
|
||||
.OrderByDescending( x => x.Order.OrderPriority ) )
|
||||
{
|
||||
var actorsAt = uim.GetUnitsAt( xy ).ToList();
|
||||
var actorsAt = self.World.ActorMap.GetUnitsAt( xy ).ToList();
|
||||
|
||||
string cursor = null;
|
||||
if( underCursor != null )
|
||||
|
||||
@@ -85,16 +85,6 @@ namespace OpenRA.Traits
|
||||
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
|
||||
public interface IHasLocation { int2 PxPosition { get; } }
|
||||
|
||||
public enum SubCell
|
||||
{
|
||||
FullCell,
|
||||
TopLeft,
|
||||
TopRight,
|
||||
Center,
|
||||
BottomLeft,
|
||||
BottomRight
|
||||
}
|
||||
|
||||
public interface IOccupySpace : IHasLocation
|
||||
{
|
||||
int2 TopLeft { get; }
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class ResourceLayerInfo : TraitInfo<ResourceLayer>, Requires<UnitInfluenceInfo> { }
|
||||
public class ResourceLayerInfo : TraitInfo<ResourceLayer> { }
|
||||
|
||||
public class ResourceLayer: IRenderOverlay, IWorldLoaded
|
||||
{
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
if (!world.Map.IsInMap(a.X, a.Y)) return false;
|
||||
if (!rt.info.AllowedTerrainTypes.Contains(world.GetTerrainInfo(a).Type)) return false;
|
||||
if (!rt.info.AllowUnderActors && world.WorldActor.Trait<UnitInfluence>().AnyUnitsAt(a)) return false;
|
||||
if (!rt.info.AllowUnderActors && world.ActorMap.AnyUnitsAt(a)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ namespace OpenRA
|
||||
public readonly Actor WorldActor;
|
||||
public readonly Map Map;
|
||||
public readonly TileSet TileSet;
|
||||
|
||||
public readonly ActorMap ActorMap;
|
||||
|
||||
public void IssueOrder( Order o ) { orderManager.IssueOrder( o ); } /* avoid exposing the OM to mod code */
|
||||
|
||||
IOrderGenerator orderGenerator_;
|
||||
@@ -100,7 +101,8 @@ namespace OpenRA
|
||||
|
||||
WorldActor = CreateActor( "World", new TypeDictionary() );
|
||||
LocalShroud = WorldActor.Trait<Shroud>();
|
||||
|
||||
ActorMap = new ActorMap(this);
|
||||
|
||||
// Add players
|
||||
foreach (var cmp in WorldActor.TraitsImplementing<ICreatePlayers>())
|
||||
cmp.CreatePlayers(this);
|
||||
|
||||
Reference in New Issue
Block a user