Moved: BaseBuilding out of core => RA
Implemented: INotifyKeyPress for World traits (to respond on key pressed) Moved: GotoNextBase (backspace key) out of core => RA Added: GotoNextBase trait to both RA & CNC
This commit is contained in:
8
OpenRA.Mods.RA/BaseBuilding.cs
Normal file
8
OpenRA.Mods.RA/BaseBuilding.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
/* tag trait for "bases": mcv/fact */
|
||||
public class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
|
||||
public class BaseBuilding { }
|
||||
}
|
||||
@@ -82,6 +82,7 @@
|
||||
<Compile Include="Activities\Wait.cs" />
|
||||
<Compile Include="AttackBase.cs" />
|
||||
<Compile Include="AttackMove.cs" />
|
||||
<Compile Include="BaseBuilding.cs" />
|
||||
<Compile Include="Buildable.cs" />
|
||||
<Compile Include="Buildings\BibLayer.cs" />
|
||||
<Compile Include="Buildings\Building.cs" />
|
||||
@@ -288,6 +289,7 @@
|
||||
<Compile Include="NullLoadScreen.cs" />
|
||||
<Compile Include="Activities\IdleAnimation.cs" />
|
||||
<Compile Include="IdleAnimation.cs" />
|
||||
<Compile Include="World\GotoNextBase.cs" />
|
||||
<Compile Include="World\SmudgeLayer.cs" />
|
||||
<Compile Include="Scripting\Media.cs" />
|
||||
<Compile Include="OpenWidgetAtGameStart.cs" />
|
||||
|
||||
44
OpenRA.Mods.RA/World/GotoNextBase.cs
Normal file
44
OpenRA.Mods.RA/World/GotoNextBase.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class GotoNextBaseInfo : TraitInfo<GotoNextBase>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class GotoNextBase : INotifyKeyPress
|
||||
{
|
||||
public bool KeyPressed(Actor self, KeyInput e)
|
||||
{
|
||||
if (self.World.LocalPlayer == null) return false;
|
||||
|
||||
if (e.KeyChar == '\b' || e.KeyChar == (char)127)
|
||||
{
|
||||
CycleBases(self.World);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void CycleBases(World world)
|
||||
{
|
||||
var bases = world.Queries.OwnedBy[world.LocalPlayer].WithTrait<BaseBuilding>().ToArray();
|
||||
if (!bases.Any()) return;
|
||||
|
||||
var next = bases
|
||||
.Select(b => b.Actor)
|
||||
.SkipWhile(b => !world.Selection.Actors.Contains(b))
|
||||
.Skip(1)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (next == null)
|
||||
next = bases.Select(b => b.Actor).First();
|
||||
|
||||
world.Selection.Combine(world, new Actor[] { next }, false, true);
|
||||
Game.viewport.Center(world.Selection.Actors);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user