Remove hardcoded limitation on mapsize everywhere except minimap
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
@@ -19,6 +19,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -29,11 +30,17 @@ namespace OpenRA.Traits
|
||||
|
||||
public class BuildingInfluence
|
||||
{
|
||||
bool[,] blocked = new bool[128, 128];
|
||||
Actor[,] influence = new Actor[128, 128];
|
||||
bool[,] blocked;
|
||||
Actor[,] influence;
|
||||
Map map;
|
||||
|
||||
public BuildingInfluence( Actor self )
|
||||
{
|
||||
map = self.World.Map;
|
||||
|
||||
blocked = new bool[map.MapSize, map.MapSize];
|
||||
influence = new Actor[map.MapSize, map.MapSize];
|
||||
|
||||
self.World.ActorAdded +=
|
||||
a => { if (a.traits.Contains<Building>())
|
||||
ChangeInfluence(a, a.traits.Get<Building>(), true); };
|
||||
@@ -45,27 +52,22 @@ namespace OpenRA.Traits
|
||||
void ChangeInfluence( Actor a, Building building, bool isAdd )
|
||||
{
|
||||
foreach( var u in Footprint.UnpathableTiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location ) )
|
||||
if( IsValid( u ) )
|
||||
if( map.IsInMap( u ) )
|
||||
blocked[ u.X, u.Y ] = isAdd;
|
||||
|
||||
foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location ) )
|
||||
if( IsValid( u ) )
|
||||
if( map.IsInMap( u ) )
|
||||
influence[ u.X, u.Y ] = isAdd ? a : null;
|
||||
}
|
||||
|
||||
bool IsValid(int2 t)
|
||||
{
|
||||
return !(t.X < 0 || t.Y < 0 || t.X >= 128 || t.Y >= 128);
|
||||
}
|
||||
|
||||
public Actor GetBuildingAt(int2 cell)
|
||||
{
|
||||
if (!IsValid(cell)) return null;
|
||||
if (!map.IsInMap(cell)) return null;
|
||||
return influence[cell.X, cell.Y];
|
||||
}
|
||||
|
||||
public bool CanMoveHere(int2 cell)
|
||||
{
|
||||
return IsValid(cell) && !blocked[cell.X, cell.Y];
|
||||
return map.IsInMap(cell) && !blocked[cell.X, cell.Y];
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace OpenRA.Traits
|
||||
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
||||
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
||||
|
||||
var newDensity = new byte[128, 128];
|
||||
var newDensity = new byte[map.MapSize, map.MapSize];
|
||||
for (int j = minj; j < maxj; j++)
|
||||
for (int i = mini; i < maxi; i++)
|
||||
if (content[i, j].type == info)
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Traits
|
||||
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
||||
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
||||
|
||||
var growMask = new bool[128, 128];
|
||||
var growMask = new bool[map.MapSize, map.MapSize];
|
||||
for (int j = minj; j < maxj; j++)
|
||||
for (int i = mini; i < maxi; i++)
|
||||
if (content[i,j].type == null
|
||||
|
||||
@@ -32,12 +32,14 @@ namespace OpenRA.Traits
|
||||
|
||||
public class UnitInfluence : ITick
|
||||
{
|
||||
List<Actor>[,] influence = new List<Actor>[128, 128];
|
||||
List<Actor>[,] influence;
|
||||
|
||||
public UnitInfluence( Actor self )
|
||||
{
|
||||
for (int i = 0; i < self.World.Map.MapSize; i++)
|
||||
for (int j = 0; j < self.World.Map.MapSize; j++)
|
||||
int size = self.World.Map.MapSize;
|
||||
influence = new List<Actor>[size, size];
|
||||
for (int i = 0; i < size; i++)
|
||||
for (int j = 0; j < size; j++)
|
||||
influence[ i, j ] = new List<Actor>();
|
||||
|
||||
self.World.ActorRemoved += a => Remove( a, a.traits.GetOrDefault<IOccupySpace>() );
|
||||
|
||||
Reference in New Issue
Block a user