Allow maps to be loaded directly, bypassing the MapCache.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
e186dc428e
commit
fceb8a479d
@@ -181,7 +181,16 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static event Action BeforeGameStart = () => { };
|
public static event Action BeforeGameStart = () => { };
|
||||||
public static event Action AfterGameStart = () => { };
|
public static event Action AfterGameStart = () => { };
|
||||||
internal static void StartGame(string mapUID, WorldType type)
|
internal static void StartGame(string uid, WorldType type)
|
||||||
|
{
|
||||||
|
var preview = ModData.MapCache[uid];
|
||||||
|
if (preview.Status != MapStatus.Available)
|
||||||
|
throw new InvalidDataException($"Invalid map uid: {uid}");
|
||||||
|
|
||||||
|
StartGame(preview.ToMap(), type);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void StartGame(Map map, WorldType type)
|
||||||
{
|
{
|
||||||
// Dispose of the old world before creating a new one.
|
// Dispose of the old world before creating a new one.
|
||||||
worldRenderer?.Dispose();
|
worldRenderer?.Dispose();
|
||||||
@@ -190,7 +199,10 @@ namespace OpenRA
|
|||||||
BeforeGameStart();
|
BeforeGameStart();
|
||||||
|
|
||||||
using (new PerfTimer("NewWorld"))
|
using (new PerfTimer("NewWorld"))
|
||||||
OrderManager.World = new World(mapUID, ModData, OrderManager, type);
|
{
|
||||||
|
ModData.PrepareMap(map);
|
||||||
|
OrderManager.World = new World(map, ModData, OrderManager, type);
|
||||||
|
}
|
||||||
|
|
||||||
OrderManager.World.GameOver += FinishBenchmark;
|
OrderManager.World.GameOver += FinishBenchmark;
|
||||||
|
|
||||||
@@ -507,10 +519,16 @@ namespace OpenRA
|
|||||||
ModData.LoadScreen.StartGame(args);
|
ModData.LoadScreen.StartGame(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadEditor(string mapUid)
|
public static void LoadEditor(string uid)
|
||||||
{
|
{
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
StartGame(mapUid, WorldType.Editor);
|
StartGame(uid, WorldType.Editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LoadEditor(Map map)
|
||||||
|
{
|
||||||
|
JoinLocal();
|
||||||
|
StartGame(map, WorldType.Editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadShellMap()
|
public static void LoadShellMap()
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileSystem;
|
using OpenRA.FileSystem;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
@@ -141,15 +140,11 @@ namespace OpenRA
|
|||||||
|
|
||||||
public IEnumerable<string> Languages { get; }
|
public IEnumerable<string> Languages { get; }
|
||||||
|
|
||||||
public Map PrepareMap(string uid)
|
public void PrepareMap(Map map)
|
||||||
{
|
{
|
||||||
LoadScreen?.Display();
|
LoadScreen?.Display();
|
||||||
|
|
||||||
if (MapCache[uid].Status != MapStatus.Available)
|
|
||||||
throw new InvalidDataException($"Invalid map uid: {uid}");
|
|
||||||
|
|
||||||
// Reinitialize all our assets
|
// Reinitialize all our assets
|
||||||
var map = MapCache[uid].ToMap();
|
|
||||||
InitializeLoaders(map);
|
InitializeLoaders(map);
|
||||||
map.Sequences.LoadSprites();
|
map.Sequences.LoadSprites();
|
||||||
|
|
||||||
@@ -157,8 +152,6 @@ namespace OpenRA
|
|||||||
using (new Support.PerfTimer("Map.Music"))
|
using (new Support.PerfTimer("Map.Music"))
|
||||||
foreach (var entry in map.Rules.Music)
|
foreach (var entry in map.Rules.Music)
|
||||||
entry.Value.Load(map);
|
entry.Value.Load(map);
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MiniYamlNode>[] GetRulesYaml()
|
public List<MiniYamlNode>[] GetRulesYaml()
|
||||||
|
|||||||
@@ -188,13 +188,12 @@ namespace OpenRA
|
|||||||
|
|
||||||
bool wasLoadingGameSave;
|
bool wasLoadingGameSave;
|
||||||
|
|
||||||
internal World(string mapUID, ModData modData, OrderManager orderManager, WorldType type)
|
internal World(Map map, ModData modData, OrderManager orderManager, WorldType type)
|
||||||
{
|
{
|
||||||
this.modData = modData;
|
this.modData = modData;
|
||||||
Type = type;
|
Type = type;
|
||||||
OrderManager = orderManager;
|
OrderManager = orderManager;
|
||||||
using (new PerfTimer("PrepareMap"))
|
Map = map;
|
||||||
Map = modData.PrepareMap(mapUID);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(modData.Manifest.DefaultOrderGenerator))
|
if (string.IsNullOrEmpty(modData.Manifest.DefaultOrderGenerator))
|
||||||
throw new InvalidDataException("mod.yaml must define a DefaultOrderGenerator");
|
throw new InvalidDataException("mod.yaml must define a DefaultOrderGenerator");
|
||||||
|
|||||||
Reference in New Issue
Block a user