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:
@@ -210,6 +210,8 @@
|
|||||||
<Compile Include="ObjectCreator.cs" />
|
<Compile Include="ObjectCreator.cs" />
|
||||||
<Compile Include="Network\SyncReport.cs" />
|
<Compile Include="Network\SyncReport.cs" />
|
||||||
<Compile Include="Traits\BaseBuilding.cs" />
|
<Compile Include="Traits\BaseBuilding.cs" />
|
||||||
|
<Compile Include="Server\IServerExtension.cs" />
|
||||||
|
<Compile Include="Server\NullServerExtension.cs" />
|
||||||
<Compile Include="Traits\EditorAppearance.cs" />
|
<Compile Include="Traits\EditorAppearance.cs" />
|
||||||
<Compile Include="Traits\ValidateOrder.cs" />
|
<Compile Include="Traits\ValidateOrder.cs" />
|
||||||
<Compile Include="Traits\Scale.cs" />
|
<Compile Include="Traits\Scale.cs" />
|
||||||
@@ -251,4 +253,4 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="ServerTraits\" />
|
<Folder Include="ServerTraits\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#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
|
|
||||||
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
|
||||||
{
|
|
||||||
/* tag trait for "bases": mcv/fact */
|
|
||||||
public class BaseBuildingInfo : TraitInfo<BaseBuilding> { }
|
|
||||||
public class BaseBuilding { }
|
|
||||||
}
|
|
||||||
@@ -241,4 +241,6 @@ namespace OpenRA.Traits
|
|||||||
string[] TargetTypes { get; }
|
string[] TargetTypes { get; }
|
||||||
IEnumerable<int2> TargetableCells( Actor self );
|
IEnumerable<int2> TargetableCells( Actor self );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface INotifyKeyPress { bool KeyPressed(Actor self, KeyInput e); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,13 +134,14 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
world.Selection.DoControlGroup(world, e.KeyName[0] - '0', e.Modifiers);
|
world.Selection.DoControlGroup(world, e.KeyName[0] - '0', e.Modifiers);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.KeyChar == '\b' || e.KeyChar == (char)127)
|
bool handled = false;
|
||||||
{
|
|
||||||
GotoNextBase();
|
foreach (var t in world.WorldActor.TraitsImplementing<INotifyKeyPress>())
|
||||||
return true;
|
handled = (t.KeyPressed(world.WorldActor, e)) ? true : handled;
|
||||||
}
|
|
||||||
|
if (handled) return true;
|
||||||
|
|
||||||
if (e.KeyChar == 'a')
|
if (e.KeyChar == 'a')
|
||||||
{
|
{
|
||||||
@@ -157,24 +158,6 @@ namespace OpenRA.Widgets
|
|||||||
world.OrderGenerator = new GenericSelectTarget(world.Selection.Actors, "AttackMove", "attackmove");
|
world.OrderGenerator = new GenericSelectTarget(world.Selection.Actors, "AttackMove", "attackmove");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GotoNextBase()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerable<Actor> SelectActorsInBox(World world, float2 a, float2 b)
|
IEnumerable<Actor> SelectActorsInBox(World world, float2 a, float2 b)
|
||||||
{
|
{
|
||||||
return world.FindUnits(a, b)
|
return world.FindUnits(a, b)
|
||||||
|
|||||||
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="Activities\Wait.cs" />
|
||||||
<Compile Include="AttackBase.cs" />
|
<Compile Include="AttackBase.cs" />
|
||||||
<Compile Include="AttackMove.cs" />
|
<Compile Include="AttackMove.cs" />
|
||||||
|
<Compile Include="BaseBuilding.cs" />
|
||||||
<Compile Include="Buildable.cs" />
|
<Compile Include="Buildable.cs" />
|
||||||
<Compile Include="Buildings\BibLayer.cs" />
|
<Compile Include="Buildings\BibLayer.cs" />
|
||||||
<Compile Include="Buildings\Building.cs" />
|
<Compile Include="Buildings\Building.cs" />
|
||||||
@@ -288,6 +289,7 @@
|
|||||||
<Compile Include="NullLoadScreen.cs" />
|
<Compile Include="NullLoadScreen.cs" />
|
||||||
<Compile Include="Activities\IdleAnimation.cs" />
|
<Compile Include="Activities\IdleAnimation.cs" />
|
||||||
<Compile Include="IdleAnimation.cs" />
|
<Compile Include="IdleAnimation.cs" />
|
||||||
|
<Compile Include="World\GotoNextBase.cs" />
|
||||||
<Compile Include="World\SmudgeLayer.cs" />
|
<Compile Include="World\SmudgeLayer.cs" />
|
||||||
<Compile Include="Scripting\Media.cs" />
|
<Compile Include="Scripting\Media.cs" />
|
||||||
<Compile Include="OpenWidgetAtGameStart.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -183,6 +183,7 @@ World:
|
|||||||
WaterChance: 0
|
WaterChance: 0
|
||||||
PathFinder:
|
PathFinder:
|
||||||
ValidateOrder:
|
ValidateOrder:
|
||||||
|
GotoNextBase:
|
||||||
|
|
||||||
CRATE:
|
CRATE:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ World:
|
|||||||
ReturnToLobby: yes
|
ReturnToLobby: yes
|
||||||
EndMessage: The game will end in {0} seconds.
|
EndMessage: The game will end in {0} seconds.
|
||||||
ValidateOrder:
|
ValidateOrder:
|
||||||
|
GotoNextBase:
|
||||||
|
|
||||||
MINP:
|
MINP:
|
||||||
Mine:
|
Mine:
|
||||||
|
|||||||
Reference in New Issue
Block a user