Merge pull request #8817 from penev92/bleed_cleanups
Touch up a few files
This commit is contained in:
@@ -42,18 +42,16 @@ namespace OpenRA.Traits
|
||||
|
||||
class CellTrigger
|
||||
{
|
||||
public readonly int Id;
|
||||
public readonly CPos[] Footprint;
|
||||
public bool Dirty;
|
||||
|
||||
Action<Actor> onActorEntered;
|
||||
Action<Actor> onActorExited;
|
||||
readonly Action<Actor> onActorEntered;
|
||||
readonly Action<Actor> onActorExited;
|
||||
|
||||
IEnumerable<Actor> currentActors = Enumerable.Empty<Actor>();
|
||||
|
||||
public CellTrigger(int id, CPos[] footprint, Action<Actor> onActorEntered, Action<Actor> onActorExited)
|
||||
public CellTrigger(CPos[] footprint, Action<Actor> onActorEntered, Action<Actor> onActorExited)
|
||||
{
|
||||
Id = id;
|
||||
Footprint = footprint;
|
||||
|
||||
this.onActorEntered = onActorEntered;
|
||||
@@ -63,13 +61,13 @@ namespace OpenRA.Traits
|
||||
Dirty = true;
|
||||
}
|
||||
|
||||
public void Tick(ActorMap am)
|
||||
public void Tick(ActorMap actorMap)
|
||||
{
|
||||
if (!Dirty)
|
||||
return;
|
||||
|
||||
var oldActors = currentActors;
|
||||
currentActors = Footprint.SelectMany(c => am.GetUnitsAt(c)).ToList();
|
||||
currentActors = Footprint.SelectMany(actorMap.GetUnitsAt).ToList();
|
||||
|
||||
var entered = currentActors.Except(oldActors);
|
||||
var exited = oldActors.Except(currentActors);
|
||||
@@ -88,24 +86,20 @@ namespace OpenRA.Traits
|
||||
|
||||
class ProximityTrigger : IDisposable
|
||||
{
|
||||
public readonly int Id;
|
||||
public WPos Position { get; private set; }
|
||||
public WDist Range { get; private set; }
|
||||
|
||||
public WPos TopLeft { get; private set; }
|
||||
public WPos BottomRight { get; private set; }
|
||||
|
||||
public bool Dirty;
|
||||
|
||||
Action<Actor> onActorEntered;
|
||||
Action<Actor> onActorExited;
|
||||
readonly Action<Actor> onActorEntered;
|
||||
readonly Action<Actor> onActorExited;
|
||||
|
||||
WPos position;
|
||||
WDist range;
|
||||
IEnumerable<Actor> currentActors = Enumerable.Empty<Actor>();
|
||||
|
||||
public ProximityTrigger(int id, WPos pos, WDist range, Action<Actor> onActorEntered, Action<Actor> onActorExited)
|
||||
public ProximityTrigger(WPos pos, WDist range, Action<Actor> onActorEntered, Action<Actor> onActorExited)
|
||||
{
|
||||
Id = id;
|
||||
|
||||
this.onActorEntered = onActorEntered;
|
||||
this.onActorExited = onActorExited;
|
||||
|
||||
@@ -114,8 +108,8 @@ namespace OpenRA.Traits
|
||||
|
||||
public void Update(WPos newPos, WDist newRange)
|
||||
{
|
||||
Position = newPos;
|
||||
Range = newRange;
|
||||
position = newPos;
|
||||
range = newRange;
|
||||
|
||||
var offset = new WVec(newRange, newRange, WDist.Zero);
|
||||
TopLeft = newPos - offset;
|
||||
@@ -130,9 +124,9 @@ namespace OpenRA.Traits
|
||||
return;
|
||||
|
||||
var oldActors = currentActors;
|
||||
var delta = new WVec(Range, Range, WDist.Zero);
|
||||
currentActors = am.ActorsInBox(Position - delta, Position + delta)
|
||||
.Where(a => (a.CenterPosition - Position).HorizontalLengthSquared < Range.LengthSquared)
|
||||
var delta = new WVec(range, range, WDist.Zero);
|
||||
currentActors = am.ActorsInBox(position - delta, position + delta)
|
||||
.Where(a => (a.CenterPosition - position).HorizontalLengthSquared < range.LengthSquared)
|
||||
.ToList();
|
||||
|
||||
var entered = currentActors.Except(oldActors);
|
||||
@@ -376,7 +370,7 @@ namespace OpenRA.Traits
|
||||
public int AddCellTrigger(CPos[] cells, Action<Actor> onEntry, Action<Actor> onExit)
|
||||
{
|
||||
var id = nextTriggerId++;
|
||||
var t = new CellTrigger(id, cells, onEntry, onExit);
|
||||
var t = new CellTrigger(cells, onEntry, onExit);
|
||||
cellTriggers.Add(id, t);
|
||||
|
||||
foreach (var c in cells)
|
||||
@@ -411,7 +405,7 @@ namespace OpenRA.Traits
|
||||
public int AddProximityTrigger(WPos pos, WDist range, Action<Actor> onEntry, Action<Actor> onExit)
|
||||
{
|
||||
var id = nextTriggerId++;
|
||||
var t = new ProximityTrigger(id, pos, range, onEntry, onExit);
|
||||
var t = new ProximityTrigger(pos, range, onEntry, onExit);
|
||||
proximityTriggers.Add(id, t);
|
||||
|
||||
foreach (var bin in BinsInBox(t.TopLeft, t.BottomRight))
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public class BuildingInfluence
|
||||
{
|
||||
CellLayer<Actor> influence;
|
||||
Map map;
|
||||
readonly Map map;
|
||||
readonly CellLayer<Actor> influence;
|
||||
|
||||
public BuildingInfluence(World world)
|
||||
{
|
||||
@@ -54,10 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public Actor GetBuildingAt(CPos cell)
|
||||
{
|
||||
if (!influence.Contains(cell))
|
||||
return null;
|
||||
|
||||
return influence[cell];
|
||||
return influence.Contains(cell) ? influence[cell] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
class BridgeLayer : IWorldLoaded
|
||||
{
|
||||
readonly BridgeLayerInfo info;
|
||||
Dictionary<ushort, Pair<string, int>> bridgeTypes = new Dictionary<ushort, Pair<string, int>>();
|
||||
readonly Dictionary<ushort, Pair<string, int>> bridgeTypes = new Dictionary<ushort, Pair<string, int>>();
|
||||
|
||||
CellLayer<Bridge> bridges;
|
||||
|
||||
public BridgeLayer(Actor self, BridgeLayerInfo info)
|
||||
@@ -47,10 +48,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bridgeTypes.Add(template.First, Pair.New(bridge, template.Second));
|
||||
}
|
||||
|
||||
// Loop through the map looking for templates to overlay
|
||||
foreach (var cell in w.Map.AllCells)
|
||||
if (bridgeTypes.ContainsKey(w.Map.MapTiles.Value[cell].Type))
|
||||
ConvertBridgeToActor(w, cell);
|
||||
// Take all templates to overlay from the map
|
||||
foreach (var cell in w.Map.AllCells.Where(cell => bridgeTypes.ContainsKey(w.Map.MapTiles.Value[cell].Type)))
|
||||
ConvertBridgeToActor(w, cell);
|
||||
|
||||
// Link adjacent (long)-bridges so that artwork is updated correctly
|
||||
foreach (var b in w.Actors.SelectMany(a => a.TraitsImplementing<Bridge>()))
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Support;
|
||||
@@ -53,11 +51,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class MovementClassDomainIndex
|
||||
{
|
||||
Map map;
|
||||
|
||||
uint movementClass;
|
||||
CellLayer<int> domains;
|
||||
Dictionary<int, HashSet<int>> transientConnections;
|
||||
readonly Map map;
|
||||
readonly uint movementClass;
|
||||
readonly CellLayer<int> domains;
|
||||
readonly Dictionary<int, HashSet<int>> transientConnections;
|
||||
|
||||
public MovementClassDomainIndex(World world, uint movementClass)
|
||||
{
|
||||
@@ -168,8 +165,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void BuildDomains(World world)
|
||||
{
|
||||
var map = world.Map;
|
||||
|
||||
var domain = 1;
|
||||
|
||||
var visited = new CellLayer<bool>(map);
|
||||
|
||||
Reference in New Issue
Block a user