add a World type

This commit is contained in:
Matthias Mailänder
2014-12-27 19:00:03 +01:00
parent dbbc790dab
commit 9d2f33d42c
5 changed files with 17 additions and 12 deletions

View File

@@ -135,7 +135,7 @@ namespace OpenRA
}
public static event Action BeforeGameStart = () => { };
internal static void StartGame(string mapUID, bool isShellmap)
internal static void StartGame(string mapUID, WorldType type)
{
Cursor.SetCursor(null);
BeforeGameStart();
@@ -146,14 +146,15 @@ namespace OpenRA
map = ModData.PrepareMap(mapUID);
using (new PerfTimer("NewWorld"))
{
OrderManager.World = new World(map, OrderManager, isShellmap);
OrderManager.World = new World(map, OrderManager, type);
OrderManager.World.Timestep = Timestep;
}
if (worldRenderer != null)
worldRenderer.Dispose();
worldRenderer = new WorldRenderer(OrderManager.World);
using (new PerfTimer("LoadComplete"))
OrderManager.World.LoadComplete(worldRenderer);
@@ -375,7 +376,7 @@ namespace OpenRA
var shellmap = ChooseShellmap();
using (new PerfTimer("StartGame"))
StartGame(shellmap, true);
StartGame(shellmap, WorldType.Shellmap);
}
static string ChooseShellmap()

View File

@@ -107,7 +107,7 @@ namespace OpenRA.Graphics
{
RefreshPalette();
if (World.IsShellmap && !Game.Settings.Game.ShowShellmap)
if (World.Type == WorldType.Shellmap && !Game.Settings.Game.ShowShellmap)
return;
var renderables = GenerateRenderables();
@@ -156,7 +156,7 @@ namespace OpenRA.Graphics
foreach (var r in g)
r.RenderDebugGeometry(this);
if (!World.IsShellmap && Game.Settings.Game.AlwaysShowStatusBars)
if (World.Type == WorldType.Regular && Game.Settings.Game.AlwaysShowStatusBars)
{
foreach (var g in World.Actors.Where(a => !a.Destroyed
&& a.HasTrait<Selectable>()

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Network
}
Game.AddChatLine(Color.White, "Server", "The game has started.");
Game.StartGame(orderManager.LobbyInfo.GlobalSettings.Map, false);
Game.StartGame(orderManager.LobbyInfo.GlobalSettings.Map, WorldType.Regular);
break;
}

View File

@@ -22,6 +22,8 @@ using OpenRA.Traits;
namespace OpenRA
{
public enum WorldType { Regular, Shellmap }
public class World
{
static readonly Func<int, int, bool> FalsePredicate = (u, v) => false;
@@ -109,6 +111,8 @@ namespace OpenRA
public readonly TileSet TileSet;
public readonly ActorMap ActorMap;
public readonly ScreenMap ScreenMap;
public readonly WorldType Type;
readonly GameInformation gameInfo;
public void IssueOrder(Order o) { OrderManager.IssueOrder(o); } /* avoid exposing the OM to mod code */
@@ -146,9 +150,9 @@ namespace OpenRA
}
}
internal World(Map map, OrderManager orderManager, bool isShellmap)
internal World(Map map, OrderManager orderManager, WorldType type)
{
IsShellmap = isShellmap;
Type = type;
OrderManager = orderManager;
orderGenerator = new UnitOrderGenerator();
Map = map;
@@ -242,7 +246,7 @@ namespace OpenRA
public bool Paused { get; internal set; }
public bool PredictedPaused { get; internal set; }
public bool PauseStateLocked { get; set; }
public bool IsShellmap = false;
public int WorldTick { get; private set; }
public void SetPauseState(bool paused)
@@ -261,7 +265,7 @@ namespace OpenRA
public void Tick()
{
if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap))
if (!Paused && (Type != WorldType.Shellmap || Game.Settings.Game.ShowShellmap))
{
WorldTick++;

View File

@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
if (installButton != null)
{
installButton.IsDisabled = () => world == null || !world.IsShellmap;
installButton.IsDisabled = () => world == null || world.Type != WorldType.Shellmap;
var args = new string[] { "Install.Music=true" };
installButton.OnClick = () =>
{