wire up bot creation properly in CreateMPPlayers etc

This commit is contained in:
Chris Forbes
2010-12-21 18:20:23 +13:00
parent 29fbeb2c5d
commit d320a689a2
4 changed files with 12 additions and 10 deletions

View File

@@ -184,7 +184,12 @@ namespace OpenRA.Traits
public interface IWorldLoaded { void WorldLoaded(World w); } public interface IWorldLoaded { void WorldLoaded(World w); }
public interface ICreatePlayers { void CreatePlayers(World w); } public interface ICreatePlayers { void CreatePlayers(World w); }
public interface IBot { void Activate(Player p); } public interface IBotInfo { string Name { get; } }
public interface IBot
{
void Activate(Player p);
IBotInfo Info { get; }
}
public interface IActivity public interface IActivity
{ {

View File

@@ -59,10 +59,11 @@ namespace OpenRA.Mods.RA
var player = new Player(w, w.Map.Players[slot.MapPlayer], playerIndex++); var player = new Player(w, w.Map.Players[slot.MapPlayer], playerIndex++);
w.AddPlayer(player); w.AddPlayer(player);
/* todo: only activate the bot option that's selected! */ /* activate the bot option that's selected! */
if (Game.IsHost) if (Game.IsHost)
foreach (var bot in player.PlayerActor.TraitsImplementing<IBot>()) player.PlayerActor.TraitsImplementing<IBot>()
bot.Activate(player); .Single(b => b.Info.Name == slot.Bot)
.Activate(player);
/* a bit of a hack */ /* a bit of a hack */
player.IsBot = true; player.IsBot = true;

View File

@@ -33,11 +33,6 @@ using XRandom = OpenRA.Thirdparty.Random;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
interface IBotInfo
{
string Name { get; }
}
class HackyAIInfo : IBotInfo, ITraitInfo class HackyAIInfo : IBotInfo, ITraitInfo
{ {
[FieldLoader.Load] [FieldLoader.Load]
@@ -84,6 +79,7 @@ namespace OpenRA.Mods.RA
BaseBuilder[] builders; BaseBuilder[] builders;
World world { get { return p.PlayerActor.World; } } World world { get { return p.PlayerActor.World; } }
IBotInfo IBot.Info { get { return this.Info; } }
readonly HackyAIInfo Info; readonly HackyAIInfo Info;
public HackyAI(HackyAIInfo Info) public HackyAI(HackyAIInfo Info)

View File

@@ -14,7 +14,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Network; using OpenRA.Network;
using OpenRA.Graphics; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Delegates namespace OpenRA.Mods.RA.Widgets.Delegates