Fold SharesCell into Mobile

This commit is contained in:
Paul Chote
2011-02-03 19:05:05 +13:00
parent 4b3c6cc62a
commit 7c2a7db794
5 changed files with 60 additions and 74 deletions

View File

@@ -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>
@@ -204,7 +204,6 @@
<Compile Include="Traits\ValidateOrder.cs" />
<Compile Include="TraitDictionary.cs" />
<Compile Include="Traits\Activities\CancelableActivity.cs" />
<Compile Include="Traits\SharesCell.cs" />
<Compile Include="Widgets\PasswordFieldWidget.cs" />
<Compile Include="Widgets\ScrollingTextWidget.cs" />
</ItemGroup>

View File

@@ -1,64 +0,0 @@
using OpenRA.FileFormats;
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
namespace OpenRA.Traits
{
class SharesCellInfo : ITraitInfo
{
public object Create(ActorInitializer init) { return new SharesCell(init); }
}
public class SharesCell : IOffsetCenterLocation, ISync
{
[Sync]
public int Position;
public SharesCell(ActorInitializer init)
{
Position = init.Contains<SubcellInit>() ? init.Get<SubcellInit,int>() : 0;
}
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);
}
}}
}
public class SubcellInit : IActorInit<int>
{
[FieldFromYamlKey]
public readonly int value = 0;
public SubcellInit() { }
public SubcellInit( int init )
{
value = init;
}
public int Value( World world )
{
return value;
}
}
}

View File

@@ -148,7 +148,6 @@ namespace OpenRA.Traits
int InitialFacing { get; }
}
public interface IOffsetCenterLocation { float2 CenterOffset { get; } }
public interface ICrushable
{
void OnCrush(Actor crusher);

View File

@@ -49,6 +49,15 @@ namespace OpenRA.Traits
for( var i = influence[ a.X, a.Y ] ; i != null ; i = i.next )
yield return i.actor;
}
public bool HasFreeSubCell(int2 a)
{
if (!AnyUnitsAt(a))
return true;
return new[]{SubCell.BottomLeft, SubCell.BottomRight, SubCell.Center,
SubCell.TopLeft, SubCell.TopRight}.Any(b => !AnyUnitsAt(a,b));
}
public bool AnyUnitsAt(int2 a)
{
@@ -60,7 +69,7 @@ namespace OpenRA.Traits
var node = influence[ a.X, a.Y ];
while (node != null)
{
if (node.subCell == sub) return true;
if (node.subCell == sub || node.subCell == SubCell.FullCell) return true;
node = node.next;
}
return false;