Add support for a "Creeps" faction that is hostile to all combatant players. Add a mod field to be used for map installation.

This commit is contained in:
Paul Chote
2011-02-10 21:22:38 +13:00
parent 56952c1ab8
commit fae355f5b6
3 changed files with 32 additions and 9 deletions

View File

@@ -321,6 +321,7 @@ namespace OpenRA.Editor
map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value,
(int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
map.Players.Add("Neutral", new PlayerReference("Neutral", Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
map.Players.Add("Creeps", new PlayerReference("Creeps", Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
NewMap(map);
}
}
@@ -372,7 +373,10 @@ namespace OpenRA.Editor
var map = LegacyMapImporter.Import(ofd.FileName);
map.Players.Add("Neutral", new PlayerReference("Neutral",
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
map.Players.Add("Creeps", new PlayerReference("Creeps",
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
map.Save(savePath);
LoadMap(savePath);
loadedMapName = null; /* editor needs to think this hasnt been saved */

View File

@@ -24,7 +24,8 @@ namespace OpenRA.FileFormats
// Yaml map data
public string Uid { get; protected set; }
[FieldLoader.Load] public bool Selectable;
[FieldLoader.Load] public bool UseAsShellmap;
[FieldLoader.Load] public bool UseAsShellmap;
[FieldLoader.Load] public string RequiresMod;
[FieldLoader.Load] public string Title;
[FieldLoader.Load] public string Type = "Conquest";

View File

@@ -140,6 +140,7 @@ namespace OpenRA
case 3:
case 4:
case 5:
{
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
{
@@ -165,21 +166,40 @@ namespace OpenRA
Name = "Multi{0}".F(index),
Race = "Random",
Playable = true,
DefaultStartingUnits = true
DefaultStartingUnits = true,
Enemies = new[]{"Creeps"}
};
Players.Add(p.Name, p);
}
}
// Color1/Color2 -> ColorRamp
if (MapFormat == 3)
if (MapFormat < 4)
foreach (var mp in Players)
mp.Value.ColorRamp = new ColorRamp(
(byte)((mp.Value.Color.GetHue() / 360.0f) * 255),
(byte)(mp.Value.Color.GetSaturation() * 255),
(byte)(mp.Value.Color.GetBrightness() * 255),
(byte)(mp.Value.Color2.GetBrightness() * 255));
// Creep player / Required Mod
if (MapFormat < 5)
{
RequiresMod = Game.CurrentMods.Keys.First();
foreach (var mp in Players.Where(p => !p.Value.NonCombatant && !p.Value.Enemies.Contains("Creeps")))
mp.Value.Enemies = mp.Value.Enemies.Concat(new[] {"Creeps"}).ToArray();
Players.Add("Creeps", new PlayerReference
{
Name = "Creeps",
Race = "Random",
NonCombatant = true,
Enemies = Players.Keys.Where(k => k != "Neutral").ToArray()
});
}
// Smudges
foreach (var kv in yaml.NodesDict["Smudges"].NodesDict)
{
@@ -206,12 +226,10 @@ namespace OpenRA
public void Save(string toPath)
{
Console.WriteLine("Saving map to path {0}",toPath);
// Todo: save to a zip file in the support dir by default
MapFormat = 4;
MapFormat = 5;
var root = new List<MiniYamlNode>();
foreach (var field in new string[] {"Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight", "UseAsShellmap", "Type"})
foreach (var field in new string[] {"Selectable", "MapFormat", "RequiresMod", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight", "UseAsShellmap", "Type"})
{
var f = this.GetType().GetField(field);
if (f.GetValue(this) == null) continue;