Make infantry crushable, refactoring, fix UIM (in)sanity crash, fix unit production
This commit is contained in:
@@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits
|
||||
public IEnumerable<UnitMovementType> CrushableBy()
|
||||
{
|
||||
yield return UnitMovementType.Track;
|
||||
yield return UnitMovementType.Wheel;
|
||||
//yield return UnitMovementType.Wheel; // Can infantry be crushed by wheel?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,31 +84,16 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
if (Game.BuildingInfluence.GetBuildingAt(a) != null) return false;
|
||||
|
||||
var actors = Game.UnitInfluence.GetUnitsAt(a);
|
||||
var crushable = true;
|
||||
foreach (Actor actor in actors)
|
||||
foreach (Actor actor in Game.UnitInfluence.GetUnitsAt(a))
|
||||
{
|
||||
if (actor == self) continue;
|
||||
|
||||
var c = actor.traits.WithInterface<ICrushable>();
|
||||
if (c == null)
|
||||
if (!Game.IsActorCrushableByActor(actor, self))
|
||||
{
|
||||
crushable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var crush in c)
|
||||
{
|
||||
// TODO: Unhack this. I can't wrap my head around this right now...
|
||||
if (!(((crush.IsCrushableByEnemy() && actor.Owner != Game.LocalPlayer) || (crush.IsCrushableByFriend() && actor.Owner == Game.LocalPlayer))
|
||||
&& crush.CrushableBy().Contains(GetMovementType())))
|
||||
{
|
||||
crushable = false;
|
||||
Log.Write("{0} is NOT crushable by {1} (mobile)", actor.Info.Name, self.Info.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log.Write("{0} is crushable by {1} (mobile)", actor.Info.Name, self.Info.Name);
|
||||
}
|
||||
|
||||
if (!crushable) return false;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRa.Game.Traits
|
||||
public bool Produce( Actor self, UnitInfo producee )
|
||||
{
|
||||
var location = CreationLocation( self, producee );
|
||||
if( location == null || !Game.UnitInfluence.GetUnitsAt( location.Value ).Any() )
|
||||
if( location == null || Game.UnitInfluence.GetUnitsAt( location.Value ).Any() )
|
||||
return false;
|
||||
|
||||
var newUnit = new Actor( producee, location.Value, self.Owner );
|
||||
|
||||
@@ -46,9 +46,11 @@ namespace OpenRa.Game
|
||||
[Conditional( "SANITY_CHECKS" )]
|
||||
void SanityCheckAdd( IOccupySpace a )
|
||||
{
|
||||
/* This check is too strict now that we can have multiple units in a cell
|
||||
foreach( var c in a.OccupiedCells() )
|
||||
if( influence[c.X, c.Y].Any())
|
||||
throw new InvalidOperationException( "UIM: Sanity check failed (Add)" );
|
||||
*/
|
||||
}
|
||||
|
||||
public IEnumerable<Actor> GetUnitsAt( int2 a )
|
||||
|
||||
Reference in New Issue
Block a user