Fixed Mobile.SetPosition & other FixUnloadCargo touch-ups
Fixed Mobile.SetPosition
Finally removed old SubCell enum
Folded MobileInfo.CanEnterCell overloads into one
Renamed IPositionable.{IsMovingFrom => IsLeaving}
Changed Crate.IsLeaving to use crate lifetime
This commit is contained in:
@@ -180,7 +180,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public interface IPositionable : IOccupySpace
|
public interface IPositionable : IOccupySpace
|
||||||
{
|
{
|
||||||
bool IsMovingFrom(CPos location, int subCell = -1);
|
bool IsLeaving(CPos location, int subCell = -1);
|
||||||
bool CanEnterCell(CPos location, Actor ignoreActor = null, bool checkTransientActors = true);
|
bool CanEnterCell(CPos location, Actor ignoreActor = null, bool checkTransientActors = true);
|
||||||
int GetAvailableSubcell(CPos location, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true);
|
int GetAvailableSubcell(CPos location, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true);
|
||||||
void SetPosition(Actor self, CPos cell, int subCell = -1);
|
void SetPosition(Actor self, CPos cell, int subCell = -1);
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
public enum SubCell { FullCell, TopLeft, TopRight, Center, BottomLeft, BottomRight }
|
|
||||||
|
|
||||||
public class ActorMapInfo : ITraitInfo
|
public class ActorMapInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
[Desc("Size of partition bins (cells)")]
|
[Desc("Size of partition bins (cells)")]
|
||||||
@@ -131,7 +129,7 @@ namespace OpenRA.Traits
|
|||||||
if (checkTransient)
|
if (checkTransient)
|
||||||
return true;
|
return true;
|
||||||
var pos = i.Actor.TraitOrDefault<IPositionable>();
|
var pos = i.Actor.TraitOrDefault<IPositionable>();
|
||||||
if (pos == null || !pos.IsMovingFrom(a, i.SubCell))
|
if (pos == null || !pos.IsLeaving(a, i.SubCell))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
|| info.RepairBuildings.Contains(a.Info.Name);
|
|| info.RepairBuildings.Contains(a.Info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsMovingFrom(CPos location, int subCell = -1) { return false; } // TODO: handle landing
|
public bool IsLeaving(CPos location, int subCell = -1) { return false; } // TODO: handle landing
|
||||||
public int GetAvailableSubcell(CPos a, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true) { return -1; } // does not use any subcell
|
public int GetAvailableSubcell(CPos a, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true) { return -1; } // does not use any subcell
|
||||||
public bool CanEnterCell(CPos cell, Actor ignoreActor = null, bool checkTransientActors = true) { return true; }
|
public bool CanEnterCell(CPos cell, Actor ignoreActor = null, bool checkTransientActors = true) { return true; }
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public void SetPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
public void SetPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
||||||
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
|
||||||
|
|
||||||
public bool IsMovingFrom(CPos location, int subCell = -1) { return false; }
|
public bool IsLeaving(CPos location, int subCell = -1) { return self.Location == location && ticks + 1 == info.Lifetime * 25; }
|
||||||
public int GetAvailableSubcell(CPos cell, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true)
|
public int GetAvailableSubcell(CPos cell, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||||
{
|
{
|
||||||
if (!self.World.Map.Contains(cell)) return -1;
|
if (!self.World.Map.Contains(cell)) return -1;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Pair<CPos, int>> OccupiedCells() { yield return Pair.New(TopLeft, 0); }
|
public IEnumerable<Pair<CPos, int>> OccupiedCells() { yield return Pair.New(TopLeft, 0); }
|
||||||
public bool IsMovingFrom(CPos location, int subCell = -1) { return false; }
|
public bool IsLeaving(CPos location, int subCell = -1) { return false; }
|
||||||
public int GetAvailableSubcell(CPos cell, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true)
|
public int GetAvailableSubcell(CPos cell, int preferredSubCell = -1, Actor ignoreActor = null, bool checkTransientActors = true)
|
||||||
{
|
{
|
||||||
if (!self.World.Map.Contains(cell))
|
if (!self.World.Map.Contains(cell))
|
||||||
|
|||||||
@@ -160,22 +160,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanEnterCell(World world, CPos cell, int subCell = -1, CellConditions check = CellConditions.All)
|
public bool CanEnterCell(World world, Actor self, CPos cell, Actor ignoreActor = null, CellConditions check = CellConditions.All)
|
||||||
{
|
|
||||||
return CanEnterCell(world, null, cell, subCell, null, check);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanEnterCell(World world, Actor self, CPos cell, int subCell, CellConditions check)
|
|
||||||
{
|
|
||||||
return CanEnterCell(world, self, cell, subCell, null, check);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanEnterCell(World world, Actor self, CPos cell, Actor ignoreActor, CellConditions check = CellConditions.All)
|
|
||||||
{
|
|
||||||
return CanEnterCell(world, self, cell, -1, ignoreActor, check);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanEnterCell(World world, Actor self, CPos cell, int subCell = -1, Actor ignoreActor = null, CellConditions check = CellConditions.All)
|
|
||||||
{
|
{
|
||||||
if (MovementCostForCell(world, cell) == int.MaxValue)
|
if (MovementCostForCell(world, cell) == int.MaxValue)
|
||||||
return false;
|
return false;
|
||||||
@@ -318,9 +303,17 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
public void SetPosition(Actor self, CPos cell, int subCell = -1)
|
public void SetPosition(Actor self, CPos cell, int subCell = -1)
|
||||||
{
|
{
|
||||||
SetLocation(cell, fromSubCell, cell, fromSubCell);
|
// Try same sub-cell
|
||||||
SetVisualPosition(self, self.World.Map.CenterOfCell(fromCell)
|
if (subCell < 0)
|
||||||
+ self.World.Map.SubCellOffsets[subCell >= 0 ? subCell : fromSubCell]);
|
subCell = fromSubCell;
|
||||||
|
|
||||||
|
// Fix sub-cell assignment
|
||||||
|
if (Info.SharesCell != (subCell != 0))
|
||||||
|
subCell = Info.SharesCell ? self.World.Map.SubCellDefaultIndex : 0;
|
||||||
|
|
||||||
|
SetLocation(cell, subCell, cell, subCell);
|
||||||
|
SetVisualPosition(self, self.World.Map.CenterOfCell(cell)
|
||||||
|
+ self.World.Map.SubCellOffsets[subCell]);
|
||||||
FinishedMoving(self);
|
FinishedMoving(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +469,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsMovingFrom(CPos location, int subCell = -1)
|
public bool IsLeaving(CPos location, int subCell = -1)
|
||||||
{
|
{
|
||||||
return toCell != location && __fromCell == location
|
return toCell != location && __fromCell == location
|
||||||
&& (subCell == -1 || fromSubCell == subCell || subCell == 0 || fromSubCell == 0);
|
&& (subCell == -1 || fromSubCell == subCell || subCell == 0 || fromSubCell == 0);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA
|
|||||||
foreach (var s in unitGroup.SupportActors)
|
foreach (var s in unitGroup.SupportActors)
|
||||||
{
|
{
|
||||||
var mi = w.Map.Rules.Actors[s.ToLowerInvariant()].Traits.Get<MobileInfo>();
|
var mi = w.Map.Rules.Actors[s.ToLowerInvariant()].Traits.Get<MobileInfo>();
|
||||||
var validCells = supportSpawnCells.Where(c => mi.CanEnterCell(w, c));
|
var validCells = supportSpawnCells.Where(c => mi.CanEnterCell(w, null, c));
|
||||||
if (!validCells.Any())
|
if (!validCells.Any())
|
||||||
throw new InvalidOperationException("No cells available to spawn starting unit {0}".F(s));
|
throw new InvalidOperationException("No cells available to spawn starting unit {0}".F(s));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user