Allow bot players to be created via map.yaml

This commit is contained in:
Paul Chote
2011-06-03 09:14:41 +12:00
parent 64497c9b2f
commit fe5ef82cdf
3 changed files with 9 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ namespace OpenRA.FileFormats
public bool OwnsWorld = false;
public bool NonCombatant = false;
public bool Playable = false;
public string Bot = null;
public bool DefaultStartingUnits = false;
public bool AllowBots = true;

View File

@@ -63,6 +63,7 @@ namespace OpenRA
ColorRamp = pr.ColorRamp;
PlayerName = pr.Name;
NonCombatant = pr.NonCombatant;
IsBot = pr.Bot != null;
Country = world.GetCountries()
.FirstOrDefault(c => pr.Race == c.Race)
@@ -70,6 +71,11 @@ namespace OpenRA
}
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
if (IsBot)
PlayerActor.TraitsImplementing<IBot>()
.Single(b => b.Info.Name == pr.Bot)
.Activate(this);
}
public void GiveAdvice(string advice)

View File

@@ -45,6 +45,7 @@ namespace OpenRA.Mods.RA
if (client.Index == Game.LocalClientId)
w.SetLocalPlayer(player.Index); // bind this one to the local player.
}
// TODO: This is shit. Merge it up into Player ctor?
else if (slot.Bot != null && slot.MapPlayer != null)
{
/* spawn a bot in this slot, "owned" by the host */