fix dumb crash in cnc
This commit is contained in:
@@ -53,7 +53,7 @@ namespace OpenRA.Traits
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (isOpen && !self.World.WorldActor.traits.Get<UnitInfluence>()
|
||||
.GetUnitsAt(((1/24f) * self.CenterLocation).ToInt2()).Any())
|
||||
.GetUnitsAt(((1f/Game.CellSize) * self.CenterLocation).ToInt2()).Any())
|
||||
{
|
||||
isOpen = false;
|
||||
roof.PlayBackwardsThen(GetPrefix(self) + "build-top", () => roof.Play(GetPrefix(self) + "idle-top"));
|
||||
|
||||
@@ -22,6 +22,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -33,10 +34,12 @@ namespace OpenRA.Traits
|
||||
public class UnitInfluence : ITick
|
||||
{
|
||||
List<Actor>[,] influence;
|
||||
Map map;
|
||||
|
||||
public UnitInfluence( Actor self )
|
||||
{
|
||||
int size = self.World.Map.MapSize;
|
||||
map = self.World.Map;
|
||||
var 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++)
|
||||
@@ -90,6 +93,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public IEnumerable<Actor> GetUnitsAt( int2 a )
|
||||
{
|
||||
if (!map.IsInMap(a)) return null;
|
||||
return influence[ a.X, a.Y ];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user