fix infantry entering buildings
This commit is contained in:
@@ -37,6 +37,7 @@ namespace OpenRA.Traits
|
|||||||
map = world.Map;
|
map = world.Map;
|
||||||
influence = new InfluenceNode[world.Map.MapSize.X, world.Map.MapSize.Y];
|
influence = new InfluenceNode[world.Map.MapSize.X, world.Map.MapSize.Y];
|
||||||
|
|
||||||
|
world.ActorAdded += a => Add( a, a.TraitOrDefault<IOccupySpace>() );
|
||||||
world.ActorRemoved += a => Remove( a, a.TraitOrDefault<IOccupySpace>() );
|
world.ActorRemoved += a => Remove( a, a.TraitOrDefault<IOccupySpace>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +56,9 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void Add( Actor self, IOccupySpace unit )
|
public void Add( Actor self, IOccupySpace unit )
|
||||||
{
|
{
|
||||||
foreach( var c in unit.OccupiedCells() )
|
if (unit != null)
|
||||||
influence[ c.X, c.Y ] = new InfluenceNode { next = influence[ c.X, c.Y ], actor = self };
|
foreach( var c in unit.OccupiedCells() )
|
||||||
|
influence[ c.X, c.Y ] = new InfluenceNode { next = influence[ c.X, c.Y ], actor = self };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove( Actor self, IOccupySpace unit )
|
public void Remove( Actor self, IOccupySpace unit )
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
self.Destroy();
|
self.Destroy();
|
||||||
});
|
});
|
||||||
return NextActivity;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
|
this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
|
||||||
|
|
||||||
var uim = init.world.WorldActor.Trait<UnitInfluence>();
|
var uim = init.world.WorldActor.Trait<UnitInfluence>();
|
||||||
uim.Add( init.self, this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetPowerUsage()
|
public int GetPowerUsage()
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ namespace OpenRA.Mods.RA
|
|||||||
this.Location = init.Get<LocationInit, int2>();
|
this.Location = init.Get<LocationInit, int2>();
|
||||||
PxPosition = Util.CenterOfCell(Location);
|
PxPosition = Util.CenterOfCell(Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Info = info;
|
this.Info = info;
|
||||||
|
|
||||||
self.World.WorldActor.Trait<UnitInfluence>().Add(self, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ namespace OpenRA.Mods.RA
|
|||||||
this.self = init.self;
|
this.self = init.self;
|
||||||
this.location = init.Get<LocationInit,int2>();
|
this.location = init.Get<LocationInit,int2>();
|
||||||
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : 128;
|
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : 128;
|
||||||
self.World.WorldActor.Trait<UnitInfluence>().Add(self, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 TopLeft { get { return location; } }
|
public int2 TopLeft { get { return location; } }
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ namespace OpenRA.Mods.RA
|
|||||||
this.self = init.self;
|
this.self = init.self;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.location = init.Get<LocationInit,int2>();
|
this.location = init.Get<LocationInit,int2>();
|
||||||
self.World.WorldActor.Trait<UnitInfluence>().Add(self, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
{
|
{
|
||||||
this.__fromCell = this.__toCell = init.Get<LocationInit,int2>();
|
this.__fromCell = this.__toCell = init.Get<LocationInit,int2>();
|
||||||
this.PxPosition = Util.CenterOfCell( fromCell );
|
this.PxPosition = Util.CenterOfCell( fromCell );
|
||||||
AddInfluence();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
|
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
this.nearEnough = 0;
|
this.nearEnough = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Move( int2 destination, int nearEnough )
|
public Move( int2 destination, int nearEnough )
|
||||||
{
|
{
|
||||||
this.getPath = (self,mobile) => self.World.WorldActor.Trait<PathFinder>().FindUnitPath( mobile.toCell, destination, self );
|
this.getPath = (self,mobile) => self.World.WorldActor.Trait<PathFinder>().FindUnitPath( mobile.toCell, destination, self );
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
@@ -50,7 +50,6 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
this.getPath = (self,mobile) =>
|
this.getPath = (self,mobile) =>
|
||||||
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
||||||
PathSearch.FromPoint( self.World, mobile.Info, mobile.toCell, destination, false )
|
PathSearch.FromPoint( self.World, mobile.Info, mobile.toCell, destination, false )
|
||||||
.WithCustomBlocker( self.World.WorldActor.Trait<PathFinder>().AvoidUnitsNear( mobile.toCell, 4, self ))
|
|
||||||
.WithIgnoredBuilding( ignoreBuilding ));
|
.WithIgnoredBuilding( ignoreBuilding ));
|
||||||
|
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
|
|||||||
Reference in New Issue
Block a user