Fix vehicle production; Basic 5-to-a-cell logic. cnc only. Infantry stack; need to give a graphical offset.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -240,6 +240,7 @@
|
||||
<Compile Include="GameRules\MusicInfo.cs" />
|
||||
<Compile Include="Widgets\PowerBinWidget.cs" />
|
||||
<Compile Include="Widgets\ImageWidget.cs" />
|
||||
<Compile Include="Traits\SharesCell.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
@@ -275,4 +276,7 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ItemGroup>
|
||||
<Folder Include="Traits\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA
|
||||
continue;
|
||||
|
||||
var mobile = self.traits.Get<Mobile>();
|
||||
if (checkForBlocked && !mobile.CanEnterCell(newHere))
|
||||
if (checkForBlocked && !mobile.CanEnterCell(newHere, ignoreBuilding))
|
||||
continue;
|
||||
|
||||
if (customBlock != null && customBlock(newHere))
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace OpenRA.Traits.Activities
|
||||
{
|
||||
if( path.Count == 0 ) return null;
|
||||
var nextCell = path[ path.Count - 1 ];
|
||||
if( !mobile.CanEnterCell( nextCell ) )
|
||||
if( !mobile.CanEnterCell( nextCell, ignoreBuilding ) )
|
||||
{
|
||||
if( ( mobile.toCell - destination.Value ).LengthSquared <= nearEnough )
|
||||
{
|
||||
@@ -244,7 +244,6 @@ namespace OpenRA.Traits.Activities
|
||||
var frac = (float)moveFraction / moveFractionTotal;
|
||||
|
||||
self.CenterLocation = float2.Lerp( from, to, frac );
|
||||
// + self.traits.WithInterface<IOffsetCenterLocation>().Aggregate(float2.Zero, (a, x) => a + x.CenterOffset);
|
||||
|
||||
if( moveFraction >= moveFractionTotal )
|
||||
unit.Facing = toFacing & 0xFF;
|
||||
|
||||
@@ -121,12 +121,28 @@ namespace OpenRA.Traits
|
||||
|
||||
public bool CanEnterCell(int2 p)
|
||||
{
|
||||
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(p)) return false;
|
||||
return CanEnterCell(p, null);
|
||||
}
|
||||
|
||||
public bool CanEnterCell(int2 p, Actor ignoreBuilding)
|
||||
{
|
||||
if (!self.World.WorldActor.traits.Get<BuildingInfluence>().CanMoveHere(p, ignoreBuilding)) return false;
|
||||
|
||||
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(p).Any(
|
||||
a => a != self && !self.World.IsActorCrushableByActor(a, self)))
|
||||
var canShare = self.traits.Contains<SharesCell>();
|
||||
var actors = self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(p);
|
||||
var nonshareable = actors.Where(a => a != self && !(canShare && a.traits.Contains<SharesCell>()));
|
||||
var shareable = actors.Where(a => a != self && canShare && a.traits.Contains<SharesCell>());
|
||||
|
||||
// only allow 5 in a cell
|
||||
if (shareable.Count() >= 5)
|
||||
return false;
|
||||
|
||||
// We can enter a cell with nonshareable units if we can crush all of them
|
||||
if (nonshareable.Any(
|
||||
a => !self.World.IsActorCrushableByActor(a, self)))
|
||||
return false;
|
||||
|
||||
|
||||
return self.World.Map.IsInMap(p.X, p.Y) &&
|
||||
Rules.TerrainTypes[self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[p.X, p.Y])]
|
||||
.GetCost(GetMovementType()) < float.PositiveInfinity;
|
||||
|
||||
46
OpenRA.Game/Traits/SharesCell.cs
Normal file
46
OpenRA.Game/Traits/SharesCell.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class SharesCellInfo : TraitInfo<SharesCell> {}
|
||||
public class SharesCell : IOffsetCenterLocation
|
||||
{
|
||||
[Sync]
|
||||
public int Position;
|
||||
|
||||
public float2 CenterOffset
|
||||
{ get {
|
||||
switch (Position)
|
||||
{
|
||||
case 1:
|
||||
return new float2(-5f,-5f);
|
||||
case 2:
|
||||
return new float2(5f,-5f);
|
||||
case 3:
|
||||
return new float2(-5f,5f);
|
||||
case 4:
|
||||
return new float2(5f,5f);
|
||||
default:
|
||||
return new float2(-5f, -5f);
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,7 @@ namespace OpenRA.Traits
|
||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||
}
|
||||
|
||||
public interface IOffsetCenterLocation { float2 CenterOffset { get; } }
|
||||
public interface ICrushable
|
||||
{
|
||||
void OnCrush(Actor crusher);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
RevealsShroud:
|
||||
GainsExperience:
|
||||
GivesExperience:
|
||||
SharesCell:
|
||||
|
||||
^Ship:
|
||||
Category: Ship
|
||||
|
||||
Reference in New Issue
Block a user