add enumeration of bots

This commit is contained in:
Chris Forbes
2010-12-21 18:13:38 +13:00
parent 7ef884532d
commit 29fbeb2c5d
4 changed files with 16 additions and 5 deletions

View File

@@ -33,8 +33,18 @@ using XRandom = OpenRA.Thirdparty.Random;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class HackyAIInfo : ITraitInfo interface IBotInfo
{ {
string Name { get; }
}
class HackyAIInfo : IBotInfo, ITraitInfo
{
[FieldLoader.Load]
public readonly string Name;
string IBotInfo.Name { get { return this.Name; } }
[FieldLoader.LoadUsing("LoadUnits")] [FieldLoader.LoadUsing("LoadUnits")]
public readonly Dictionary<string, float> UnitsToBuild = null; public readonly Dictionary<string, float> UnitsToBuild = null;

View File

@@ -162,7 +162,7 @@ namespace OpenRA.Mods.RA.Server
{ {
var parts = s.Split(' '); var parts = s.Split(' ');
if (parts.Length != 2) if (parts.Length < 2)
{ {
server.SendChatTo( conn, "Malformed slot_bot command" ); server.SendChatTo( conn, "Malformed slot_bot command" );
return true; return true;
@@ -181,7 +181,7 @@ namespace OpenRA.Mods.RA.Server
return true; return true;
} }
slotData.Bot = parts[1]; slotData.Bot = string.Join(" ", parts.Skip(1).ToArray() );
server.SyncLobbyInfo(); server.SyncLobbyInfo();
return true; return true;

View File

@@ -211,7 +211,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
if (showBotOptions) if (showBotOptions)
{ {
var bots = new string[] { "HackyAI" }; var bots = Rules.Info["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
bots.Do(bot => bots.Do(bot =>
dropDownOptions.Add(new Pair<string, Action>("Bot: {0}".F(bot), dropDownOptions.Add(new Pair<string, Action>("Bot: {0}".F(bot),
() => orderManager.IssueOrder(Order.Command("slot_bot {0} {1}".F(slot.Index, bot)))))); () => orderManager.IssueOrder(Order.Command("slot_bot {0} {1}".F(slot.Index, bot))))));

View File

@@ -32,7 +32,8 @@ Player:
InitialCash: 5000 InitialCash: 5000
ActorGroupProxy: ActorGroupProxy:
DeveloperMode: DeveloperMode:
HackyAI: HackyAI@Default:
Name:Easy AI
BuildingFractions: BuildingFractions:
proc: 20% proc: 20%
barr: 5% barr: 5%