Add support for custom locations to legacy map importer
For example, to place actors with changed footprint correctly. Use it to ensure correct positioning of several RA and TD structures as well as TD tiberium trees.
This commit is contained in:
@@ -116,6 +116,17 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
|||||||
return input.Split(',')[0].ToLowerInvariant();
|
return input.Split(',')[0].ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override CPos ParseActorLocation(string input, int loc)
|
||||||
|
{
|
||||||
|
var newLoc = new CPos(loc % MapSize, loc / MapSize);
|
||||||
|
var vectorDown = new CVec(0, 1);
|
||||||
|
|
||||||
|
if (input == "obli" || input == "atwr" || input == "weap" || input == "hand" || input == "tmpl" || input == "split2" || input == "split3")
|
||||||
|
newLoc += vectorDown;
|
||||||
|
|
||||||
|
return newLoc;
|
||||||
|
}
|
||||||
|
|
||||||
public override void LoadPlayer(IniFile file, string section)
|
public override void LoadPlayer(IniFile file, string section)
|
||||||
{
|
{
|
||||||
string color;
|
string color;
|
||||||
|
|||||||
@@ -365,7 +365,12 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
mapPlayers.Players[section] = pr;
|
mapPlayers.Players[section] = pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadActors(IniFile file, string section, List<string> players, int mapSize, Map map)
|
public virtual CPos ParseActorLocation(string input, int loc)
|
||||||
|
{
|
||||||
|
return new CPos(loc % MapSize, loc / MapSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadActors(IniFile file, string section, List<string> players, int mapSize, Map map)
|
||||||
{
|
{
|
||||||
foreach (var s in file.GetSection(section, true))
|
foreach (var s in file.GetSection(section, true))
|
||||||
{
|
{
|
||||||
@@ -385,8 +390,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
var health = Exts.ParseIntegerInvariant(parts[2]) * 100 / 256;
|
var health = Exts.ParseIntegerInvariant(parts[2]) * 100 / 256;
|
||||||
var facing = (section == "INFANTRY") ? Exts.ParseIntegerInvariant(parts[6]) : Exts.ParseIntegerInvariant(parts[4]);
|
var facing = (section == "INFANTRY") ? Exts.ParseIntegerInvariant(parts[6]) : Exts.ParseIntegerInvariant(parts[4]);
|
||||||
|
|
||||||
var actor = new ActorReference(parts[1].ToLowerInvariant()) {
|
var actorType = parts[1].ToLowerInvariant();
|
||||||
new LocationInit(new CPos(loc % mapSize, loc / mapSize)),
|
|
||||||
|
var actor = new ActorReference(actorType) {
|
||||||
|
new LocationInit(ParseActorLocation(actorType, loc)),
|
||||||
new OwnerInit(parts[0]),
|
new OwnerInit(parts[0]),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -424,9 +431,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
foreach (var kv in terrain)
|
foreach (var kv in terrain)
|
||||||
{
|
{
|
||||||
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
var loc = Exts.ParseIntegerInvariant(kv.Key);
|
||||||
var ar = new ActorReference(ParseTreeActor(kv.Value))
|
var treeActor = ParseTreeActor(kv.Value);
|
||||||
|
|
||||||
|
var ar = new ActorReference(treeActor)
|
||||||
{
|
{
|
||||||
new LocationInit(new CPos(loc % MapSize, loc / MapSize)),
|
new LocationInit(ParseActorLocation(treeActor, loc)),
|
||||||
new OwnerInit("Neutral")
|
new OwnerInit("Neutral")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,17 @@ namespace OpenRA.Mods.RA.UtilityCommands
|
|||||||
return input.ToLowerInvariant();
|
return input.ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override CPos ParseActorLocation(string input, int loc)
|
||||||
|
{
|
||||||
|
var newLoc = new CPos(loc % MapSize, loc / MapSize);
|
||||||
|
var vectorDown = new CVec(0, 1);
|
||||||
|
|
||||||
|
if (input == "tsla" || input == "agun" || input == "gap" || input == "apwr" || input == "iron")
|
||||||
|
newLoc += vectorDown;
|
||||||
|
|
||||||
|
return newLoc;
|
||||||
|
}
|
||||||
|
|
||||||
public override void LoadPlayer(IniFile file, string section)
|
public override void LoadPlayer(IniFile file, string section)
|
||||||
{
|
{
|
||||||
string color;
|
string color;
|
||||||
|
|||||||
Reference in New Issue
Block a user