Allow bot players to be created via map.yaml
This commit is contained in:
@@ -20,6 +20,7 @@ namespace OpenRA.FileFormats
|
|||||||
public bool OwnsWorld = false;
|
public bool OwnsWorld = false;
|
||||||
public bool NonCombatant = false;
|
public bool NonCombatant = false;
|
||||||
public bool Playable = false;
|
public bool Playable = false;
|
||||||
|
public string Bot = null;
|
||||||
public bool DefaultStartingUnits = false;
|
public bool DefaultStartingUnits = false;
|
||||||
public bool AllowBots = true;
|
public bool AllowBots = true;
|
||||||
|
|
||||||
|
|||||||
@@ -63,13 +63,19 @@ namespace OpenRA
|
|||||||
ColorRamp = pr.ColorRamp;
|
ColorRamp = pr.ColorRamp;
|
||||||
PlayerName = pr.Name;
|
PlayerName = pr.Name;
|
||||||
NonCombatant = pr.NonCombatant;
|
NonCombatant = pr.NonCombatant;
|
||||||
|
IsBot = pr.Bot != null;
|
||||||
|
|
||||||
Country = world.GetCountries()
|
Country = world.GetCountries()
|
||||||
.FirstOrDefault(c => pr.Race == c.Race)
|
.FirstOrDefault(c => pr.Race == c.Race)
|
||||||
?? world.GetCountries().Random(world.SharedRandom);
|
?? world.GetCountries().Random(world.SharedRandom);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
|
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)
|
public void GiveAdvice(string advice)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (client.Index == Game.LocalClientId)
|
if (client.Index == Game.LocalClientId)
|
||||||
w.SetLocalPlayer(player.Index); // bind this one to the local player.
|
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)
|
else if (slot.Bot != null && slot.MapPlayer != null)
|
||||||
{
|
{
|
||||||
/* spawn a bot in this slot, "owned" by the host */
|
/* spawn a bot in this slot, "owned" by the host */
|
||||||
|
|||||||
Reference in New Issue
Block a user