StyleCop clean OpenRA.Game
This commit is contained in:
2
Makefile
2
Makefile
@@ -179,6 +179,8 @@ test:
|
|||||||
@mono --debug OpenRA.Utility.exe ts --check-yaml
|
@mono --debug OpenRA.Utility.exe ts --check-yaml
|
||||||
|
|
||||||
check:
|
check:
|
||||||
|
@echo "Checking for code style violations in OpenRA.Game..."
|
||||||
|
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Game
|
||||||
@echo "Checking for code style violations in OpenRA.Renderer.Null..."
|
@echo "Checking for code style violations in OpenRA.Renderer.Null..."
|
||||||
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Renderer.Null
|
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Renderer.Null
|
||||||
@echo "Checking for code style violations in OpenRA.GameMonitor..."
|
@echo "Checking for code style violations in OpenRA.GameMonitor..."
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ namespace OpenRA.Editor
|
|||||||
currentMod = toolStripComboBox1.SelectedItem as string;
|
currentMod = toolStripComboBox1.SelectedItem as string;
|
||||||
|
|
||||||
Game.InitializeSettings(Arguments.Empty);
|
Game.InitializeSettings(Arguments.Empty);
|
||||||
Game.modData = new ModData(currentMod);
|
Game.ModData = new ModData(currentMod);
|
||||||
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
|
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest);
|
||||||
Program.Rules = Game.modData.RulesetCache.LoadDefaultRules();
|
Program.Rules = Game.ModData.RulesetCache.LoadDefaultRules();
|
||||||
|
|
||||||
var mod = Game.modData.Manifest.Mod;
|
var mod = Game.ModData.Manifest.Mod;
|
||||||
Text = "{0} Mod Version: {1} - OpenRA Editor".F(mod.Title, mod.Version);
|
Text = "{0} Mod Version: {1} - OpenRA Editor".F(mod.Title, mod.Version);
|
||||||
|
|
||||||
loadedMapName = null;
|
loadedMapName = null;
|
||||||
@@ -129,7 +129,7 @@ namespace OpenRA.Editor
|
|||||||
if (map.Players.Count == 0)
|
if (map.Players.Count == 0)
|
||||||
map.MakeDefaultPlayers();
|
map.MakeDefaultPlayers();
|
||||||
|
|
||||||
PrepareMapResources(Game.modData, map);
|
PrepareMapResources(Game.ModData, map);
|
||||||
|
|
||||||
// Calculate total net worth of resources in cash
|
// Calculate total net worth of resources in cash
|
||||||
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
|
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
|
||||||
@@ -144,7 +144,7 @@ namespace OpenRA.Editor
|
|||||||
resourcePalette.Controls.Clear();
|
resourcePalette.Controls.Clear();
|
||||||
|
|
||||||
loadedMapName = null;
|
loadedMapName = null;
|
||||||
PrepareMapResources(Game.modData, map);
|
PrepareMapResources(Game.ModData, map);
|
||||||
|
|
||||||
MakeDirty();
|
MakeDirty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
using (var g = SGraphics.FromImage(bitmap))
|
using (var g = SGraphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
var ts = Game.modData.Manifest.TileSize;
|
var ts = Game.ModData.Manifest.TileSize;
|
||||||
var rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
|
var rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
|
||||||
ControlPaint.DrawGrid(g, rect, new Size(2, ts.Height), Color.DarkRed);
|
ControlPaint.DrawGrid(g, rect, new Size(2, ts.Height), Color.DarkRed);
|
||||||
ControlPaint.DrawGrid(g, rect, new Size(ts.Width, 2), Color.DarkRed);
|
ControlPaint.DrawGrid(g, rect, new Size(ts.Width, 2), Color.DarkRed);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Editor
|
|||||||
this.TileSize = Math.Min(tileSize.Width, tileSize.Height);
|
this.TileSize = Math.Min(tileSize.Width, tileSize.Height);
|
||||||
|
|
||||||
templates = new Dictionary<ushort, byte[][]>();
|
templates = new Dictionary<ushort, byte[][]>();
|
||||||
var frameCache = new FrameCache(Game.modData.SpriteLoaders, tileset.Extensions);
|
var frameCache = new FrameCache(Game.ModData.SpriteLoaders, tileset.Extensions);
|
||||||
foreach (var t in tileset.Templates)
|
foreach (var t in tileset.Templates)
|
||||||
{
|
{
|
||||||
var allFrames = frameCache[t.Value.Image];
|
var allFrames = frameCache[t.Value.Image];
|
||||||
|
|||||||
@@ -180,27 +180,27 @@ namespace OpenRA
|
|||||||
|
|
||||||
public T Trait<T>()
|
public T Trait<T>()
|
||||||
{
|
{
|
||||||
return World.traitDict.Get<T>(this);
|
return World.TraitDict.Get<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T TraitOrDefault<T>()
|
public T TraitOrDefault<T>()
|
||||||
{
|
{
|
||||||
return World.traitDict.GetOrDefault<T>(this);
|
return World.TraitDict.GetOrDefault<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T> TraitsImplementing<T>()
|
public IEnumerable<T> TraitsImplementing<T>()
|
||||||
{
|
{
|
||||||
return World.traitDict.WithInterface<T>(this);
|
return World.TraitDict.WithInterface<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasTrait<T>()
|
public bool HasTrait<T>()
|
||||||
{
|
{
|
||||||
return World.traitDict.Contains<T>(this);
|
return World.TraitDict.Contains<T>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTrait(object trait)
|
public void AddTrait(object trait)
|
||||||
{
|
{
|
||||||
World.traitDict.AddTrait(this, trait);
|
World.TraitDict.AddTrait(this, trait);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
@@ -213,7 +213,7 @@ namespace OpenRA
|
|||||||
if (IsInWorld)
|
if (IsInWorld)
|
||||||
World.Remove(this);
|
World.Remove(this);
|
||||||
|
|
||||||
World.traitDict.RemoveActor(this);
|
World.TraitDict.RemoveActor(this);
|
||||||
Destroyed = true;
|
Destroyed = true;
|
||||||
|
|
||||||
if (luaInterface != null)
|
if (luaInterface != null)
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ namespace OpenRA
|
|||||||
public const int Timestep = 40;
|
public const int Timestep = 40;
|
||||||
public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms
|
public const int TimestepJankThreshold = 250; // Don't catch up for delays larger than 250ms
|
||||||
|
|
||||||
public static ModData modData;
|
public static ModData ModData;
|
||||||
public static Settings Settings;
|
public static Settings Settings;
|
||||||
public static ICursor Cursor;
|
public static ICursor Cursor;
|
||||||
static WorldRenderer worldRenderer;
|
static WorldRenderer worldRenderer;
|
||||||
|
|
||||||
internal static OrderManager orderManager;
|
internal static OrderManager OrderManager;
|
||||||
static Server.Server server;
|
static Server.Server server;
|
||||||
|
|
||||||
public static MersenneTwister CosmeticRandom = new MersenneTwister(); // not synced
|
public static MersenneTwister CosmeticRandom = new MersenneTwister(); // not synced
|
||||||
@@ -64,10 +64,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
static void JoinInner(OrderManager om)
|
static void JoinInner(OrderManager om)
|
||||||
{
|
{
|
||||||
if (orderManager != null) orderManager.Dispose();
|
if (OrderManager != null) OrderManager.Dispose();
|
||||||
orderManager = om;
|
OrderManager = om;
|
||||||
lastConnectionState = ConnectionState.PreConnecting;
|
lastConnectionState = ConnectionState.PreConnecting;
|
||||||
ConnectionStateChanged(orderManager);
|
ConnectionStateChanged(OrderManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void JoinReplay(string replayFile)
|
public static void JoinReplay(string replayFile)
|
||||||
@@ -85,13 +85,13 @@ namespace OpenRA
|
|||||||
public static int RunTime { get { return (int)Game.stopwatch.ElapsedMilliseconds; } }
|
public static int RunTime { get { return (int)Game.stopwatch.ElapsedMilliseconds; } }
|
||||||
|
|
||||||
public static int RenderFrame = 0;
|
public static int RenderFrame = 0;
|
||||||
public static int NetFrameNumber { get { return orderManager.NetFrameNumber; } }
|
public static int NetFrameNumber { get { return OrderManager.NetFrameNumber; } }
|
||||||
public static int LocalTick { get { return orderManager.LocalFrameNumber; } }
|
public static int LocalTick { get { return OrderManager.LocalFrameNumber; } }
|
||||||
|
|
||||||
public static event Action<string, int> OnRemoteDirectConnect = (a, b) => { };
|
public static event Action<string, int> OnRemoteDirectConnect = (a, b) => { };
|
||||||
public static event Action<OrderManager> ConnectionStateChanged = _ => { };
|
public static event Action<OrderManager> ConnectionStateChanged = _ => { };
|
||||||
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
||||||
public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } }
|
public static int LocalClientId { get { return OrderManager.Connection.LocalClientId; } }
|
||||||
|
|
||||||
public static void RemoteDirectConnect(string host, int port)
|
public static void RemoteDirectConnect(string host, int port)
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ namespace OpenRA
|
|||||||
// Hacky workaround for orderManager visibility
|
// Hacky workaround for orderManager visibility
|
||||||
public static Widget OpenWindow(World world, string widget)
|
public static Widget OpenWindow(World world, string widget)
|
||||||
{
|
{
|
||||||
return Ui.OpenWindow(widget, new WidgetArgs() { { "world", world }, { "orderManager", orderManager }, { "worldRenderer", worldRenderer } });
|
return Ui.OpenWindow(widget, new WidgetArgs() { { "world", world }, { "orderManager", OrderManager }, { "worldRenderer", worldRenderer } });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Who came up with the great idea of making these things
|
// Who came up with the great idea of making these things
|
||||||
@@ -110,8 +110,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
return Ui.OpenWindow(widget, new WidgetArgs(args)
|
return Ui.OpenWindow(widget, new WidgetArgs(args)
|
||||||
{
|
{
|
||||||
{ "world", worldRenderer.world },
|
{ "world", worldRenderer.World },
|
||||||
{ "orderManager", orderManager },
|
{ "orderManager", OrderManager },
|
||||||
{ "worldRenderer", worldRenderer },
|
{ "worldRenderer", worldRenderer },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -119,10 +119,10 @@ namespace OpenRA
|
|||||||
// Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree
|
// Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree
|
||||||
public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args)
|
public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args)
|
||||||
{
|
{
|
||||||
return modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
|
return ModData.WidgetLoader.LoadWidget(new WidgetArgs(args)
|
||||||
{
|
{
|
||||||
{ "world", world },
|
{ "world", world },
|
||||||
{ "orderManager", orderManager },
|
{ "orderManager", OrderManager },
|
||||||
{ "worldRenderer", worldRenderer },
|
{ "worldRenderer", worldRenderer },
|
||||||
}, parent, id);
|
}, parent, id);
|
||||||
}
|
}
|
||||||
@@ -143,29 +143,29 @@ namespace OpenRA
|
|||||||
Map map;
|
Map map;
|
||||||
|
|
||||||
using (new PerfTimer("PrepareMap"))
|
using (new PerfTimer("PrepareMap"))
|
||||||
map = modData.PrepareMap(mapUID);
|
map = ModData.PrepareMap(mapUID);
|
||||||
using (new PerfTimer("NewWorld"))
|
using (new PerfTimer("NewWorld"))
|
||||||
{
|
{
|
||||||
orderManager.World = new World(map, orderManager, isShellmap);
|
OrderManager.World = new World(map, OrderManager, isShellmap);
|
||||||
orderManager.World.Timestep = Timestep;
|
OrderManager.World.Timestep = Timestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldRenderer != null)
|
if (worldRenderer != null)
|
||||||
worldRenderer.Dispose();
|
worldRenderer.Dispose();
|
||||||
worldRenderer = new WorldRenderer(orderManager.World);
|
worldRenderer = new WorldRenderer(OrderManager.World);
|
||||||
|
|
||||||
using (new PerfTimer("LoadComplete"))
|
using (new PerfTimer("LoadComplete"))
|
||||||
orderManager.World.LoadComplete(worldRenderer);
|
OrderManager.World.LoadComplete(worldRenderer);
|
||||||
|
|
||||||
if (orderManager.GameStarted)
|
if (OrderManager.GameStarted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Ui.MouseFocusWidget = null;
|
Ui.MouseFocusWidget = null;
|
||||||
Ui.KeyboardFocusWidget = null;
|
Ui.KeyboardFocusWidget = null;
|
||||||
|
|
||||||
orderManager.LocalFrameNumber = 0;
|
OrderManager.LocalFrameNumber = 0;
|
||||||
orderManager.LastTickTime = RunTime;
|
OrderManager.LastTickTime = RunTime;
|
||||||
orderManager.StartGame();
|
OrderManager.StartGame();
|
||||||
worldRenderer.RefreshPalette();
|
worldRenderer.RefreshPalette();
|
||||||
Cursor.SetCursor("default");
|
Cursor.SetCursor("default");
|
||||||
|
|
||||||
@@ -176,8 +176,8 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var id = orderManager.Connection.LocalClientId;
|
var id = OrderManager.Connection.LocalClientId;
|
||||||
var client = orderManager.LobbyInfo.ClientWithIndex(id);
|
var client = OrderManager.LobbyInfo.ClientWithIndex(id);
|
||||||
return client != null && client.IsAdmin;
|
return client != null && client.IsAdmin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,12 +282,12 @@ namespace OpenRA
|
|||||||
worldRenderer = null;
|
worldRenderer = null;
|
||||||
if (server != null)
|
if (server != null)
|
||||||
server.Shutdown();
|
server.Shutdown();
|
||||||
if (orderManager != null)
|
if (OrderManager != null)
|
||||||
orderManager.Dispose();
|
OrderManager.Dispose();
|
||||||
|
|
||||||
if (modData != null)
|
if (ModData != null)
|
||||||
modData.Dispose();
|
ModData.Dispose();
|
||||||
modData = null;
|
ModData = null;
|
||||||
|
|
||||||
// Fall back to default if the mod doesn't exist
|
// Fall back to default if the mod doesn't exist
|
||||||
if (!ModMetadata.AllMods.ContainsKey(mod))
|
if (!ModMetadata.AllMods.ContainsKey(mod))
|
||||||
@@ -300,18 +300,18 @@ namespace OpenRA
|
|||||||
Sound.StopVideo();
|
Sound.StopVideo();
|
||||||
Sound.Initialize();
|
Sound.Initialize();
|
||||||
|
|
||||||
modData = new ModData(mod, true);
|
ModData = new ModData(mod, true);
|
||||||
|
|
||||||
Renderer.InitializeFonts(modData.Manifest);
|
Renderer.InitializeFonts(ModData.Manifest);
|
||||||
modData.InitializeLoaders();
|
ModData.InitializeLoaders();
|
||||||
using (new PerfTimer("LoadMaps"))
|
using (new PerfTimer("LoadMaps"))
|
||||||
modData.MapCache.LoadMaps();
|
ModData.MapCache.LoadMaps();
|
||||||
|
|
||||||
if (Settings.Graphics.HardwareCursors)
|
if (Settings.Graphics.HardwareCursors)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Cursor = new HardwareCursor(modData.CursorProvider);
|
Cursor = new HardwareCursor(ModData.CursorProvider);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -321,12 +321,12 @@ namespace OpenRA
|
|||||||
Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors.");
|
Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors.");
|
||||||
Console.WriteLine("Error was: " + e.Message);
|
Console.WriteLine("Error was: " + e.Message);
|
||||||
|
|
||||||
Cursor = new SoftwareCursor(modData.CursorProvider);
|
Cursor = new SoftwareCursor(ModData.CursorProvider);
|
||||||
Settings.Graphics.HardwareCursors = false;
|
Settings.Graphics.HardwareCursors = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Cursor = new SoftwareCursor(modData.CursorProvider);
|
Cursor = new SoftwareCursor(ModData.CursorProvider);
|
||||||
|
|
||||||
PerfHistory.Items["render"].HasNormalTick = false;
|
PerfHistory.Items["render"].HasNormalTick = false;
|
||||||
PerfHistory.Items["batches"].HasNormalTick = false;
|
PerfHistory.Items["batches"].HasNormalTick = false;
|
||||||
@@ -357,7 +357,7 @@ namespace OpenRA
|
|||||||
if (Settings.Server.DedicatedLoop)
|
if (Settings.Server.DedicatedLoop)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Starting a new server instance...");
|
Console.WriteLine("Starting a new server instance...");
|
||||||
modData.MapCache.LoadMaps();
|
ModData.MapCache.LoadMaps();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ namespace OpenRA
|
|||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
modData.LoadScreen.StartGame(args);
|
ModData.LoadScreen.StartGame(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadShellMap()
|
public static void LoadShellMap()
|
||||||
@@ -380,7 +380,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
static string ChooseShellmap()
|
static string ChooseShellmap()
|
||||||
{
|
{
|
||||||
var shellmaps = modData.MapCache
|
var shellmaps = ModData.MapCache
|
||||||
.Where(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Shellmap))
|
.Where(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Shellmap))
|
||||||
.Select(m => m.Uid);
|
.Select(m => m.Uid);
|
||||||
|
|
||||||
@@ -471,15 +471,15 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
delayedActions.PerformActions();
|
delayedActions.PerformActions();
|
||||||
|
|
||||||
if (orderManager.Connection.ConnectionState != lastConnectionState)
|
if (OrderManager.Connection.ConnectionState != lastConnectionState)
|
||||||
{
|
{
|
||||||
lastConnectionState = orderManager.Connection.ConnectionState;
|
lastConnectionState = OrderManager.Connection.ConnectionState;
|
||||||
ConnectionStateChanged(orderManager);
|
ConnectionStateChanged(OrderManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
InnerLogicTick(orderManager);
|
InnerLogicTick(OrderManager);
|
||||||
if (worldRenderer != null && orderManager.World != worldRenderer.world)
|
if (worldRenderer != null && OrderManager.World != worldRenderer.World)
|
||||||
InnerLogicTick(worldRenderer.world.orderManager);
|
InnerLogicTick(worldRenderer.World.OrderManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RenderTick()
|
static void RenderTick()
|
||||||
@@ -502,7 +502,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
Ui.Draw();
|
Ui.Draw();
|
||||||
|
|
||||||
if (modData != null && modData.CursorProvider != null)
|
if (ModData != null && ModData.CursorProvider != null)
|
||||||
{
|
{
|
||||||
Cursor.SetCursor(Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default");
|
Cursor.SetCursor(Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default");
|
||||||
Cursor.Render(Renderer);
|
Cursor.Render(Renderer);
|
||||||
@@ -510,7 +510,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
using (new PerfSample("render_flip"))
|
using (new PerfSample("render_flip"))
|
||||||
Renderer.EndFrame(new DefaultInputHandler(orderManager.World));
|
Renderer.EndFrame(new DefaultInputHandler(OrderManager.World));
|
||||||
}
|
}
|
||||||
|
|
||||||
PerfHistory.Items["render"].Tick();
|
PerfHistory.Items["render"].Tick();
|
||||||
@@ -567,7 +567,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
// Ideal time between logic updates. Timestep = 0 means the game is paused
|
// Ideal time between logic updates. Timestep = 0 means the game is paused
|
||||||
// but we still call LogicTick() because it handles pausing internally.
|
// but we still call LogicTick() because it handles pausing internally.
|
||||||
var logicInterval = worldRenderer != null && worldRenderer.world.Timestep != 0 ? worldRenderer.world.Timestep : Game.Timestep;
|
var logicInterval = worldRenderer != null && worldRenderer.World.Timestep != 0 ? worldRenderer.World.Timestep : Game.Timestep;
|
||||||
|
|
||||||
// Ideal time between screen updates
|
// Ideal time between screen updates
|
||||||
var maxFramerate = Settings.Graphics.CapFramerate ? Settings.Graphics.MaxFramerate.Clamp(1, 1000) : 1000;
|
var maxFramerate = Settings.Graphics.CapFramerate ? Settings.Graphics.MaxFramerate.Clamp(1, 1000) : 1000;
|
||||||
@@ -592,7 +592,7 @@ namespace OpenRA
|
|||||||
LogicTick();
|
LogicTick();
|
||||||
|
|
||||||
// Force at least one render per tick during regular gameplay
|
// Force at least one render per tick during regular gameplay
|
||||||
if (orderManager.World != null && !orderManager.World.IsReplay)
|
if (OrderManager.World != null && !OrderManager.World.IsReplay)
|
||||||
forceRender = true;
|
forceRender = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,13 +636,13 @@ namespace OpenRA
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Ensure that the active replay is properly saved
|
// Ensure that the active replay is properly saved
|
||||||
if (orderManager != null)
|
if (OrderManager != null)
|
||||||
orderManager.Dispose();
|
OrderManager.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldRenderer != null)
|
if (worldRenderer != null)
|
||||||
worldRenderer.Dispose();
|
worldRenderer.Dispose();
|
||||||
modData.Dispose();
|
ModData.Dispose();
|
||||||
ChromeProvider.Deinitialize();
|
ChromeProvider.Deinitialize();
|
||||||
Renderer.Dispose();
|
Renderer.Dispose();
|
||||||
|
|
||||||
@@ -663,7 +663,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void AddChatLine(Color color, string name, string text)
|
public static void AddChatLine(Color color, string name, string text)
|
||||||
{
|
{
|
||||||
orderManager.AddChatLine(color, name, text);
|
OrderManager.AddChatLine(color, name, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Debug(string s, params object[] args)
|
public static void Debug(string s, params object[] args)
|
||||||
@@ -673,10 +673,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void Disconnect()
|
public static void Disconnect()
|
||||||
{
|
{
|
||||||
if (orderManager.World != null)
|
if (OrderManager.World != null)
|
||||||
orderManager.World.traitDict.PrintReport();
|
OrderManager.World.TraitDict.PrintReport();
|
||||||
|
|
||||||
orderManager.Dispose();
|
OrderManager.Dispose();
|
||||||
CloseServer();
|
CloseServer();
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
}
|
}
|
||||||
@@ -689,12 +689,12 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static T CreateObject<T>(string name)
|
public static T CreateObject<T>(string name)
|
||||||
{
|
{
|
||||||
return modData.ObjectCreator.CreateObject<T>(name);
|
return ModData.ObjectCreator.CreateObject<T>(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateServer(ServerSettings settings)
|
public static void CreateServer(ServerSettings settings)
|
||||||
{
|
{
|
||||||
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, modData);
|
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort), settings, ModData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CreateLocalServer(string map)
|
public static int CreateLocalServer(string map)
|
||||||
@@ -707,14 +707,14 @@ namespace OpenRA
|
|||||||
AllowPortForward = false
|
AllowPortForward = false
|
||||||
};
|
};
|
||||||
|
|
||||||
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), settings, modData);
|
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0), settings, ModData);
|
||||||
|
|
||||||
return server.Port;
|
return server.Port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsCurrentWorld(World world)
|
public static bool IsCurrentWorld(World world)
|
||||||
{
|
{
|
||||||
return orderManager != null && orderManager.World == world;
|
return OrderManager != null && OrderManager.World == world;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA
|
|||||||
// replay recording stopped.
|
// replay recording stopped.
|
||||||
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
|
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
|
||||||
public IList<Player> Players { get; private set; }
|
public IList<Player> Players { get; private set; }
|
||||||
public MapPreview MapPreview { get { return Game.modData.MapCache[MapUid]; } }
|
public MapPreview MapPreview { get { return Game.ModData.MapCache[MapUid]; } }
|
||||||
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
|
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
|
||||||
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }
|
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
static void LoadCollection(string name, MiniYaml yaml)
|
static void LoadCollection(string name, MiniYaml yaml)
|
||||||
{
|
{
|
||||||
Game.modData.LoadScreen.Display();
|
Game.ModData.LoadScreen.Display();
|
||||||
var collection = new Collection()
|
var collection = new Collection()
|
||||||
{
|
{
|
||||||
Src = yaml.Value,
|
Src = yaml.Value,
|
||||||
|
|||||||
@@ -87,19 +87,19 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
float2 ScreenPosition(WorldRenderer wr)
|
float2 ScreenPosition(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
return wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f * scale * sprite.size).ToInt2();
|
return wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f * scale * sprite.Size).ToInt2();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeforeRender(WorldRenderer wr) { }
|
public void BeforeRender(WorldRenderer wr) { }
|
||||||
public void Render(WorldRenderer wr)
|
public void Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite, ScreenPosition(wr), palette, sprite.size * scale);
|
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite, ScreenPosition(wr), palette, sprite.Size * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderDebugGeometry(WorldRenderer wr)
|
public void RenderDebugGeometry(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var offset = ScreenPosition(wr) + sprite.offset;
|
var offset = ScreenPosition(wr) + sprite.Offset;
|
||||||
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + sprite.size, Color.Red);
|
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + sprite.Size, Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Graphics
|
|||||||
// Apply offset to each sprite in the sequence
|
// Apply offset to each sprite in the sequence
|
||||||
// Different sequences may apply different offsets to the same frame
|
// Different sequences may apply different offsets to the same frame
|
||||||
sprites = cache[srcOverride ?? unit].Select(
|
sprites = cache[srcOverride ?? unit].Select(
|
||||||
s => new Sprite(s.sheet, s.bounds, s.offset + offset, s.channel, blendMode)).ToArray();
|
s => new Sprite(s.Sheet, s.Bounds, s.Offset + offset, s.Channel, blendMode)).ToArray();
|
||||||
|
|
||||||
if (!d.ContainsKey("Length"))
|
if (!d.ContainsKey("Length"))
|
||||||
Length = 1;
|
Length = 1;
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
var cursorSequence = cursorProvider.GetCursorSequence(cursorName);
|
var cursorSequence = cursorProvider.GetCursorSequence(cursorName);
|
||||||
var cursorSprite = sprites[cursorName][((int)cursorFrame % cursorSequence.Length)];
|
var cursorSprite = sprites[cursorName][((int)cursorFrame % cursorSequence.Length)];
|
||||||
var cursorSize = CursorProvider.CursorViewportZoomed ? 2.0f * cursorSprite.size : cursorSprite.size;
|
var cursorSize = CursorProvider.CursorViewportZoomed ? 2.0f * cursorSprite.Size : cursorSprite.Size;
|
||||||
|
|
||||||
var cursorOffset = CursorProvider.CursorViewportZoomed ?
|
var cursorOffset = CursorProvider.CursorViewportZoomed ?
|
||||||
(2 * cursorSequence.Hotspot) + cursorSprite.size.ToInt2() :
|
(2 * cursorSequence.Hotspot) + cursorSprite.Size.ToInt2() :
|
||||||
cursorSequence.Hotspot + (0.5f * cursorSprite.size).ToInt2();
|
cursorSequence.Hotspot + (0.5f * cursorSprite.Size).ToInt2();
|
||||||
|
|
||||||
renderer.SetPalette(palette);
|
renderer.SetPalette(palette);
|
||||||
renderer.SpriteRenderer.DrawSprite(cursorSprite,
|
renderer.SpriteRenderer.DrawSprite(cursorSprite,
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
public class Sprite
|
public class Sprite
|
||||||
{
|
{
|
||||||
public readonly Rectangle bounds;
|
public readonly Rectangle Bounds;
|
||||||
public readonly Sheet sheet;
|
public readonly Sheet Sheet;
|
||||||
public readonly BlendMode blendMode;
|
public readonly BlendMode BlendMode;
|
||||||
public readonly TextureChannel channel;
|
public readonly TextureChannel Channel;
|
||||||
public readonly float2 size;
|
public readonly float2 Size;
|
||||||
public readonly float2 offset;
|
public readonly float2 Offset;
|
||||||
public readonly float2 fractionalOffset;
|
public readonly float2 FractionalOffset;
|
||||||
public readonly float top, left, bottom, right;
|
public readonly float Top, Left, Bottom, Right;
|
||||||
|
|
||||||
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
|
||||||
: this(sheet, bounds, float2.Zero, channel, BlendMode.Alpha) { }
|
: this(sheet, bounds, float2.Zero, channel, BlendMode.Alpha) { }
|
||||||
@@ -31,19 +31,19 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public Sprite(Sheet sheet, Rectangle bounds, float2 offset, TextureChannel channel, BlendMode blendMode)
|
public Sprite(Sheet sheet, Rectangle bounds, float2 offset, TextureChannel channel, BlendMode blendMode)
|
||||||
{
|
{
|
||||||
this.sheet = sheet;
|
Sheet = sheet;
|
||||||
this.bounds = bounds;
|
Bounds = bounds;
|
||||||
this.offset = offset;
|
Offset = offset;
|
||||||
this.channel = channel;
|
Channel = channel;
|
||||||
this.size = new float2(bounds.Size);
|
Size = new float2(bounds.Size);
|
||||||
this.blendMode = blendMode;
|
BlendMode = blendMode;
|
||||||
|
|
||||||
this.fractionalOffset = offset / this.size;
|
FractionalOffset = offset / Size;
|
||||||
|
|
||||||
left = (float)bounds.Left / sheet.Size.Width;
|
Left = (float)bounds.Left / sheet.Size.Width;
|
||||||
top = (float)bounds.Top / sheet.Size.Height;
|
Top = (float)bounds.Top / sheet.Size.Height;
|
||||||
right = (float)bounds.Right / sheet.Size.Width;
|
Right = (float)bounds.Right / sheet.Size.Width;
|
||||||
bottom = (float)bounds.Bottom / sheet.Size.Height;
|
Bottom = (float)bounds.Bottom / sheet.Size.Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,15 +117,15 @@ namespace OpenRA.Graphics
|
|||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
var p = (byte*)bitmap.Buffer;
|
var p = (byte*)bitmap.Buffer;
|
||||||
var dest = s.sheet.GetData();
|
var dest = s.Sheet.GetData();
|
||||||
var destStride = s.sheet.Size.Width * 4;
|
var destStride = s.Sheet.Size.Width * 4;
|
||||||
|
|
||||||
for (var j = 0; j < s.size.Y; j++)
|
for (var j = 0; j < s.Size.Y; j++)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < s.size.X; i++)
|
for (var i = 0; i < s.Size.X; i++)
|
||||||
if (p[i] != 0)
|
if (p[i] != 0)
|
||||||
{
|
{
|
||||||
var q = destStride * (j + s.bounds.Top) + 4 * (i + s.bounds.Left);
|
var q = destStride * (j + s.Bounds.Top) + 4 * (i + s.Bounds.Left);
|
||||||
dest[q] = c.Second.B;
|
dest[q] = c.Second.B;
|
||||||
dest[q + 1] = c.Second.G;
|
dest[q + 1] = c.Second.G;
|
||||||
dest[q + 2] = c.Second.R;
|
dest[q + 2] = c.Second.R;
|
||||||
@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.sheet.CommitData();
|
s.Sheet.CommitData();
|
||||||
|
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void DrawSprite(Sprite s, float2 location, PaletteReference pal)
|
public void DrawSprite(Sprite s, float2 location, PaletteReference pal)
|
||||||
{
|
{
|
||||||
DrawSprite(s, location, pal.Index, s.size);
|
DrawSprite(s, location, pal.Index, s.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float2 location, PaletteReference pal, float2 size)
|
public void DrawSprite(Sprite s, float2 location, PaletteReference pal, float2 size)
|
||||||
@@ -63,25 +63,25 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
renderer.CurrentBatchRenderer = this;
|
renderer.CurrentBatchRenderer = this;
|
||||||
|
|
||||||
if (s.sheet != currentSheet)
|
if (s.Sheet != currentSheet)
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
if (s.blendMode != currentBlend)
|
if (s.BlendMode != currentBlend)
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
if (nv + 4 > renderer.TempBufferSize)
|
if (nv + 4 > renderer.TempBufferSize)
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
currentBlend = s.blendMode;
|
currentBlend = s.BlendMode;
|
||||||
currentSheet = s.sheet;
|
currentSheet = s.Sheet;
|
||||||
Util.FastCreateQuad(vertices, location + s.fractionalOffset * size, s, paletteIndex, nv, size);
|
Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, paletteIndex, nv, size);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For RGBASpriteRenderer, which doesn't use palettes
|
// For RGBASpriteRenderer, which doesn't use palettes
|
||||||
public void DrawSprite(Sprite s, float2 location)
|
public void DrawSprite(Sprite s, float2 location)
|
||||||
{
|
{
|
||||||
DrawSprite(s, location, 0, s.size);
|
DrawSprite(s, location, 0, s.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSprite(Sprite s, float2 location, float2 size)
|
public void DrawSprite(Sprite s, float2 location, float2 size)
|
||||||
@@ -93,17 +93,17 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
renderer.CurrentBatchRenderer = this;
|
renderer.CurrentBatchRenderer = this;
|
||||||
|
|
||||||
if (s.sheet != currentSheet)
|
if (s.Sheet != currentSheet)
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
if (s.blendMode != currentBlend)
|
if (s.BlendMode != currentBlend)
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
if (nv + 4 > renderer.TempBufferSize)
|
if (nv + 4 > renderer.TempBufferSize)
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
currentSheet = s.sheet;
|
currentSheet = s.Sheet;
|
||||||
currentBlend = s.blendMode;
|
currentBlend = s.BlendMode;
|
||||||
Util.FastCreateQuad(vertices, a, b, c, d, s, 0, nv);
|
Util.FastCreateQuad(vertices, a, b, c, d, s, 0, nv);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ namespace OpenRA.Graphics
|
|||||||
foreach (var cell in map.Cells)
|
foreach (var cell in map.Cells)
|
||||||
{
|
{
|
||||||
var tile = wr.Theater.TileSprite(map.MapTiles.Value[cell]);
|
var tile = wr.Theater.TileSprite(map.MapTiles.Value[cell]);
|
||||||
var pos = wr.ScreenPosition(map.CenterOfCell(cell)) + tile.offset - 0.5f * tile.size;
|
var pos = wr.ScreenPosition(map.CenterOfCell(cell)) + tile.Offset - 0.5f * tile.Size;
|
||||||
Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.size);
|
Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.Size);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
var verticesPerRow = 4 * map.Bounds.Width;
|
var verticesPerRow = 4 * map.Bounds.Width;
|
||||||
var cells = viewport.VisibleCells;
|
var cells = viewport.VisibleCells;
|
||||||
var shape = wr.world.Map.TileShape;
|
var shape = wr.World.Map.TileShape;
|
||||||
|
|
||||||
// Only draw the rows that are visible.
|
// Only draw the rows that are visible.
|
||||||
// VisibleCells is clamped to the map, so additional checks are unnecessary
|
// VisibleCells is clamped to the map, so additional checks are unnecessary
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Graphics
|
|||||||
sheetBuilder = new SheetBuilder(SheetType.Indexed, allocate);
|
sheetBuilder = new SheetBuilder(SheetType.Indexed, allocate);
|
||||||
templates = new Dictionary<ushort, Sprite[]>();
|
templates = new Dictionary<ushort, Sprite[]>();
|
||||||
|
|
||||||
var frameCache = new FrameCache(Game.modData.SpriteLoaders, tileset.Extensions);
|
var frameCache = new FrameCache(Game.ModData.SpriteLoaders, tileset.Extensions);
|
||||||
foreach (var t in tileset.Templates)
|
foreach (var t in tileset.Templates)
|
||||||
{
|
{
|
||||||
var allFrames = frameCache[t.Value.Image];
|
var allFrames = frameCache[t.Value.Image];
|
||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
// Ignore the offsets baked into R8 sprites
|
// Ignore the offsets baked into R8 sprites
|
||||||
if (tileset.IgnoreTileSpriteOffsets)
|
if (tileset.IgnoreTileSpriteOffsets)
|
||||||
sprites = sprites.Select(s => new Sprite(s.sheet, s.bounds, float2.Zero, s.channel, s.blendMode));
|
sprites = sprites.Select(s => new Sprite(s.Sheet, s.Bounds, float2.Zero, s.Channel, s.BlendMode));
|
||||||
|
|
||||||
templates.Add(t.Value.Id, sprites.ToArray());
|
templates.Add(t.Value.Id, sprites.ToArray());
|
||||||
}
|
}
|
||||||
@@ -91,8 +91,8 @@ namespace OpenRA.Graphics
|
|||||||
var u = tileShape == TileShape.Rectangle ? x : (x - y) / 2f;
|
var u = tileShape == TileShape.Rectangle ? x : (x - y) / 2f;
|
||||||
var v = tileShape == TileShape.Rectangle ? y : (x + y) / 2f;
|
var v = tileShape == TileShape.Rectangle ? y : (x + y) / 2f;
|
||||||
|
|
||||||
var tl = new float2(u * tileSize.Width, (v - 0.5f * tileInfo.Height) * tileSize.Height) - 0.5f * sprite.size;
|
var tl = new float2(u * tileSize.Width, (v - 0.5f * tileInfo.Height) * tileSize.Height) - 0.5f * sprite.Size;
|
||||||
var rect = new Rectangle((int)(tl.X + sprite.offset.X), (int)(tl.Y + sprite.offset.Y), (int)sprite.size.X, (int)sprite.size.Y);
|
var rect = new Rectangle((int)(tl.X + sprite.Offset.X), (int)(tl.Y + sprite.Offset.Y), (int)sprite.Size.X, (int)sprite.Size.Y);
|
||||||
templateRect = templateRect.HasValue ? Rectangle.Union(templateRect.Value, rect) : rect;
|
templateRect = templateRect.HasValue ? Rectangle.Union(templateRect.Value, rect) : rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ namespace OpenRA.Graphics
|
|||||||
public void BeforeRender(WorldRenderer wr) { }
|
public void BeforeRender(WorldRenderer wr) { }
|
||||||
public void Render(WorldRenderer wr)
|
public void Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
Game.Renderer.SpriteRenderer.DrawSprite(sprite, screenPos, palette, sprite.size * scale);
|
Game.Renderer.SpriteRenderer.DrawSprite(sprite, screenPos, palette, sprite.Size * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderDebugGeometry(WorldRenderer wr)
|
public void RenderDebugGeometry(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var offset = screenPos + sprite.offset;
|
var offset = screenPos + sprite.Offset;
|
||||||
Game.Renderer.LineRenderer.DrawRect(offset, offset + sprite.size, Color.Red);
|
Game.Renderer.LineRenderer.DrawRect(offset, offset + sprite.Size, Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ namespace OpenRA.Graphics
|
|||||||
public static class Util
|
public static class Util
|
||||||
{
|
{
|
||||||
// yes, our channel order is nuts.
|
// yes, our channel order is nuts.
|
||||||
static readonly int[] channelMasks = { 2, 1, 0, 3 };
|
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
|
||||||
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
static readonly float[] ChannelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
||||||
|
|
||||||
public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, int palette, int nv, float2 size)
|
public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, int palette, int nv, float2 size)
|
||||||
{
|
{
|
||||||
@@ -32,23 +32,23 @@ namespace OpenRA.Graphics
|
|||||||
public static void FastCreateQuad(Vertex[] vertices, float2 a, float2 b, float2 c, float2 d, Sprite r, int palette, int nv)
|
public static void FastCreateQuad(Vertex[] vertices, float2 a, float2 b, float2 c, float2 d, Sprite r, int palette, int nv)
|
||||||
{
|
{
|
||||||
var attribP = palette / (float)HardwarePalette.MaxPalettes;
|
var attribP = palette / (float)HardwarePalette.MaxPalettes;
|
||||||
var attribC = channelSelect[(int)r.channel];
|
var attribC = ChannelSelect[(int)r.Channel];
|
||||||
|
|
||||||
vertices[nv] = new Vertex(a, r.left, r.top, attribP, attribC);
|
vertices[nv] = new Vertex(a, r.Left, r.Top, attribP, attribC);
|
||||||
vertices[nv + 1] = new Vertex(b, r.right, r.top, attribP, attribC);
|
vertices[nv + 1] = new Vertex(b, r.Right, r.Top, attribP, attribC);
|
||||||
vertices[nv + 2] = new Vertex(c, r.right, r.bottom, attribP, attribC);
|
vertices[nv + 2] = new Vertex(c, r.Right, r.Bottom, attribP, attribC);
|
||||||
vertices[nv + 3] = new Vertex(d, r.left, r.bottom, attribP, attribC);
|
vertices[nv + 3] = new Vertex(d, r.Left, r.Bottom, attribP, attribC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FastCopyIntoChannel(Sprite dest, byte[] src) { FastCopyIntoChannel(dest, 0, src); }
|
public static void FastCopyIntoChannel(Sprite dest, byte[] src) { FastCopyIntoChannel(dest, 0, src); }
|
||||||
public static void FastCopyIntoChannel(Sprite dest, int channelOffset, byte[] src)
|
public static void FastCopyIntoChannel(Sprite dest, int channelOffset, byte[] src)
|
||||||
{
|
{
|
||||||
var data = dest.sheet.GetData();
|
var data = dest.Sheet.GetData();
|
||||||
var srcStride = dest.bounds.Width;
|
var srcStride = dest.Bounds.Width;
|
||||||
var destStride = dest.sheet.Size.Width * 4;
|
var destStride = dest.Sheet.Size.Width * 4;
|
||||||
var destOffset = destStride * dest.bounds.Top + dest.bounds.Left * 4 + channelMasks[(int)dest.channel + channelOffset];
|
var destOffset = destStride * dest.Bounds.Top + dest.Bounds.Left * 4 + ChannelMasks[(int)dest.Channel + channelOffset];
|
||||||
var destSkip = destStride - 4 * srcStride;
|
var destSkip = destStride - 4 * srcStride;
|
||||||
var height = dest.bounds.Height;
|
var height = dest.Bounds.Height;
|
||||||
|
|
||||||
var srcOffset = 0;
|
var srcOffset = 0;
|
||||||
for (var j = 0; j < height; j++)
|
for (var j = 0; j < height; j++)
|
||||||
@@ -65,12 +65,12 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public static void FastCopyIntoSprite(Sprite dest, Bitmap src)
|
public static void FastCopyIntoSprite(Sprite dest, Bitmap src)
|
||||||
{
|
{
|
||||||
var data = dest.sheet.GetData();
|
var data = dest.Sheet.GetData();
|
||||||
var dataStride = dest.sheet.Size.Width * 4;
|
var dataStride = dest.Sheet.Size.Width * 4;
|
||||||
var x = dest.bounds.Left * 4;
|
var x = dest.Bounds.Left * 4;
|
||||||
var width = dest.bounds.Width * 4;
|
var width = dest.Bounds.Width * 4;
|
||||||
var y = dest.bounds.Top;
|
var y = dest.Bounds.Top;
|
||||||
var height = dest.bounds.Height;
|
var height = dest.Bounds.Height;
|
||||||
|
|
||||||
var bd = src.LockBits(src.Bounds(),
|
var bd = src.LockBits(src.Bounds(),
|
||||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||||
|
|||||||
@@ -98,14 +98,14 @@ namespace OpenRA.Graphics
|
|||||||
var br = wr.ScreenPxPosition(map.CenterOfCell(Map.MapToCell(map.TileShape, new CPos(b.Right, b.Bottom))) + new WVec(511, 511, 0));
|
var br = wr.ScreenPxPosition(map.CenterOfCell(Map.MapToCell(map.TileShape, new CPos(b.Right, b.Bottom))) + new WVec(511, 511, 0));
|
||||||
mapBounds = Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
|
mapBounds = Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
|
||||||
|
|
||||||
maxGroundHeight = wr.world.TileSet.MaxGroundHeight;
|
maxGroundHeight = wr.World.TileSet.MaxGroundHeight;
|
||||||
CenterLocation = (tl + br) / 2;
|
CenterLocation = (tl + br) / 2;
|
||||||
Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPos ViewToWorld(int2 view)
|
public CPos ViewToWorld(int2 view)
|
||||||
{
|
{
|
||||||
return worldRenderer.world.Map.CellContaining(worldRenderer.Position(ViewToWorldPx(view)));
|
return worldRenderer.World.Map.CellContaining(worldRenderer.Position(ViewToWorldPx(view)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 ViewToWorldPx(int2 view) { return (1f / Zoom * view.ToFloat2()).ToInt2() + TopLeft; }
|
public int2 ViewToWorldPx(int2 view) { return (1f / Zoom * view.ToFloat2()).ToInt2() + TopLeft; }
|
||||||
@@ -142,7 +142,7 @@ namespace OpenRA.Graphics
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
// Visible rectangle in world coordinates (expanded to the corners of the cells)
|
// Visible rectangle in world coordinates (expanded to the corners of the cells)
|
||||||
var map = worldRenderer.world.Map;
|
var map = worldRenderer.World.Map;
|
||||||
var ctl = map.CenterOfCell(VisibleCells.TopLeft) - new WVec(512, 512, 0);
|
var ctl = map.CenterOfCell(VisibleCells.TopLeft) - new WVec(512, 512, 0);
|
||||||
var cbr = map.CenterOfCell(VisibleCells.BottomRight) + new WVec(512, 512, 0);
|
var cbr = map.CenterOfCell(VisibleCells.BottomRight) + new WVec(512, 512, 0);
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
if (cellsDirty)
|
if (cellsDirty)
|
||||||
{
|
{
|
||||||
var map = worldRenderer.world.Map;
|
var map = worldRenderer.World.Map;
|
||||||
var wtl = worldRenderer.Position(TopLeft);
|
var wtl = worldRenderer.Position(TopLeft);
|
||||||
var wbr = worldRenderer.Position(BottomRight);
|
var wbr = worldRenderer.Position(BottomRight);
|
||||||
|
|
||||||
|
|||||||
@@ -86,16 +86,16 @@ namespace OpenRA.Graphics
|
|||||||
var s = sheetBuilder.Allocate(new Size(su, sv));
|
var s = sheetBuilder.Allocate(new Size(su, sv));
|
||||||
Util.FastCopyIntoChannel(s, 0, colors);
|
Util.FastCopyIntoChannel(s, 0, colors);
|
||||||
Util.FastCopyIntoChannel(s, 1, normals);
|
Util.FastCopyIntoChannel(s, 1, normals);
|
||||||
s.sheet.CommitData();
|
s.Sheet.CommitData();
|
||||||
|
|
||||||
var channelP = ChannelSelect[(int)s.channel];
|
var channelP = ChannelSelect[(int)s.Channel];
|
||||||
var channelC = ChannelSelect[(int)s.channel + 1];
|
var channelC = ChannelSelect[(int)s.Channel + 1];
|
||||||
return new Vertex[4]
|
return new Vertex[4]
|
||||||
{
|
{
|
||||||
new Vertex(coord(0, 0), s.left, s.top, channelP, channelC),
|
new Vertex(coord(0, 0), s.Left, s.Top, channelP, channelC),
|
||||||
new Vertex(coord(su, 0), s.right, s.top, channelP, channelC),
|
new Vertex(coord(su, 0), s.Right, s.Top, channelP, channelC),
|
||||||
new Vertex(coord(su, sv), s.right, s.bottom, channelP, channelC),
|
new Vertex(coord(su, sv), s.Right, s.Bottom, channelP, channelC),
|
||||||
new Vertex(coord(0, sv), s.left, s.bottom, channelP, channelC)
|
new Vertex(coord(0, sv), s.Left, s.Bottom, channelP, channelC)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
|
|||||||
foreach (var s in sequences)
|
foreach (var s in sequences)
|
||||||
LoadVoxelsForUnit(s.Key, s.Value);
|
LoadVoxelsForUnit(s.Key, s.Value);
|
||||||
|
|
||||||
Game.modData.VoxelLoader.RefreshBuffer();
|
Game.ModData.VoxelLoader.RefreshBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Voxel LoadVoxel(string unit, MiniYaml info)
|
static Voxel LoadVoxel(string unit, MiniYaml info)
|
||||||
@@ -47,12 +47,12 @@ namespace OpenRA.Graphics
|
|||||||
hva = fields[1].Trim();
|
hva = fields[1].Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Game.modData.VoxelLoader.Load(vxl, hva);
|
return Game.ModData.VoxelLoader.Load(vxl, hva);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadVoxelsForUnit(string unit, MiniYaml sequences)
|
static void LoadVoxelsForUnit(string unit, MiniYaml sequences)
|
||||||
{
|
{
|
||||||
Game.modData.LoadScreen.Display();
|
Game.ModData.LoadScreen.Display();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var seq = sequences.ToDictionary(my => LoadVoxel(unit, my));
|
var seq = sequences.ToDictionary(my => LoadVoxel(unit, my));
|
||||||
|
|||||||
@@ -161,8 +161,8 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
var sprite = sheetBuilder.Allocate(spriteSize, spriteOffset);
|
var sprite = sheetBuilder.Allocate(spriteSize, spriteOffset);
|
||||||
var shadowSprite = sheetBuilder.Allocate(shadowSpriteSize, shadowSpriteOffset);
|
var shadowSprite = sheetBuilder.Allocate(shadowSpriteSize, shadowSpriteOffset);
|
||||||
var sb = sprite.bounds;
|
var sb = sprite.Bounds;
|
||||||
var ssb = shadowSprite.bounds;
|
var ssb = shadowSprite.Bounds;
|
||||||
var spriteCenter = new float2(sb.Left + sb.Width / 2, sb.Top + sb.Height / 2);
|
var spriteCenter = new float2(sb.Left + sb.Width / 2, sb.Top + sb.Height / 2);
|
||||||
var shadowCenter = new float2(ssb.Left + ssb.Width / 2, ssb.Top + ssb.Height / 2);
|
var shadowCenter = new float2(ssb.Left + ssb.Width / 2, ssb.Top + ssb.Height / 2);
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ namespace OpenRA.Graphics
|
|||||||
var correctionTransform = Util.MatrixMultiply(translateMtx, FlipMtx);
|
var correctionTransform = Util.MatrixMultiply(translateMtx, FlipMtx);
|
||||||
var shadowCorrectionTransform = Util.MatrixMultiply(shadowTranslateMtx, ShadowScaleFlipMtx);
|
var shadowCorrectionTransform = Util.MatrixMultiply(shadowTranslateMtx, ShadowScaleFlipMtx);
|
||||||
|
|
||||||
doRender.Add(Pair.New<Sheet, Action>(sprite.sheet, () =>
|
doRender.Add(Pair.New<Sheet, Action>(sprite.Sheet, () =>
|
||||||
{
|
{
|
||||||
foreach (var v in voxels)
|
foreach (var v in voxels)
|
||||||
{
|
{
|
||||||
@@ -262,7 +262,7 @@ namespace OpenRA.Graphics
|
|||||||
shader.SetVec("AmbientLight", ambientLight, 3);
|
shader.SetVec("AmbientLight", ambientLight, 3);
|
||||||
shader.SetVec("DiffuseLight", diffuseLight, 3);
|
shader.SetVec("DiffuseLight", diffuseLight, 3);
|
||||||
|
|
||||||
shader.Render(() => renderer.DrawBatch(Game.modData.VoxelLoader.VertexBuffer, renderData.Start, renderData.Count, PrimitiveType.QuadList));
|
shader.Render(() => renderer.DrawBatch(Game.ModData.VoxelLoader.VertexBuffer, renderData.Start, renderData.Count, PrimitiveType.QuadList));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginFrame()
|
public void BeginFrame()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public sealed class WorldRenderer : IDisposable
|
public sealed class WorldRenderer : IDisposable
|
||||||
{
|
{
|
||||||
public readonly World world;
|
public readonly World World;
|
||||||
public readonly Theater Theater;
|
public readonly Theater Theater;
|
||||||
public Viewport Viewport { get; private set; }
|
public Viewport Viewport { get; private set; }
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
internal WorldRenderer(World world)
|
internal WorldRenderer(World world)
|
||||||
{
|
{
|
||||||
this.world = world;
|
World = world;
|
||||||
Viewport = new Viewport(this, world.Map);
|
Viewport = new Viewport(this, world.Map);
|
||||||
|
|
||||||
foreach (var pal in world.traitDict.ActorsWithTrait<ILoadsPalettes>())
|
foreach (var pal in world.TraitDict.ActorsWithTrait<ILoadsPalettes>())
|
||||||
pal.Trait.LoadPalettes(this);
|
pal.Trait.LoadPalettes(this);
|
||||||
|
|
||||||
palette.Initialize();
|
palette.Initialize();
|
||||||
@@ -70,27 +70,27 @@ namespace OpenRA.Graphics
|
|||||||
List<IRenderable> GenerateRenderables()
|
List<IRenderable> GenerateRenderables()
|
||||||
{
|
{
|
||||||
var comparer = new RenderableComparer(this);
|
var comparer = new RenderableComparer(this);
|
||||||
var actors = world.ScreenMap.ActorsInBox(Viewport.TopLeft, Viewport.BottomRight)
|
var actors = World.ScreenMap.ActorsInBox(Viewport.TopLeft, Viewport.BottomRight)
|
||||||
.Append(world.WorldActor)
|
.Append(World.WorldActor)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Include player actor for the rendered player
|
// Include player actor for the rendered player
|
||||||
if (world.RenderPlayer != null)
|
if (World.RenderPlayer != null)
|
||||||
actors.Add(world.RenderPlayer.PlayerActor);
|
actors.Add(World.RenderPlayer.PlayerActor);
|
||||||
|
|
||||||
var worldRenderables = actors.SelectMany(a => a.Render(this));
|
var worldRenderables = actors.SelectMany(a => a.Render(this));
|
||||||
if (world.OrderGenerator != null)
|
if (World.OrderGenerator != null)
|
||||||
worldRenderables = worldRenderables.Concat(world.OrderGenerator.Render(this, world));
|
worldRenderables = worldRenderables.Concat(World.OrderGenerator.Render(this, World));
|
||||||
|
|
||||||
worldRenderables = worldRenderables.OrderBy(r => r, comparer);
|
worldRenderables = worldRenderables.OrderBy(r => r, comparer);
|
||||||
|
|
||||||
// Effects are drawn on top of all actors
|
// Effects are drawn on top of all actors
|
||||||
// HACK: Effects aren't interleaved with actors.
|
// HACK: Effects aren't interleaved with actors.
|
||||||
var effectRenderables = world.Effects
|
var effectRenderables = World.Effects
|
||||||
.SelectMany(e => e.Render(this));
|
.SelectMany(e => e.Render(this));
|
||||||
|
|
||||||
if (world.OrderGenerator != null)
|
if (World.OrderGenerator != null)
|
||||||
effectRenderables = effectRenderables.Concat(world.OrderGenerator.RenderAfterWorld(this, world));
|
effectRenderables = effectRenderables.Concat(World.OrderGenerator.RenderAfterWorld(this, World));
|
||||||
|
|
||||||
// Iterating via foreach copies the structs, so enumerate by index
|
// Iterating via foreach copies the structs, so enumerate by index
|
||||||
var renderables = worldRenderables.Concat(effectRenderables).ToList();
|
var renderables = worldRenderables.Concat(effectRenderables).ToList();
|
||||||
@@ -107,7 +107,7 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
RefreshPalette();
|
RefreshPalette();
|
||||||
|
|
||||||
if (world.IsShellmap && !Game.Settings.Game.ShowShellmap)
|
if (World.IsShellmap && !Game.Settings.Game.ShowShellmap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var renderables = GenerateRenderables();
|
var renderables = GenerateRenderables();
|
||||||
@@ -121,13 +121,13 @@ namespace OpenRA.Graphics
|
|||||||
renderables[i].Render(this);
|
renderables[i].Render(this);
|
||||||
|
|
||||||
// added for contrails
|
// added for contrails
|
||||||
foreach (var a in world.ActorsWithTrait<IPostRender>())
|
foreach (var a in World.ActorsWithTrait<IPostRender>())
|
||||||
if (a.Actor.IsInWorld && !a.Actor.Destroyed)
|
if (a.Actor.IsInWorld && !a.Actor.Destroyed)
|
||||||
a.Trait.RenderAfterWorld(this, a.Actor);
|
a.Trait.RenderAfterWorld(this, a.Actor);
|
||||||
|
|
||||||
var renderShroud = world.RenderPlayer != null ? world.RenderPlayer.Shroud : null;
|
var renderShroud = World.RenderPlayer != null ? World.RenderPlayer.Shroud : null;
|
||||||
|
|
||||||
foreach (var a in world.ActorsWithTrait<IRenderShroud>())
|
foreach (var a in World.ActorsWithTrait<IRenderShroud>())
|
||||||
a.Trait.RenderShroud(this, renderShroud);
|
a.Trait.RenderShroud(this, renderShroud);
|
||||||
|
|
||||||
if (devTrait.Value != null && devTrait.Value.ShowDebugGeometry)
|
if (devTrait.Value != null && devTrait.Value.ShowDebugGeometry)
|
||||||
@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
Game.Renderer.DisableScissor();
|
Game.Renderer.DisableScissor();
|
||||||
|
|
||||||
var overlayRenderables = world.Selection.Actors.Where(a => !a.Destroyed)
|
var overlayRenderables = World.Selection.Actors.Where(a => !a.Destroyed)
|
||||||
.SelectMany(a => a.TraitsImplementing<IPostRenderSelection>())
|
.SelectMany(a => a.TraitsImplementing<IPostRenderSelection>())
|
||||||
.SelectMany(t => t.RenderAfterWorld(this))
|
.SelectMany(t => t.RenderAfterWorld(this))
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -156,12 +156,12 @@ namespace OpenRA.Graphics
|
|||||||
foreach (var r in g)
|
foreach (var r in g)
|
||||||
r.RenderDebugGeometry(this);
|
r.RenderDebugGeometry(this);
|
||||||
|
|
||||||
if (!world.IsShellmap && Game.Settings.Game.AlwaysShowStatusBars)
|
if (!World.IsShellmap && Game.Settings.Game.AlwaysShowStatusBars)
|
||||||
{
|
{
|
||||||
foreach (var g in world.Actors.Where(a => !a.Destroyed
|
foreach (var g in World.Actors.Where(a => !a.Destroyed
|
||||||
&& a.HasTrait<Selectable>()
|
&& a.HasTrait<Selectable>()
|
||||||
&& !world.FogObscures(a)
|
&& !World.FogObscures(a)
|
||||||
&& !world.Selection.Actors.Contains(a)))
|
&& !World.Selection.Actors.Contains(a)))
|
||||||
|
|
||||||
DrawRollover(g);
|
DrawRollover(g);
|
||||||
}
|
}
|
||||||
@@ -206,14 +206,14 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void RefreshPalette()
|
public void RefreshPalette()
|
||||||
{
|
{
|
||||||
palette.ApplyModifiers(world.WorldActor.TraitsImplementing<IPaletteModifier>());
|
palette.ApplyModifiers(World.WorldActor.TraitsImplementing<IPaletteModifier>());
|
||||||
Game.Renderer.SetPalette(palette);
|
Game.Renderer.SetPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Conversion between world and screen coordinates
|
// Conversion between world and screen coordinates
|
||||||
public float2 ScreenPosition(WPos pos)
|
public float2 ScreenPosition(WPos pos)
|
||||||
{
|
{
|
||||||
var ts = Game.modData.Manifest.TileSize;
|
var ts = Game.ModData.Manifest.TileSize;
|
||||||
return new float2(ts.Width * pos.X / 1024f, ts.Height * (pos.Y - pos.Z) / 1024f);
|
return new float2(ts.Width * pos.X / 1024f, ts.Height * (pos.Y - pos.Z) / 1024f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ namespace OpenRA.Graphics
|
|||||||
// For scaling vectors to pixel sizes in the voxel renderer
|
// For scaling vectors to pixel sizes in the voxel renderer
|
||||||
public float[] ScreenVector(WVec vec)
|
public float[] ScreenVector(WVec vec)
|
||||||
{
|
{
|
||||||
var ts = Game.modData.Manifest.TileSize;
|
var ts = Game.ModData.Manifest.TileSize;
|
||||||
return new float[] { ts.Width * vec.X / 1024f, ts.Height * vec.Y / 1024f, ts.Height * vec.Z / 1024f, 1 };
|
return new float[] { ts.Width * vec.X / 1024f, ts.Height * vec.Y / 1024f, ts.Height * vec.Z / 1024f, 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,13 +240,13 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public float ScreenZPosition(WPos pos, int offset)
|
public float ScreenZPosition(WPos pos, int offset)
|
||||||
{
|
{
|
||||||
var ts = Game.modData.Manifest.TileSize;
|
var ts = Game.ModData.Manifest.TileSize;
|
||||||
return (pos.Y + pos.Z + offset) * ts.Height / 1024f;
|
return (pos.Y + pos.Z + offset) * ts.Height / 1024f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WPos Position(int2 screenPx)
|
public WPos Position(int2 screenPx)
|
||||||
{
|
{
|
||||||
var ts = Game.modData.Manifest.TileSize;
|
var ts = Game.ModData.Manifest.TileSize;
|
||||||
return new WPos(1024 * screenPx.X / ts.Width, 1024 * screenPx.Y / ts.Height, 0);
|
return new WPos(1024 * screenPx.X / ts.Width, 1024 * screenPx.Y / ts.Height, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,19 +16,19 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public class ActorInitializer
|
public class ActorInitializer
|
||||||
{
|
{
|
||||||
public readonly Actor self;
|
public readonly Actor Self;
|
||||||
public World world { get { return self.World; } }
|
public World World { get { return Self.World; } }
|
||||||
|
|
||||||
internal TypeDictionary Dict;
|
internal TypeDictionary Dict;
|
||||||
|
|
||||||
public ActorInitializer(Actor actor, TypeDictionary dict)
|
public ActorInitializer(Actor actor, TypeDictionary dict)
|
||||||
{
|
{
|
||||||
self = actor;
|
Self = actor;
|
||||||
Dict = dict;
|
Dict = dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Get<T>() where T : IActorInit { return Dict.Get<T>(); }
|
public T Get<T>() where T : IActorInit { return Dict.Get<T>(); }
|
||||||
public U Get<T, U>() where T : IActorInit<U> { return Dict.Get<T>().Value(world); }
|
public U Get<T, U>() where T : IActorInit<U> { return Dict.Get<T>().Value(World); }
|
||||||
public bool Contains<T>() where T : IActorInit { return Dict.Contains<T>(); }
|
public bool Contains<T>() where T : IActorInit { return Dict.Contains<T>(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ namespace OpenRA
|
|||||||
public static Map FromTileset(TileSet tileset)
|
public static Map FromTileset(TileSet tileset)
|
||||||
{
|
{
|
||||||
var size = new Size(1, 1);
|
var size = new Size(1, 1);
|
||||||
var tileShape = Game.modData.Manifest.TileShape;
|
var tileShape = Game.ModData.Manifest.TileShape;
|
||||||
var tileRef = new TerrainTile(tileset.Templates.First().Key, (byte)0);
|
var tileRef = new TerrainTile(tileset.Templates.First().Key, (byte)0);
|
||||||
|
|
||||||
var makeMapTiles = Exts.Lazy(() =>
|
var makeMapTiles = Exts.Lazy(() =>
|
||||||
@@ -328,10 +328,10 @@ namespace OpenRA
|
|||||||
MapResources = Exts.Lazy(() => LoadResourceTiles());
|
MapResources = Exts.Lazy(() => LoadResourceTiles());
|
||||||
MapHeight = Exts.Lazy(() => LoadMapHeight());
|
MapHeight = Exts.Lazy(() => LoadMapHeight());
|
||||||
|
|
||||||
TileShape = Game.modData.Manifest.TileShape;
|
TileShape = Game.ModData.Manifest.TileShape;
|
||||||
SubCellOffsets = Game.modData.Manifest.SubCellOffsets;
|
SubCellOffsets = Game.ModData.Manifest.SubCellOffsets;
|
||||||
LastSubCell = (SubCell)(SubCellOffsets.Length - 1);
|
LastSubCell = (SubCell)(SubCellOffsets.Length - 1);
|
||||||
DefaultSubCell = (SubCell)Game.modData.Manifest.SubCellDefaultIndex;
|
DefaultSubCell = (SubCell)Game.ModData.Manifest.SubCellDefaultIndex;
|
||||||
|
|
||||||
if (Container.Exists("map.png"))
|
if (Container.Exists("map.png"))
|
||||||
using (var dataStream = Container.GetContent("map.png"))
|
using (var dataStream = Container.GetContent("map.png"))
|
||||||
@@ -354,7 +354,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Game.modData.RulesetCache.LoadMapRules(this);
|
return Game.ModData.RulesetCache.LoadMapRules(this);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -362,7 +362,7 @@ namespace OpenRA
|
|||||||
Log.Write("debug", "Failed to load rules for {0} with error {1}", Title, e.Message);
|
Log.Write("debug", "Failed to load rules for {0} with error {1}", Title, e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Game.modData.DefaultRules;
|
return Game.ModData.DefaultRules;
|
||||||
});
|
});
|
||||||
|
|
||||||
cachedTileSet = Exts.Lazy(() => Rules.TileSets[Tileset]);
|
cachedTileSet = Exts.Lazy(() => Rules.TileSets[Tileset]);
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ namespace OpenRA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Status = MapStatus.Downloading;
|
Status = MapStatus.Downloading;
|
||||||
var baseMapPath = Platform.ResolvePath("^", "maps", Game.modData.Manifest.Mod.Id);
|
var baseMapPath = Platform.ResolvePath("^", "maps", Game.ModData.Manifest.Mod.Id);
|
||||||
|
|
||||||
// Create the map directory if it doesn't exist
|
// Create the map directory if it doesn't exist
|
||||||
if (!Directory.Exists(baseMapPath))
|
if (!Directory.Exists(baseMapPath))
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Network
|
|||||||
else
|
else
|
||||||
ModLabel = "Unknown mod: {0}".F(Mods);
|
ModLabel = "Unknown mod: {0}".F(Mods);
|
||||||
|
|
||||||
var mapAvailable = Game.Settings.Game.AllowDownloading || Game.modData.MapCache[Map].Status == MapStatus.Available;
|
var mapAvailable = Game.Settings.Game.AllowDownloading || Game.ModData.MapCache[Map].Status == MapStatus.Available;
|
||||||
IsJoinable = IsCompatible && State == 1 && mapAvailable;
|
IsJoinable = IsCompatible && State == 1 && mapAvailable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Network
|
|||||||
void StartSavingReplay(byte[] initialContent)
|
void StartSavingReplay(byte[] initialContent)
|
||||||
{
|
{
|
||||||
var filename = chooseFilename();
|
var filename = chooseFilename();
|
||||||
var mod = Game.modData.Manifest.Mod;
|
var mod = Game.ModData.Manifest.Mod;
|
||||||
var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Version);
|
var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Version);
|
||||||
|
|
||||||
if (!Directory.Exists(dir))
|
if (!Directory.Exists(dir))
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Network
|
|||||||
{
|
{
|
||||||
if (r.Frame == frame)
|
if (r.Frame == frame)
|
||||||
{
|
{
|
||||||
var mod = Game.modData.Manifest.Mod;
|
var mod = Game.ModData.Manifest.Mod;
|
||||||
Log.Write("sync", "Player: {0} ({1} {2} {3})", Game.Settings.Player.Name, Platform.CurrentPlatform, Environment.OSVersion, Platform.RuntimeVersion);
|
Log.Write("sync", "Player: {0} ({1} {2} {3})", Game.Settings.Player.Name, Platform.CurrentPlatform, Environment.OSVersion, Platform.RuntimeVersion);
|
||||||
Log.Write("sync", "Game ID: {0} (Mod: {1} at Version {2})", orderManager.LobbyInfo.GlobalSettings.GameUid, mod.Title, mod.Version);
|
Log.Write("sync", "Game ID: {0} (Mod: {1} at Version {2})", orderManager.LobbyInfo.GlobalSettings.GameUid, mod.Title, mod.Version);
|
||||||
Log.Write("sync", "Sync for net frame {0} -------------", r.Frame);
|
Log.Write("sync", "Sync for net frame {0} -------------", r.Frame);
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
case "StartGame":
|
case "StartGame":
|
||||||
{
|
{
|
||||||
if (Game.modData.MapCache[orderManager.LobbyInfo.GlobalSettings.Map].Status != MapStatus.Available)
|
if (Game.ModData.MapCache[orderManager.LobbyInfo.GlobalSettings.Map].Status != MapStatus.Available)
|
||||||
{
|
{
|
||||||
Game.Disconnect();
|
Game.Disconnect();
|
||||||
Game.LoadShellMap();
|
Game.LoadShellMap();
|
||||||
@@ -129,7 +129,7 @@ namespace OpenRA.Network
|
|||||||
case "HandshakeRequest":
|
case "HandshakeRequest":
|
||||||
{
|
{
|
||||||
// Switch to the server's mod if we need and are able to
|
// Switch to the server's mod if we need and are able to
|
||||||
var mod = Game.modData.Manifest.Mod;
|
var mod = Game.ModData.Manifest.Mod;
|
||||||
var request = HandshakeRequest.Deserialize(order.TargetString);
|
var request = HandshakeRequest.Deserialize(order.TargetString);
|
||||||
|
|
||||||
ModMetadata serverMod;
|
ModMetadata serverMod;
|
||||||
@@ -142,7 +142,7 @@ namespace OpenRA.Network
|
|||||||
"Launch.Replay=" + replay.Filename :
|
"Launch.Replay=" + replay.Filename :
|
||||||
"Launch.Connect=" + orderManager.Host + ":" + orderManager.Port;
|
"Launch.Connect=" + orderManager.Host + ":" + orderManager.Port;
|
||||||
|
|
||||||
Game.modData.LoadScreen.Display();
|
Game.ModData.LoadScreen.Display();
|
||||||
Game.InitializeMod(request.Mod, new Arguments(launchCommand));
|
Game.InitializeMod(request.Mod, new Arguments(launchCommand));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -261,7 +261,7 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
case "SetStance":
|
case "SetStance":
|
||||||
{
|
{
|
||||||
if (!Game.orderManager.LobbyInfo.GlobalSettings.FragileAlliances)
|
if (!Game.OrderManager.LobbyInfo.GlobalSettings.FragileAlliances)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);
|
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ namespace OpenRA.Scripting
|
|||||||
|
|
||||||
void InitializeBindings()
|
void InitializeBindings()
|
||||||
{
|
{
|
||||||
var commandClasses = context.ActorCommands[actor.Info].AsEnumerable();
|
var commandClasses = Context.ActorCommands[actor.Info].AsEnumerable();
|
||||||
|
|
||||||
// Destroyed actors cannot have their traits queried
|
// Destroyed actors cannot have their traits queried
|
||||||
if (actor.Destroyed)
|
if (actor.Destroyed)
|
||||||
commandClasses = commandClasses.Where(c => c.HasAttribute<ExposedForDestroyedActors>());
|
commandClasses = commandClasses.Where(c => c.HasAttribute<ExposedForDestroyedActors>());
|
||||||
|
|
||||||
var args = new object[] { context, actor };
|
var args = new object[] { Context, actor };
|
||||||
var objects = commandClasses.Select(cg =>
|
var objects = commandClasses.Select(cg =>
|
||||||
{
|
{
|
||||||
var groupCtor = cg.GetConstructor(new Type[] { typeof(ScriptContext), typeof(Actor) });
|
var groupCtor = cg.GetConstructor(new Type[] { typeof(ScriptContext), typeof(Actor) });
|
||||||
|
|||||||
@@ -47,23 +47,23 @@ namespace OpenRA.Scripting
|
|||||||
|
|
||||||
public abstract class ScriptActorProperties
|
public abstract class ScriptActorProperties
|
||||||
{
|
{
|
||||||
protected readonly Actor self;
|
protected readonly Actor Self;
|
||||||
protected readonly ScriptContext context;
|
protected readonly ScriptContext Context;
|
||||||
public ScriptActorProperties(ScriptContext context, Actor self)
|
public ScriptActorProperties(ScriptContext context, Actor self)
|
||||||
{
|
{
|
||||||
this.self = self;
|
Self = self;
|
||||||
this.context = context;
|
Context = context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class ScriptPlayerProperties
|
public abstract class ScriptPlayerProperties
|
||||||
{
|
{
|
||||||
protected readonly Player player;
|
protected readonly Player Player;
|
||||||
protected readonly ScriptContext context;
|
protected readonly ScriptContext Context;
|
||||||
public ScriptPlayerProperties(ScriptContext context, Player player)
|
public ScriptPlayerProperties(ScriptContext context, Player player)
|
||||||
{
|
{
|
||||||
this.player = player;
|
Player = player;
|
||||||
this.context = context;
|
Context = context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,12 +123,12 @@ namespace OpenRA.Scripting
|
|||||||
|
|
||||||
World = world;
|
World = world;
|
||||||
WorldRenderer = worldRenderer;
|
WorldRenderer = worldRenderer;
|
||||||
knownActorCommands = Game.modData.ObjectCreator
|
knownActorCommands = Game.ModData.ObjectCreator
|
||||||
.GetTypesImplementing<ScriptActorProperties>()
|
.GetTypesImplementing<ScriptActorProperties>()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
ActorCommands = new Cache<ActorInfo, Type[]>(FilterActorCommands);
|
ActorCommands = new Cache<ActorInfo, Type[]>(FilterActorCommands);
|
||||||
PlayerCommands = Game.modData.ObjectCreator
|
PlayerCommands = Game.ModData.ObjectCreator
|
||||||
.GetTypesImplementing<ScriptPlayerProperties>()
|
.GetTypesImplementing<ScriptPlayerProperties>()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ namespace OpenRA.Scripting
|
|||||||
registerGlobal.Call("print", fn).Dispose();
|
registerGlobal.Call("print", fn).Dispose();
|
||||||
|
|
||||||
// Register global tables
|
// Register global tables
|
||||||
var bindings = Game.modData.ObjectCreator.GetTypesImplementing<ScriptGlobal>();
|
var bindings = Game.ModData.ObjectCreator.GetTypesImplementing<ScriptGlobal>();
|
||||||
foreach (var b in bindings)
|
foreach (var b in bindings)
|
||||||
{
|
{
|
||||||
var ctor = b.GetConstructors(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(c =>
|
var ctor = b.GetConstructors(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(c =>
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ namespace OpenRA.Scripting
|
|||||||
protected abstract string DuplicateKeyError(string memberName);
|
protected abstract string DuplicateKeyError(string memberName);
|
||||||
protected abstract string MemberNotFoundError(string memberName);
|
protected abstract string MemberNotFoundError(string memberName);
|
||||||
|
|
||||||
protected readonly ScriptContext context;
|
protected readonly ScriptContext Context;
|
||||||
Dictionary<string, ScriptMemberWrapper> members;
|
Dictionary<string, ScriptMemberWrapper> members;
|
||||||
|
|
||||||
public ScriptObjectWrapper(ScriptContext context)
|
public ScriptObjectWrapper(ScriptContext context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
Context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Bind(IEnumerable<object> clrObjects)
|
protected void Bind(IEnumerable<object> clrObjects)
|
||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Scripting
|
|||||||
if (members.ContainsKey(m.Name))
|
if (members.ContainsKey(m.Name))
|
||||||
throw new LuaException(DuplicateKeyError(m.Name));
|
throw new LuaException(DuplicateKeyError(m.Name));
|
||||||
|
|
||||||
members.Add(m.Name, new ScriptMemberWrapper(context, obj, m));
|
members.Add(m.Name, new ScriptMemberWrapper(Context, obj, m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ namespace OpenRA
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currFrame = Game.orderManager.LocalFrameNumber;
|
var currFrame = Game.OrderManager.LocalFrameNumber;
|
||||||
var atten = 1f;
|
var atten = 1f;
|
||||||
|
|
||||||
// Check if max # of instances-per-location reached:
|
// Check if max # of instances-per-location reached:
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
Log.AddChannel("exception", "exception.log");
|
Log.AddChannel("exception", "exception.log");
|
||||||
|
|
||||||
if (Game.modData != null)
|
if (Game.ModData != null)
|
||||||
{
|
{
|
||||||
var mod = Game.modData.Manifest.Mod;
|
var mod = Game.ModData.Manifest.Mod;
|
||||||
Log.Write("exception", "{0} Mod at Version {1}", mod.Title, mod.Version);
|
Log.Write("exception", "{0} Mod at Version {1}", mod.Title, mod.Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Traits
|
|||||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new BodyOrientation(init.self, this); }
|
public object Create(ActorInitializer init) { return new BodyOrientation(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BodyOrientation : IBodyOrientation
|
public class BodyOrientation : IBodyOrientation
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace OpenRA.Traits
|
|||||||
[Desc("Checks for pause related desyncs. Attach this to the world actor.")]
|
[Desc("Checks for pause related desyncs. Attach this to the world actor.")]
|
||||||
public class DebugPauseStateInfo : ITraitInfo
|
public class DebugPauseStateInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new DebugPauseState(init.world); }
|
public object Create(ActorInitializer init) { return new DebugPauseState(init.World); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DebugPauseState : ISync
|
public class DebugPauseState : ISync
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public readonly int Ticks = 60;
|
public readonly int Ticks = 60;
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(init.self, this); }
|
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DrawLineToTarget : IPostRenderSelection, INotifySelected, INotifyBecomingIdle
|
public class DrawLineToTarget : IPostRenderSelection, INotifySelected, INotifyBecomingIdle
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRA.Traits
|
|||||||
[Desc("Required for FrozenUnderFog to work. Attach this to the player actor.")]
|
[Desc("Required for FrozenUnderFog to work. Attach this to the player actor.")]
|
||||||
public class FrozenActorLayerInfo : ITraitInfo
|
public class FrozenActorLayerInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new FrozenActorLayer(init.self); }
|
public object Create(ActorInitializer init) { return new FrozenActorLayer(init.Self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FrozenActor
|
public class FrozenActor
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Traits
|
|||||||
[Desc("Allow palette modifiers to change the palette.")]
|
[Desc("Allow palette modifiers to change the palette.")]
|
||||||
public readonly bool AllowModifiers = true;
|
public readonly bool AllowModifiers = true;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new PlayerColorPalette(init.self.Owner, this); }
|
public object Create(ActorInitializer init) { return new PlayerColorPalette(init.Self.Owner, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerColorPalette : ILoadsPalettes
|
public class PlayerColorPalette : ILoadsPalettes
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Traits
|
|||||||
[Desc("The prefix for the resulting player palettes")]
|
[Desc("The prefix for the resulting player palettes")]
|
||||||
public readonly string BaseName = "highlight";
|
public readonly string BaseName = "highlight";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new PlayerHighlightPalette(init.self.Owner, this); }
|
public object Create(ActorInitializer init) { return new PlayerHighlightPalette(init.Self.Owner, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerHighlightPalette : ILoadsPalettes
|
public class PlayerHighlightPalette : ILoadsPalettes
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Traits
|
|||||||
public readonly int DefaultCash = 5000;
|
public readonly int DefaultCash = 5000;
|
||||||
public readonly int AdviceInterval = 250;
|
public readonly int AdviceInterval = 250;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new PlayerResources(init.self, this); }
|
public object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerResources : ITick, ISync
|
public class PlayerResources : ITick, ISync
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Traits
|
|||||||
public readonly int[] Bounds = null;
|
public readonly int[] Bounds = null;
|
||||||
[VoiceReference] public readonly string Voice = null;
|
[VoiceReference] public readonly string Voice = null;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Selectable(init.self, this); }
|
public object Create(ActorInitializer init) { return new Selectable(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Selectable : IPostRenderSelection
|
public class Selectable : IPostRenderSelection
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public readonly string Palette = "chrome";
|
public readonly string Palette = "chrome";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new SelectionDecorations(init.self, this); }
|
public object Create(ActorInitializer init) { return new SelectionDecorations(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SelectionDecorations : IPostRenderSelection
|
public class SelectionDecorations : IPostRenderSelection
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Traits
|
|||||||
pipImages.PlayFetchIndex("groups", () => (int)group);
|
pipImages.PlayFetchIndex("groups", () => (int)group);
|
||||||
pipImages.Tick();
|
pipImages.Tick();
|
||||||
|
|
||||||
var pos = basePosition - (0.5f * pipImages.Image.size).ToInt2() + new int2(9, 5);
|
var pos = basePosition - (0.5f * pipImages.Image.Size).ToInt2() + new int2(9, 5);
|
||||||
yield return new UISpriteRenderable(pipImages.Image, pos, 0, pal, 1f);
|
yield return new UISpriteRenderable(pipImages.Image, pos, 0, pal, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ namespace OpenRA.Traits
|
|||||||
var pipImages = new Animation(self.World, "pips");
|
var pipImages = new Animation(self.World, "pips");
|
||||||
pipImages.PlayRepeating(PipStrings[0]);
|
pipImages.PlayRepeating(PipStrings[0]);
|
||||||
|
|
||||||
var pipSize = pipImages.Image.size.ToInt2();
|
var pipSize = pipImages.Image.Size.ToInt2();
|
||||||
var pipxyBase = basePosition + new int2(1 - pipSize.X / 2, -(3 + pipSize.Y / 2));
|
var pipxyBase = basePosition + new int2(1 - pipSize.X / 2, -(3 + pipSize.Y / 2));
|
||||||
var pipxyOffset = new int2(0, 0);
|
var pipxyOffset = new int2(0, 0);
|
||||||
var pal = wr.Palette(Info.Palette);
|
var pal = wr.Palette(Info.Palette);
|
||||||
@@ -127,7 +127,7 @@ namespace OpenRA.Traits
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
tagImages.PlayRepeating(TagStrings[(int)tag]);
|
tagImages.PlayRepeating(TagStrings[(int)tag]);
|
||||||
var pos = basePosition + tagxyOffset - (0.5f * tagImages.Image.size).ToInt2();
|
var pos = basePosition + tagxyOffset - (0.5f * tagImages.Image.Size).ToInt2();
|
||||||
yield return new UISpriteRenderable(tagImages.Image, pos, 0, pal, 1f);
|
yield return new UISpriteRenderable(tagImages.Image, pos, 0, pal, 1f);
|
||||||
|
|
||||||
// Increment row
|
// Increment row
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.Traits
|
|||||||
[Desc("Size of partition bins (cells)")]
|
[Desc("Size of partition bins (cells)")]
|
||||||
public readonly int BinSize = 10;
|
public readonly int BinSize = 10;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new ActorMap(init.world, this); }
|
public object Create(ActorInitializer init) { return new ActorMap(init.World, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActorMap : ITick
|
public class ActorMap : ITick
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public PipType PipColor = PipType.Yellow;
|
public PipType PipColor = PipType.Yellow;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new ResourceType(this, init.world); }
|
public object Create(ActorInitializer init) { return new ResourceType(this, init.World); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ResourceType : IWorldLoaded
|
public class ResourceType : IWorldLoaded
|
||||||
|
|||||||
4
OpenRA.Game/Traits/World/ScreenMap.cs
Executable file → Normal file
4
OpenRA.Game/Traits/World/ScreenMap.cs
Executable file → Normal file
@@ -22,7 +22,7 @@ namespace OpenRA.Traits
|
|||||||
[Desc("Size of partition bins (world pixels)")]
|
[Desc("Size of partition bins (world pixels)")]
|
||||||
public readonly int BinSize = 250;
|
public readonly int BinSize = 250;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new ScreenMap(init.world, this); }
|
public object Create(ActorInitializer init) { return new ScreenMap(init.World, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ScreenMap : IWorldLoaded
|
public class ScreenMap : IWorldLoaded
|
||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Traits
|
|||||||
public ScreenMap(World world, ScreenMapInfo info)
|
public ScreenMap(World world, ScreenMapInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
var ts = Game.modData.Manifest.TileSize;
|
var ts = Game.ModData.Manifest.TileSize;
|
||||||
cols = world.Map.MapSize.X * ts.Width / info.BinSize + 1;
|
cols = world.Map.MapSize.X * ts.Width / info.BinSize + 1;
|
||||||
rows = world.Map.MapSize.Y * ts.Height / info.BinSize + 1;
|
rows = world.Map.MapSize.Y * ts.Height / info.BinSize + 1;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Traits
|
|||||||
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
|
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
|
||||||
public class ShroudInfo : ITraitInfo
|
public class ShroudInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new Shroud(init.self); }
|
public object Create(ActorInitializer init) { return new Shroud(init.Self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Shroud
|
public class Shroud
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Widgets
|
|||||||
var color = GetColor();
|
var color = GetColor();
|
||||||
var colorDisabled = GetColorDisabled();
|
var colorDisabled = GetColorDisabled();
|
||||||
|
|
||||||
WidgetUtils.DrawRGBA(image, stateOffset + new float2(rb.Right - rb.Height + 4, rb.Top + (rb.Height - image.bounds.Height) / 2));
|
WidgetUtils.DrawRGBA(image, stateOffset + new float2(rb.Right - rb.Height + 4, rb.Top + (rb.Height - image.Bounds.Height) / 2));
|
||||||
|
|
||||||
WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height,
|
WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height,
|
||||||
stateOffset.Y + rb.Top + 3, 1, rb.Height - 6),
|
stateOffset.Y + rb.Top + 3, 1, rb.Height - 6),
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace OpenRA.Widgets
|
|||||||
public int2 ConvertToPreview(CPos cell)
|
public int2 ConvertToPreview(CPos cell)
|
||||||
{
|
{
|
||||||
var preview = Preview();
|
var preview = Preview();
|
||||||
var tileShape = Game.modData.Manifest.TileShape;
|
var tileShape = Game.ModData.Manifest.TileShape;
|
||||||
var point = Map.CellToMap(tileShape, cell);
|
var point = Map.CellToMap(tileShape, cell);
|
||||||
var dx = (int)(previewScale * (point.X - preview.Bounds.Left));
|
var dx = (int)(previewScale * (point.X - preview.Bounds.Left));
|
||||||
var dy = (int)(previewScale * (point.Y - preview.Bounds.Top));
|
var dy = (int)(previewScale * (point.Y - preview.Bounds.Top));
|
||||||
@@ -152,9 +152,9 @@ namespace OpenRA.Widgets
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Update map rect
|
// Update map rect
|
||||||
previewScale = Math.Min(RenderBounds.Width / minimap.size.X, RenderBounds.Height / minimap.size.Y);
|
previewScale = Math.Min(RenderBounds.Width / minimap.Size.X, RenderBounds.Height / minimap.Size.Y);
|
||||||
var w = (int)(previewScale * minimap.size.X);
|
var w = (int)(previewScale * minimap.Size.X);
|
||||||
var h = (int)(previewScale * minimap.size.Y);
|
var h = (int)(previewScale * minimap.Size.Y);
|
||||||
var x = RenderBounds.X + (RenderBounds.Width - w) / 2;
|
var x = RenderBounds.X + (RenderBounds.Width - w) / 2;
|
||||||
var y = RenderBounds.Y + (RenderBounds.Height - h) / 2;
|
var y = RenderBounds.Y + (RenderBounds.Height - h) / 2;
|
||||||
mapRect = new Rectangle(x, y, w, h);
|
mapRect = new Rectangle(x, y, w, h);
|
||||||
@@ -172,10 +172,10 @@ namespace OpenRA.Widgets
|
|||||||
var owned = colors.ContainsKey(p);
|
var owned = colors.ContainsKey(p);
|
||||||
var pos = ConvertToPreview(p);
|
var pos = ConvertToPreview(p);
|
||||||
var sprite = owned ? spawnClaimed : spawnUnclaimed;
|
var sprite = owned ? spawnClaimed : spawnUnclaimed;
|
||||||
var offset = new int2(sprite.bounds.Width, sprite.bounds.Height) / 2;
|
var offset = new int2(sprite.Bounds.Width, sprite.Bounds.Height) / 2;
|
||||||
|
|
||||||
if (owned)
|
if (owned)
|
||||||
WidgetUtils.FillEllipseWithColor(new Rectangle(pos.X - offset.X + 1, pos.Y - offset.Y + 1, sprite.bounds.Width - 2, sprite.bounds.Height - 2), colors[p]);
|
WidgetUtils.FillEllipseWithColor(new Rectangle(pos.X - offset.X + 1, pos.Y - offset.Y + 1, sprite.Bounds.Width - 2, sprite.Bounds.Height - 2), colors[p]);
|
||||||
|
|
||||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos - offset);
|
Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos - offset);
|
||||||
var number = Convert.ToChar('A' + spawnPoints.IndexOf(p)).ToString();
|
var number = Convert.ToChar('A' + spawnPoints.IndexOf(p)).ToString();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
if (hk == Game.Settings.Keys.DevReloadChromeKey)
|
if (hk == Game.Settings.Keys.DevReloadChromeKey)
|
||||||
{
|
{
|
||||||
ChromeProvider.Initialize(Game.modData.Manifest.Chrome);
|
ChromeProvider.Initialize(Game.ModData.Manifest.Chrome);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
OpenRA.Game/Widgets/SliderWidget.cs
Executable file → Normal file
2
OpenRA.Game/Widgets/SliderWidget.cs
Executable file → Normal file
@@ -118,7 +118,7 @@ namespace OpenRA.Widgets
|
|||||||
for (var i = 0; i < Ticks; i++)
|
for (var i = 0; i < Ticks; i++)
|
||||||
{
|
{
|
||||||
var tickPos = new float2(
|
var tickPos = new float2(
|
||||||
trackOrigin + (i * (trackRect.Width - (int)tick.size.X) / (Ticks - 1)) - tick.size.X / 2,
|
trackOrigin + (i * (trackRect.Width - (int)tick.Size.X) / (Ticks - 1)) - tick.Size.X / 2,
|
||||||
trackRect.Bottom);
|
trackRect.Bottom);
|
||||||
|
|
||||||
WidgetUtils.DrawRGBA(tick, tickPos);
|
WidgetUtils.DrawRGBA(tick, tickPos);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
if (Unit != null && Sequence != null)
|
if (Unit != null && Sequence != null)
|
||||||
{
|
{
|
||||||
var anim = new Animation(WorldRenderer.world, Unit, () => Facing);
|
var anim = new Animation(WorldRenderer.World, Unit, () => Facing);
|
||||||
anim.PlayFetchIndex(Sequence, () => Frame);
|
anim.PlayFetchIndex(Sequence, () => Frame);
|
||||||
GetAnimation = () => anim;
|
GetAnimation = () => anim;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
if (sprite != cachedSprite)
|
if (sprite != cachedSprite)
|
||||||
{
|
{
|
||||||
offset = 0.5f * (new float2(RenderBounds.Size) - sprite.size);
|
offset = 0.5f * (new float2(RenderBounds.Size) - sprite.Size);
|
||||||
cachedSprite = sprite;
|
cachedSprite = sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace OpenRA.Widgets
|
|||||||
while (nextFrame > video.CurrentFrame)
|
while (nextFrame > video.CurrentFrame)
|
||||||
{
|
{
|
||||||
video.AdvanceFrame();
|
video.AdvanceFrame();
|
||||||
videoSprite.sheet.GetTexture().SetData(video.FrameData);
|
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
|
||||||
skippedFrames++;
|
skippedFrames++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ namespace OpenRA.Widgets
|
|||||||
paused = true;
|
paused = true;
|
||||||
Sound.StopVideo();
|
Sound.StopVideo();
|
||||||
video.Reset();
|
video.Reset();
|
||||||
videoSprite.sheet.GetTexture().SetData(video.FrameData);
|
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
|
||||||
world.AddFrameEndTask(_ => onComplete());
|
world.AddFrameEndTask(_ => onComplete());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public static Widget OpenWindow(string id, WidgetArgs args)
|
public static Widget OpenWindow(string id, WidgetArgs args)
|
||||||
{
|
{
|
||||||
var window = Game.modData.WidgetLoader.LoadWidget(args, Root, id);
|
var window = Game.ModData.WidgetLoader.LoadWidget(args, Root, id);
|
||||||
if (WindowList.Count > 0)
|
if (WindowList.Count > 0)
|
||||||
Root.RemoveChild(WindowList.Peek());
|
Root.RemoveChild(WindowList.Peek());
|
||||||
WindowList.Push(window);
|
WindowList.Push(window);
|
||||||
@@ -67,7 +67,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public static Widget LoadWidget(string id, Widget parent, WidgetArgs args)
|
public static Widget LoadWidget(string id, Widget parent, WidgetArgs args)
|
||||||
{
|
{
|
||||||
return Game.modData.WidgetLoader.LoadWidget(args, parent, id);
|
return Game.ModData.WidgetLoader.LoadWidget(args, parent, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Tick() { Root.TickOuter(); }
|
public static void Tick() { Root.TickOuter(); }
|
||||||
@@ -235,7 +235,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
args["widget"] = this;
|
args["widget"] = this;
|
||||||
|
|
||||||
LogicObject = Game.modData.ObjectCreator.CreateObject<object>(Logic, args);
|
LogicObject = Game.ModData.ObjectCreator.CreateObject<object>(Logic, args);
|
||||||
|
|
||||||
args.Remove("widget");
|
args.Remove("widget");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace OpenRA
|
|||||||
static Widget NewWidget(string widgetType, WidgetArgs args)
|
static Widget NewWidget(string widgetType, WidgetArgs args)
|
||||||
{
|
{
|
||||||
widgetType = widgetType.Split('@')[0];
|
widgetType = widgetType.Split('@')[0];
|
||||||
return Game.modData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args);
|
return Game.ModData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,33 +29,33 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public static void DrawSHPCentered(Sprite s, float2 pos, WorldRenderer wr)
|
public static void DrawSHPCentered(Sprite s, float2 pos, WorldRenderer wr)
|
||||||
{
|
{
|
||||||
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * s.size, wr.Palette("chrome"));
|
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * s.Size, wr.Palette("chrome"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawSHPCentered(Sprite s, float2 pos, WorldRenderer wr, float scale)
|
public static void DrawSHPCentered(Sprite s, float2 pos, WorldRenderer wr, float scale)
|
||||||
{
|
{
|
||||||
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * scale * s.size, wr.Palette("chrome"), scale * s.size);
|
Game.Renderer.SpriteRenderer.DrawSprite(s, pos - 0.5f * scale * s.Size, wr.Palette("chrome"), scale * s.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawPanel(string collection, Rectangle Bounds)
|
public static void DrawPanel(string collection, Rectangle bounds)
|
||||||
{
|
{
|
||||||
DrawPanelPartial(collection, Bounds, PanelSides.All);
|
DrawPanelPartial(collection, bounds, PanelSides.All);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FillRectWithSprite(Rectangle r, Sprite s)
|
public static void FillRectWithSprite(Rectangle r, Sprite s)
|
||||||
{
|
{
|
||||||
for (var x = r.Left; x < r.Right; x += (int)s.size.X)
|
for (var x = r.Left; x < r.Right; x += (int)s.Size.X)
|
||||||
for (var y = r.Top; y < r.Bottom; y += (int)s.size.Y)
|
for (var y = r.Top; y < r.Bottom; y += (int)s.Size.Y)
|
||||||
{
|
{
|
||||||
var ss = s;
|
var ss = s;
|
||||||
var left = new int2(r.Right - x, r.Bottom - y);
|
var left = new int2(r.Right - x, r.Bottom - y);
|
||||||
if (left.X < (int)s.size.X || left.Y < (int)s.size.Y)
|
if (left.X < (int)s.Size.X || left.Y < (int)s.Size.Y)
|
||||||
{
|
{
|
||||||
var rr = new Rectangle(s.bounds.Left,
|
var rr = new Rectangle(s.Bounds.Left,
|
||||||
s.bounds.Top,
|
s.Bounds.Top,
|
||||||
Math.Min(left.X, (int)s.size.X),
|
Math.Min(left.X, (int)s.Size.X),
|
||||||
Math.Min(left.Y, (int)s.size.Y));
|
Math.Min(left.Y, (int)s.Size.Y));
|
||||||
ss = new Sprite(s.sheet, rr, s.channel);
|
ss = new Sprite(s.Sheet, rr, s.Channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawRGBA(ss, new float2(x, y));
|
DrawRGBA(ss, new float2(x, y));
|
||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
var images = new[] { "border-t", "border-b", "border-l", "border-r" };
|
var images = new[] { "border-t", "border-b", "border-l", "border-r" };
|
||||||
var ss = images.Select(i => ChromeProvider.GetImage(collection, i)).ToArray();
|
var ss = images.Select(i => ChromeProvider.GetImage(collection, i)).ToArray();
|
||||||
return new[] { (int)ss[0].size.Y, (int)ss[1].size.Y, (int)ss[2].size.X, (int)ss[3].size.X };
|
return new[] { (int)ss[0].Size.Y, (int)ss[1].Size.Y, (int)ss[2].Size.X, (int)ss[3].Size.X };
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HasFlags(this PanelSides a, PanelSides b) { return (a & b) == b; }
|
static bool HasFlags(this PanelSides a, PanelSides b) { return (a & b) == b; }
|
||||||
@@ -95,10 +95,10 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public static void DrawPanelPartial(Sprite[] ss, Rectangle bounds, PanelSides ps)
|
public static void DrawPanelPartial(Sprite[] ss, Rectangle bounds, PanelSides ps)
|
||||||
{
|
{
|
||||||
var marginLeft = ss[2] == null ? 0 : (int)ss[2].size.X;
|
var marginLeft = ss[2] == null ? 0 : (int)ss[2].Size.X;
|
||||||
var marginTop = ss[0] == null ? 0 : (int)ss[0].size.Y;
|
var marginTop = ss[0] == null ? 0 : (int)ss[0].Size.Y;
|
||||||
var marginRight = ss[3] == null ? 0 : (int)ss[3].size.X;
|
var marginRight = ss[3] == null ? 0 : (int)ss[3].Size.X;
|
||||||
var marginBottom = ss[1] == null ? 0 : (int)ss[1].size.Y;
|
var marginBottom = ss[1] == null ? 0 : (int)ss[1].Size.Y;
|
||||||
var marginWidth = marginRight + marginLeft;
|
var marginWidth = marginRight + marginLeft;
|
||||||
var marginHeight = marginBottom + marginTop;
|
var marginHeight = marginBottom + marginTop;
|
||||||
|
|
||||||
@@ -135,11 +135,11 @@ namespace OpenRA.Widgets
|
|||||||
if (ps.HasFlags(PanelSides.Left | PanelSides.Top) && ss[4] != null)
|
if (ps.HasFlags(PanelSides.Left | PanelSides.Top) && ss[4] != null)
|
||||||
DrawRGBA(ss[4], new float2(bounds.Left, bounds.Top));
|
DrawRGBA(ss[4], new float2(bounds.Left, bounds.Top));
|
||||||
if (ps.HasFlags(PanelSides.Right | PanelSides.Top) && ss[5] != null)
|
if (ps.HasFlags(PanelSides.Right | PanelSides.Top) && ss[5] != null)
|
||||||
DrawRGBA(ss[5], new float2(bounds.Right - ss[5].size.X, bounds.Top));
|
DrawRGBA(ss[5], new float2(bounds.Right - ss[5].Size.X, bounds.Top));
|
||||||
if (ps.HasFlags(PanelSides.Left | PanelSides.Bottom) && ss[6] != null)
|
if (ps.HasFlags(PanelSides.Left | PanelSides.Bottom) && ss[6] != null)
|
||||||
DrawRGBA(ss[6], new float2(bounds.Left, bounds.Bottom - ss[6].size.Y));
|
DrawRGBA(ss[6], new float2(bounds.Left, bounds.Bottom - ss[6].Size.Y));
|
||||||
if (ps.HasFlags(PanelSides.Right | PanelSides.Bottom) && ss[7] != null)
|
if (ps.HasFlags(PanelSides.Right | PanelSides.Bottom) && ss[7] != null)
|
||||||
DrawRGBA(ss[7], new float2(bounds.Right - ss[7].size.X, bounds.Bottom - ss[7].size.Y));
|
DrawRGBA(ss[7], new float2(bounds.Right - ss[7].Size.X, bounds.Bottom - ss[7].Size.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatTime(int ticks)
|
public static string FormatTime(int ticks)
|
||||||
@@ -215,7 +215,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public static string ChooseInitialMap(string initialUid)
|
public static string ChooseInitialMap(string initialUid)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(initialUid) || Game.modData.MapCache[initialUid].Status != MapStatus.Available)
|
if (string.IsNullOrEmpty(initialUid) || Game.ModData.MapCache[initialUid].Status != MapStatus.Available)
|
||||||
{
|
{
|
||||||
Func<MapPreview, bool> isIdealMap = m =>
|
Func<MapPreview, bool> isIdealMap = m =>
|
||||||
{
|
{
|
||||||
@@ -237,8 +237,8 @@ namespace OpenRA.Widgets
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var selected = Game.modData.MapCache.Where(m => isIdealMap(m)).RandomOrDefault(Game.CosmeticRandom) ??
|
var selected = Game.ModData.MapCache.Where(m => isIdealMap(m)).RandomOrDefault(Game.CosmeticRandom) ??
|
||||||
Game.modData.MapCache.First(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Lobby));
|
Game.ModData.MapCache.First(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Lobby));
|
||||||
return selected.Uid;
|
return selected.Uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,15 +25,15 @@ namespace OpenRA
|
|||||||
public class World
|
public class World
|
||||||
{
|
{
|
||||||
static readonly Func<int, int, bool> FalsePredicate = (u, v) => false;
|
static readonly Func<int, int, bool> FalsePredicate = (u, v) => false;
|
||||||
internal readonly TraitDictionary traitDict = new TraitDictionary();
|
internal readonly TraitDictionary TraitDict = new TraitDictionary();
|
||||||
readonly HashSet<Actor> actors = new HashSet<Actor>();
|
readonly HashSet<Actor> actors = new HashSet<Actor>();
|
||||||
readonly List<IEffect> effects = new List<IEffect>();
|
readonly List<IEffect> effects = new List<IEffect>();
|
||||||
readonly Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
|
readonly Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
|
||||||
|
|
||||||
public int Timestep;
|
public int Timestep;
|
||||||
|
|
||||||
internal readonly OrderManager orderManager;
|
internal readonly OrderManager OrderManager;
|
||||||
public Session LobbyInfo { get { return orderManager.LobbyInfo; } }
|
public Session LobbyInfo { get { return OrderManager.LobbyInfo; } }
|
||||||
|
|
||||||
public readonly MersenneTwister SharedRandom;
|
public readonly MersenneTwister SharedRandom;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool IsReplay
|
public bool IsReplay
|
||||||
{
|
{
|
||||||
get { return orderManager.Connection is ReplayConnection; }
|
get { return OrderManager.Connection is ReplayConnection; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AllowDevCommands
|
public bool AllowDevCommands
|
||||||
@@ -111,20 +111,20 @@ namespace OpenRA
|
|||||||
public readonly ScreenMap ScreenMap;
|
public readonly ScreenMap ScreenMap;
|
||||||
readonly GameInformation gameInfo;
|
readonly GameInformation gameInfo;
|
||||||
|
|
||||||
public void IssueOrder(Order o) { orderManager.IssueOrder(o); } /* avoid exposing the OM to mod code */
|
public void IssueOrder(Order o) { OrderManager.IssueOrder(o); } /* avoid exposing the OM to mod code */
|
||||||
|
|
||||||
IOrderGenerator orderGenerator_;
|
IOrderGenerator orderGenerator;
|
||||||
public IOrderGenerator OrderGenerator
|
public IOrderGenerator OrderGenerator
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return orderGenerator_;
|
return orderGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Sync.AssertUnsynced("The current order generator may not be changed from synced code");
|
Sync.AssertUnsynced("The current order generator may not be changed from synced code");
|
||||||
orderGenerator_ = value;
|
orderGenerator = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,8 +149,8 @@ namespace OpenRA
|
|||||||
internal World(Map map, OrderManager orderManager, bool isShellmap)
|
internal World(Map map, OrderManager orderManager, bool isShellmap)
|
||||||
{
|
{
|
||||||
IsShellmap = isShellmap;
|
IsShellmap = isShellmap;
|
||||||
this.orderManager = orderManager;
|
OrderManager = orderManager;
|
||||||
orderGenerator_ = new UnitOrderGenerator();
|
orderGenerator = new UnitOrderGenerator();
|
||||||
Map = map;
|
Map = map;
|
||||||
|
|
||||||
TileSet = map.Rules.TileSets[Map.Tileset];
|
TileSet = map.Rules.TileSets[Map.Tileset];
|
||||||
@@ -189,9 +189,9 @@ namespace OpenRA
|
|||||||
|
|
||||||
gameInfo.StartTimeUtc = DateTime.UtcNow;
|
gameInfo.StartTimeUtc = DateTime.UtcNow;
|
||||||
foreach (var player in Players)
|
foreach (var player in Players)
|
||||||
gameInfo.AddPlayer(player, orderManager.LobbyInfo);
|
gameInfo.AddPlayer(player, OrderManager.LobbyInfo);
|
||||||
|
|
||||||
var rc = orderManager.Connection as ReplayRecorderConnection;
|
var rc = OrderManager.Connection as ReplayRecorderConnection;
|
||||||
if (rc != null)
|
if (rc != null)
|
||||||
rc.Metadata = new ReplayMetadata(gameInfo);
|
rc.Metadata = new ReplayMetadata(gameInfo);
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public IEnumerable<TraitPair<T>> ActorsWithTrait<T>()
|
public IEnumerable<TraitPair<T>> ActorsWithTrait<T>()
|
||||||
{
|
{
|
||||||
return traitDict.ActorsWithTrait<T>();
|
return TraitDict.ActorsWithTrait<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPlayerWinStateChanged(Player player)
|
public void OnPlayerWinStateChanged(Player player)
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
bool skippedMakeAnimation;
|
bool skippedMakeAnimation;
|
||||||
|
|
||||||
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
|
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
|
||||||
: base(init.self, info)
|
: base(init.Self, info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
turret = turrets.FirstOrDefault();
|
turret = turrets.FirstOrDefault();
|
||||||
rb = init.self.Trait<RenderBuilding>();
|
rb = init.Self.Trait<RenderBuilding>();
|
||||||
skippedMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
skippedMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
[Desc("Cargo aircraft used.")]
|
[Desc("Cargo aircraft used.")]
|
||||||
[ActorReference] public readonly string ActorType = "c17";
|
[ActorReference] public readonly string ActorType = "c17";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new ProductionAirdrop(this, init.self); }
|
public override object Create(ActorInitializer init) { return new ProductionAirdrop(this, init.Self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProductionAirdrop : Production
|
class ProductionAirdrop : Production
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
{
|
{
|
||||||
public class TiberiumRefineryInfo : OreRefineryInfo
|
public class TiberiumRefineryInfo : OreRefineryInfo
|
||||||
{
|
{
|
||||||
public override object Create(ActorInitializer init) { return new TiberiumRefinery(init.self, this); }
|
public override object Create(ActorInitializer init) { return new TiberiumRefinery(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TiberiumRefinery : OreRefinery
|
public class TiberiumRefinery : OreRefinery
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
public readonly string WakeLeftSequence = "wake-left";
|
public readonly string WakeLeftSequence = "wake-left";
|
||||||
public readonly string WakeRightSequence = "wake-right";
|
public readonly string WakeRightSequence = "wake-right";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new RenderGunboat(init.self, this); }
|
public override object Create(ActorInitializer init) { return new RenderGunboat(init.Self, this); }
|
||||||
|
|
||||||
public int QuantizedBodyFacings(SequenceProvider sequenceProvider, ActorInfo ai)
|
public int QuantizedBodyFacings(SequenceProvider sequenceProvider, ActorInfo ai)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
[Desc("Passenger CargoType to display.")]
|
[Desc("Passenger CargoType to display.")]
|
||||||
public readonly string[] DisplayTypes = { };
|
public readonly string[] DisplayTypes = { };
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithCargo(init.self, this); }
|
public object Create(ActorInitializer init) { return new WithCargo(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithCargo : IRenderModifier
|
public class WithCargo : IRenderModifier
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public readonly string IdleSequence = "idle";
|
public readonly string IdleSequence = "idle";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithDeliveryAnimation(init.self, this); }
|
public object Create(ActorInitializer init) { return new WithDeliveryAnimation(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithDeliveryAnimation : INotifyDelivery
|
public class WithDeliveryAnimation : INotifyDelivery
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
public readonly string StartSequence = "fire-start";
|
public readonly string StartSequence = "fire-start";
|
||||||
public readonly string LoopSequence = "fire-loop";
|
public readonly string LoopSequence = "fire-loop";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithFire(init.self, this); }
|
public object Create(ActorInitializer init) { return new WithFire(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class WithFire
|
class WithFire
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
{
|
{
|
||||||
public readonly string Sequence = "roof";
|
public readonly string Sequence = "roof";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithRoof(init.self, this); }
|
public object Create(ActorInitializer init) { return new WithRoof(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithRoof
|
public class WithRoof
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
[Desc("Apply the weapon impact this many ticks into the effect")]
|
[Desc("Apply the weapon impact this many ticks into the effect")]
|
||||||
public readonly int WeaponDelay = 7;
|
public readonly int WeaponDelay = 7;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new IonCannonPower(init.self, this); }
|
public override object Create(ActorInitializer init) { return new IonCannonPower(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class IonCannonPower : SupportPower
|
class IonCannonPower : SupportPower
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
if (anim == null || ticks >= length)
|
if (anim == null || ticks >= length)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var cell = wr.world.Map.CellContaining(pos);
|
var cell = wr.World.Map.CellContaining(pos);
|
||||||
if (!args.SourceActor.World.FogObscures(cell))
|
if (!args.SourceActor.World.FogObscures(cell))
|
||||||
{
|
{
|
||||||
if (info.Shadow)
|
if (info.Shadow)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
[Desc("Use player remap color instead of a custom color?")]
|
[Desc("Use player remap color instead of a custom color?")]
|
||||||
public readonly bool UsePlayerColor = true;
|
public readonly bool UsePlayerColor = true;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Contrail(init.self, this); }
|
public object Create(ActorInitializer init) { return new Contrail(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class Contrail : ITick, IRender
|
class Contrail : ITick, IRender
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (wr.world.FogObscures(wr.world.Map.CellContaining(pos)))
|
if (wr.World.FogObscures(wr.World.Map.CellContaining(pos)))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
yield return new TextRenderable(font, pos, 0, color, text);
|
yield return new TextRenderable(font, pos, 0, color, text);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var cell = wr.world.Map.CellContaining(pos);
|
var cell = wr.World.Map.CellContaining(pos);
|
||||||
if (!args.SourceActor.World.FogObscures(cell))
|
if (!args.SourceActor.World.FogObscures(cell))
|
||||||
{
|
{
|
||||||
if (info.Shadow)
|
if (info.Shadow)
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (wr.world.FogObscures(wr.world.Map.CellContaining(target)) &&
|
if (wr.World.FogObscures(wr.World.Map.CellContaining(target)) &&
|
||||||
wr.world.FogObscures(wr.world.Map.CellContaining(args.Source)))
|
wr.World.FogObscures(wr.World.Map.CellContaining(args.Source)))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
if (ticks < info.BeamDuration)
|
if (ticks < info.BeamDuration)
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
if (info.ContrailLength > 0)
|
if (info.ContrailLength > 0)
|
||||||
yield return trail;
|
yield return trail;
|
||||||
|
|
||||||
if (!args.SourceActor.World.FogObscures(wr.world.Map.CellContaining(pos)))
|
if (!args.SourceActor.World.FogObscures(wr.World.Map.CellContaining(pos)))
|
||||||
{
|
{
|
||||||
if (info.Shadow)
|
if (info.Shadow)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (a.Destroyed || wr.world.FogObscures(a))
|
if (a.Destroyed || wr.World.FogObscures(a))
|
||||||
return SpriteRenderable.None;
|
return SpriteRenderable.None;
|
||||||
|
|
||||||
return anim.Render(a.CenterPosition, wr.Palette("chrome"));
|
return anim.Render(a.CenterPosition, wr.Palette("chrome"));
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
if (!building.IsInWorld || !building.World.Selection.Actors.Contains(building))
|
if (!building.IsInWorld || !building.World.Selection.Actors.Contains(building))
|
||||||
return SpriteRenderable.None;
|
return SpriteRenderable.None;
|
||||||
|
|
||||||
var pos = wr.world.Map.CenterOfCell(cachedLocation);
|
var pos = wr.World.Map.CenterOfCell(cachedLocation);
|
||||||
var palette = wr.Palette(palettePrefix + building.Owner.InternalName);
|
var palette = wr.Palette(palettePrefix + building.Owner.InternalName);
|
||||||
return circles.Render(pos, palette).Concat(flag.Render(pos, palette));
|
return circles.Render(pos, palette).Concat(flag.Render(pos, palette));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
if (wr.world.FogObscures(self))
|
if (wr.World.FogObscures(self))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
public readonly ActorInfo Actor;
|
public readonly ActorInfo Actor;
|
||||||
public readonly Player Owner;
|
public readonly Player Owner;
|
||||||
public readonly WorldRenderer WorldRenderer;
|
public readonly WorldRenderer WorldRenderer;
|
||||||
public World World { get { return WorldRenderer.world; } }
|
public World World { get { return WorldRenderer.World; } }
|
||||||
|
|
||||||
readonly TypeDictionary dict;
|
readonly TypeDictionary dict;
|
||||||
|
|
||||||
|
|||||||
@@ -67,13 +67,13 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
|
|
||||||
// Start of the first line segment is the tail of the list - don't smooth it.
|
// Start of the first line segment is the tail of the list - don't smooth it.
|
||||||
var curPos = trail[Index(next - skip - 1)];
|
var curPos = trail[Index(next - skip - 1)];
|
||||||
var curCell = wr.world.Map.CellContaining(curPos);
|
var curCell = wr.World.Map.CellContaining(curPos);
|
||||||
var curColor = color;
|
var curColor = color;
|
||||||
for (var i = 0; i < length - skip - 4; i++)
|
for (var i = 0; i < length - skip - 4; i++)
|
||||||
{
|
{
|
||||||
var j = next - skip - i - 2;
|
var j = next - skip - i - 2;
|
||||||
var nextPos = Average(trail[Index(j)], trail[Index(j - 1)], trail[Index(j - 2)], trail[Index(j - 3)]);
|
var nextPos = Average(trail[Index(j)], trail[Index(j - 1)], trail[Index(j - 2)], trail[Index(j - 3)]);
|
||||||
var nextCell = wr.world.Map.CellContaining(nextPos);
|
var nextCell = wr.World.Map.CellContaining(nextPos);
|
||||||
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
|
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
|
||||||
|
|
||||||
if (!world.FogObscures(curCell) && !world.FogObscures(nextCell))
|
if (!world.FogObscures(curCell) && !world.FogObscures(nextCell))
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
public void Render(WorldRenderer wr)
|
public void Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
// TODO: This is a temporary workaround until we have a proper ramp-aware height calculation
|
// TODO: This is a temporary workaround until we have a proper ramp-aware height calculation
|
||||||
var groundPos = wr.world.Map.CenterOfCell(wr.world.Map.CellContaining(pos));
|
var groundPos = wr.World.Map.CenterOfCell(wr.World.Map.CellContaining(pos));
|
||||||
|
|
||||||
var ts = Game.modData.Manifest.TileSize;
|
var ts = Game.ModData.Manifest.TileSize;
|
||||||
var groundZ = ts.Height * (groundPos.Z - pos.Z) / 1024f;
|
var groundZ = ts.Height * (groundPos.Z - pos.Z) / 1024f;
|
||||||
|
|
||||||
var pxOrigin = wr.ScreenPosition(pos);
|
var pxOrigin = wr.ScreenPosition(pos);
|
||||||
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
var sc = shadowOrigin + psb[1];
|
var sc = shadowOrigin + psb[1];
|
||||||
var sd = shadowOrigin + psb[3];
|
var sd = shadowOrigin + psb[3];
|
||||||
Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.ShadowSprite, sa, sb, sc, sd);
|
Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.ShadowSprite, sa, sb, sc, sd);
|
||||||
Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.Sprite, pxOrigin - 0.5f * renderProxy.Sprite.size);
|
Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.Sprite, pxOrigin - 0.5f * renderProxy.Sprite.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderDebugGeometry(WorldRenderer wr)
|
public void RenderDebugGeometry(WorldRenderer wr)
|
||||||
@@ -125,8 +125,8 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
|
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
|
||||||
|
|
||||||
// Draw sprite rect
|
// Draw sprite rect
|
||||||
var offset = pxOrigin + renderProxy.Sprite.offset - 0.5f * renderProxy.Sprite.size;
|
var offset = pxOrigin + renderProxy.Sprite.Offset - 0.5f * renderProxy.Sprite.Size;
|
||||||
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + renderProxy.Sprite.size, Color.Red);
|
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + renderProxy.Sprite.Size, Color.Red);
|
||||||
|
|
||||||
// Draw transformed shadow sprite rect
|
// Draw transformed shadow sprite rect
|
||||||
var c = Color.Purple;
|
var c = Color.Purple;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
// Check whether the mod content is installed
|
// Check whether the mod content is installed
|
||||||
// TODO: The installation code has finally been beaten into shape, so we can
|
// TODO: The installation code has finally been beaten into shape, so we can
|
||||||
// finally move it all into the planned "Manage Content" panel in the modchooser mod.
|
// finally move it all into the planned "Manage Content" panel in the modchooser mod.
|
||||||
var installData = Game.modData.Manifest.ContentInstaller;
|
var installData = Game.ModData.Manifest.ContentInstaller;
|
||||||
var installModContent = !installData.TestFiles.All(f => GlobalFileSystem.Exists(f));
|
var installModContent = !installData.TestFiles.All(f => GlobalFileSystem.Exists(f));
|
||||||
var installModMusic = args != null && args.Contains("Install.Music");
|
var installModMusic = args != null && args.Contains("Install.Music");
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (sprite != null)
|
if (sprite != null)
|
||||||
sprite.sheet.Dispose();
|
sprite.Sheet.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
// Find the requested type
|
// Find the requested type
|
||||||
var typeName = kv.Key.ToString();
|
var typeName = kv.Key.ToString();
|
||||||
var initType = Game.modData.ObjectCreator.FindType(typeName + "Init");
|
var initType = Game.ModData.ObjectCreator.FindType(typeName + "Init");
|
||||||
if (initType == null)
|
if (initType == null)
|
||||||
throw new LuaException("Unknown initializer type '{0}'".F(typeName));
|
throw new LuaException("Unknown initializer type '{0}'".F(typeName));
|
||||||
|
|
||||||
@@ -52,9 +52,9 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The actor must be added to the world at the end of the tick
|
// The actor must be added to the world at the end of the tick
|
||||||
var a = context.World.CreateActor(false, type, initDict);
|
var a = Context.World.CreateActor(false, type, initDict);
|
||||||
if (addToWorld)
|
if (addToWorld)
|
||||||
context.World.AddFrameEndTask(w => w.Add(a));
|
Context.World.AddFrameEndTask(w => w.Add(a));
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public int BuildTime(string type)
|
public int BuildTime(string type)
|
||||||
{
|
{
|
||||||
ActorInfo ai;
|
ActorInfo ai;
|
||||||
if (!context.World.Map.Rules.Actors.TryGetValue(type, out ai))
|
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out ai))
|
||||||
throw new LuaException("Unknown actor type '{0}'".F(type));
|
throw new LuaException("Unknown actor type '{0}'".F(type));
|
||||||
|
|
||||||
return ai.GetBuildTime();
|
return ai.GetBuildTime();
|
||||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public int CruiseAltitude(string type)
|
public int CruiseAltitude(string type)
|
||||||
{
|
{
|
||||||
ActorInfo ai;
|
ActorInfo ai;
|
||||||
if (!context.World.Map.Rules.Actors.TryGetValue(type, out ai))
|
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out ai))
|
||||||
throw new LuaException("Unknown actor type '{0}'".F(type));
|
throw new LuaException("Unknown actor type '{0}'".F(type));
|
||||||
|
|
||||||
var pi = ai.Traits.GetOrDefault<ICruiseAltitudeInfo>();
|
var pi = ai.Traits.GetOrDefault<ICruiseAltitudeInfo>();
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("The center of the visible viewport.")]
|
[Desc("The center of the visible viewport.")]
|
||||||
public WPos Position
|
public WPos Position
|
||||||
{
|
{
|
||||||
get { return context.WorldRenderer.Viewport.CenterPosition; }
|
get { return Context.WorldRenderer.Viewport.CenterPosition; }
|
||||||
set { context.WorldRenderer.Viewport.Center(value); }
|
set { Context.WorldRenderer.Viewport.Center(value); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Get the current game time (in ticks)")]
|
[Desc("Get the current game time (in ticks)")]
|
||||||
public int GameTime
|
public int GameTime
|
||||||
{
|
{
|
||||||
get { return context.World.WorldTick; }
|
get { return Context.World.WorldTick; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Converts the number of seconds into game time (ticks).")]
|
[Desc("Converts the number of seconds into game time (ticks).")]
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Returns a table of all actors within the requested region, filtered using the specified function.")]
|
[Desc("Returns a table of all actors within the requested region, filtered using the specified function.")]
|
||||||
public Actor[] ActorsInCircle(WPos location, WRange radius, LuaFunction filter = null)
|
public Actor[] ActorsInCircle(WPos location, WRange radius, LuaFunction filter = null)
|
||||||
{
|
{
|
||||||
var actors = context.World.FindActorsInCircle(location, radius);
|
var actors = Context.World.FindActorsInCircle(location, radius);
|
||||||
|
|
||||||
if (filter != null)
|
if (filter != null)
|
||||||
{
|
{
|
||||||
actors = actors.Where(a =>
|
actors = actors.Where(a =>
|
||||||
{
|
{
|
||||||
using (var f = filter.Call(a.ToLuaValue(context)))
|
using (var f = filter.Call(a.ToLuaValue(Context)))
|
||||||
return f.First().ToBoolean();
|
return f.First().ToBoolean();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -49,13 +49,13 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Returns a table of all actors within the requested rectangle, filtered using the specified function.")]
|
[Desc("Returns a table of all actors within the requested rectangle, filtered using the specified function.")]
|
||||||
public Actor[] ActorsInBox(WPos topLeft, WPos bottomRight, LuaFunction filter = null)
|
public Actor[] ActorsInBox(WPos topLeft, WPos bottomRight, LuaFunction filter = null)
|
||||||
{
|
{
|
||||||
var actors = context.World.ActorMap.ActorsInBox(topLeft, bottomRight);
|
var actors = Context.World.ActorMap.ActorsInBox(topLeft, bottomRight);
|
||||||
|
|
||||||
if (filter != null)
|
if (filter != null)
|
||||||
{
|
{
|
||||||
actors = actors.Where(a =>
|
actors = actors.Where(a =>
|
||||||
{
|
{
|
||||||
using (var f = filter.Call(a.ToLuaValue(context)))
|
using (var f = filter.Call(a.ToLuaValue(Context)))
|
||||||
return f.First().ToBoolean();
|
return f.First().ToBoolean();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -66,38 +66,38 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Returns the location of the top-left corner of the map.")]
|
[Desc("Returns the location of the top-left corner of the map.")]
|
||||||
public WPos TopLeft
|
public WPos TopLeft
|
||||||
{
|
{
|
||||||
get { return new WPos(context.World.Map.Bounds.Left * 1024, context.World.Map.Bounds.Top * 1024, 0); }
|
get { return new WPos(Context.World.Map.Bounds.Left * 1024, Context.World.Map.Bounds.Top * 1024, 0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Returns the location of the bottom-right corner of the map.")]
|
[Desc("Returns the location of the bottom-right corner of the map.")]
|
||||||
public WPos BottomRight
|
public WPos BottomRight
|
||||||
{
|
{
|
||||||
get { return new WPos(context.World.Map.Bounds.Right * 1024, context.World.Map.Bounds.Bottom * 1024, 0); }
|
get { return new WPos(Context.World.Map.Bounds.Right * 1024, Context.World.Map.Bounds.Bottom * 1024, 0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Returns a random cell inside the visible region of the map.")]
|
[Desc("Returns a random cell inside the visible region of the map.")]
|
||||||
public CPos RandomCell()
|
public CPos RandomCell()
|
||||||
{
|
{
|
||||||
return context.World.Map.ChooseRandomCell(context.World.SharedRandom);
|
return Context.World.Map.ChooseRandomCell(Context.World.SharedRandom);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Returns a random cell on the visible border of the map.")]
|
[Desc("Returns a random cell on the visible border of the map.")]
|
||||||
public CPos RandomEdgeCell()
|
public CPos RandomEdgeCell()
|
||||||
{
|
{
|
||||||
return context.World.Map.ChooseRandomEdgeCell(context.World.SharedRandom);
|
return Context.World.Map.ChooseRandomEdgeCell(Context.World.SharedRandom);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Returns the center of a cell in world coordinates.")]
|
[Desc("Returns the center of a cell in world coordinates.")]
|
||||||
public WPos CenterOfCell(CPos cell)
|
public WPos CenterOfCell(CPos cell)
|
||||||
{
|
{
|
||||||
return context.World.Map.CenterOfCell(cell);
|
return Context.World.Map.CenterOfCell(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Returns true if there is only one human player.")]
|
[Desc("Returns true if there is only one human player.")]
|
||||||
public bool IsSinglePlayer { get { return context.World.LobbyInfo.IsSinglePlayer; } }
|
public bool IsSinglePlayer { get { return Context.World.LobbyInfo.IsSinglePlayer; } }
|
||||||
|
|
||||||
[Desc("Returns the difficulty selected by the player before starting the mission.")]
|
[Desc("Returns the difficulty selected by the player before starting the mission.")]
|
||||||
public string Difficulty { get { return context.World.LobbyInfo.GlobalSettings.Difficulty; } }
|
public string Difficulty { get { return Context.World.LobbyInfo.GlobalSettings.Difficulty; } }
|
||||||
|
|
||||||
[Desc("Returns a table of all the actors that were specified in the map file.")]
|
[Desc("Returns a table of all the actors that were specified in the map file.")]
|
||||||
public Actor[] NamedActors { get { return sma.Actors.Values.ToArray(); } }
|
public Actor[] NamedActors { get { return sma.Actors.Values.ToArray(); } }
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (LuaException e)
|
catch (LuaException e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,16 +22,16 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Returns the player with the specified internal name, or nil if a match is not found.")]
|
[Desc("Returns the player with the specified internal name, or nil if a match is not found.")]
|
||||||
public Player GetPlayer(string name)
|
public Player GetPlayer(string name)
|
||||||
{
|
{
|
||||||
return context.World.Players.FirstOrDefault(p => p.InternalName == name);
|
return Context.World.Players.FirstOrDefault(p => p.InternalName == name);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Returns a table of players filtered by the specified function.")]
|
[Desc("Returns a table of players filtered by the specified function.")]
|
||||||
public Player[] GetPlayers(LuaFunction filter)
|
public Player[] GetPlayers(LuaFunction filter)
|
||||||
{
|
{
|
||||||
return context.World.Players
|
return Context.World.Players
|
||||||
.Where(p =>
|
.Where(p =>
|
||||||
{
|
{
|
||||||
using (var f = filter.Call(p.ToLuaValue(context)))
|
using (var f = filter.Call(p.ToLuaValue(Context)))
|
||||||
return f.First().ToBoolean();
|
return f.First().ToBoolean();
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,32 +45,32 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
context.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, doCall)));
|
Context.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, doCall)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function each tick that the actor is idle. " +
|
[Desc("Call a function each tick that the actor is idle. " +
|
||||||
"The callback function will be called as func(Actor self).")]
|
"The callback function will be called as func(Actor self).")]
|
||||||
public void OnIdle(Actor a, LuaFunction func)
|
public void OnIdle(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnIdle, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnIdle, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when the actor is damaged. The callback " +
|
[Desc("Call a function when the actor is damaged. The callback " +
|
||||||
"function will be called as func(Actor self, Actor attacker).")]
|
"function will be called as func(Actor self, Actor attacker).")]
|
||||||
public void OnDamaged(Actor a, LuaFunction func)
|
public void OnDamaged(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnDamaged, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnDamaged, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when the actor is killed. The callback " +
|
[Desc("Call a function when the actor is killed. The callback " +
|
||||||
"function will be called as func(Actor self, Actor killer).")]
|
"function will be called as func(Actor self, Actor killer).")]
|
||||||
public void OnKilled(Actor a, LuaFunction func)
|
public void OnKilled(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnKilled, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnKilled, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when all of the actors in a group are killed. The callback " +
|
[Desc("Call a function when all of the actors in a group are killed. The callback " +
|
||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
if (called)
|
if (called)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using (var killed = m.ToLuaValue(context))
|
using (var killed = m.ToLuaValue(Context))
|
||||||
copy.Call(killed).Dispose();
|
copy.Call(killed).Dispose();
|
||||||
|
|
||||||
copy.Dispose();
|
copy.Dispose();
|
||||||
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -133,56 +133,56 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
"The callback function will be called as func(Actor producer, Actor produced).")]
|
"The callback function will be called as func(Actor producer, Actor produced).")]
|
||||||
public void OnProduction(Actor a, LuaFunction func)
|
public void OnProduction(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnProduction, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnProduction, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this player completes all primary objectives. " +
|
[Desc("Call a function when this player completes all primary objectives. " +
|
||||||
"The callback function will be called as func(Player player).")]
|
"The callback function will be called as func(Player player).")]
|
||||||
public void OnPlayerWon(Player player, LuaFunction func)
|
public void OnPlayerWon(Player player, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnPlayerWon, func, context);
|
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnPlayerWon, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this player fails any primary objective. " +
|
[Desc("Call a function when this player fails any primary objective. " +
|
||||||
"The callback function will be called as func(Player player).")]
|
"The callback function will be called as func(Player player).")]
|
||||||
public void OnPlayerLost(Player player, LuaFunction func)
|
public void OnPlayerLost(Player player, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnPlayerLost, func, context);
|
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnPlayerLost, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this player is assigned a new objective. " +
|
[Desc("Call a function when this player is assigned a new objective. " +
|
||||||
"The callback function will be called as func(Player player, int objectiveID).")]
|
"The callback function will be called as func(Player player, int objectiveID).")]
|
||||||
public void OnObjectiveAdded(Player player, LuaFunction func)
|
public void OnObjectiveAdded(Player player, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnObjectiveAdded, func, context);
|
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnObjectiveAdded, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this player completes an objective. " +
|
[Desc("Call a function when this player completes an objective. " +
|
||||||
"The callback function will be called as func(Player player, int objectiveID).")]
|
"The callback function will be called as func(Player player, int objectiveID).")]
|
||||||
public void OnObjectiveCompleted(Player player, LuaFunction func)
|
public void OnObjectiveCompleted(Player player, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnObjectiveCompleted, func, context);
|
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnObjectiveCompleted, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this player fails an objective. " +
|
[Desc("Call a function when this player fails an objective. " +
|
||||||
"The callback function will be called as func(Player player, int objectiveID).")]
|
"The callback function will be called as func(Player player, int objectiveID).")]
|
||||||
public void OnObjectiveFailed(Player player, LuaFunction func)
|
public void OnObjectiveFailed(Player player, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnObjectiveFailed, func, context);
|
GetScriptTriggers(player.PlayerActor).RegisterCallback(Trigger.OnObjectiveFailed, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this actor is added to the world. " +
|
[Desc("Call a function when this actor is added to the world. " +
|
||||||
"The callback function will be called as func(Actor self).")]
|
"The callback function will be called as func(Actor self).")]
|
||||||
public void OnAddedToWorld(Actor a, LuaFunction func)
|
public void OnAddedToWorld(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnAddedToWorld, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnAddedToWorld, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this actor is removed from the world. " +
|
[Desc("Call a function when this actor is removed from the world. " +
|
||||||
"The callback function will be called as func(Actor self).")]
|
"The callback function will be called as func(Actor self).")]
|
||||||
public void OnRemovedFromWorld(Actor a, LuaFunction func)
|
public void OnRemovedFromWorld(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnRemovedFromWorld, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnRemovedFromWorld, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when all of the actors in a group have been removed from the world. " +
|
[Desc("Call a function when all of the actors in a group have been removed from the world. " +
|
||||||
@@ -205,7 +205,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
"will be called as func(Actor self, Actor captor, Player oldOwner, Player newOwner).")]
|
"will be called as func(Actor self, Actor captor, Player oldOwner, Player newOwner).")]
|
||||||
public void OnCapture(Actor a, LuaFunction func)
|
public void OnCapture(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnCapture, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnCapture, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this actor is killed or captured. " +
|
[Desc("Call a function when this actor is killed or captured. " +
|
||||||
@@ -240,7 +240,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -293,17 +293,17 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var luaActor = a.ToLuaValue(context))
|
using (var luaActor = a.ToLuaValue(Context))
|
||||||
using (var id = triggerId.ToLuaValue(context))
|
using (var id = triggerId.ToLuaValue(Context))
|
||||||
onEntry.Call(luaActor, id).Dispose();
|
onEntry.Call(luaActor, id).Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
triggerId = context.World.ActorMap.AddCellTrigger(cells, invokeEntry, null);
|
triggerId = Context.World.ActorMap.AddCellTrigger(cells, invokeEntry, null);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
@@ -319,17 +319,17 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var luaActor = a.ToLuaValue(context))
|
using (var luaActor = a.ToLuaValue(Context))
|
||||||
using (var id = triggerId.ToLuaValue(context))
|
using (var id = triggerId.ToLuaValue(Context))
|
||||||
onExit.Call(luaActor, id).Dispose();
|
onExit.Call(luaActor, id).Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
triggerId = context.World.ActorMap.AddCellTrigger(cells, null, invokeExit);
|
triggerId = Context.World.ActorMap.AddCellTrigger(cells, null, invokeExit);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
@@ -337,7 +337,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Removes a previously created footprint trigger.")]
|
[Desc("Removes a previously created footprint trigger.")]
|
||||||
public void RemoveFootprintTrigger(int id)
|
public void RemoveFootprintTrigger(int id)
|
||||||
{
|
{
|
||||||
context.World.ActorMap.RemoveCellTrigger(id);
|
Context.World.ActorMap.RemoveCellTrigger(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when an actor enters this range." +
|
[Desc("Call a function when an actor enters this range." +
|
||||||
@@ -351,17 +351,17 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var luaActor = a.ToLuaValue(context))
|
using (var luaActor = a.ToLuaValue(Context))
|
||||||
using (var id = triggerId.ToLuaValue(context))
|
using (var id = triggerId.ToLuaValue(Context))
|
||||||
onEntry.Call(luaActor, id).Dispose();
|
onEntry.Call(luaActor, id).Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
triggerId = context.World.ActorMap.AddProximityTrigger(pos, range, invokeEntry, null);
|
triggerId = Context.World.ActorMap.AddProximityTrigger(pos, range, invokeEntry, null);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
@@ -377,17 +377,17 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var luaActor = a.ToLuaValue(context))
|
using (var luaActor = a.ToLuaValue(Context))
|
||||||
using (var id = triggerId.ToLuaValue(context))
|
using (var id = triggerId.ToLuaValue(Context))
|
||||||
onExit.Call(luaActor, id).Dispose();
|
onExit.Call(luaActor, id).Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
context.FatalError(e.Message);
|
Context.FatalError(e.Message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
triggerId = context.World.ActorMap.AddProximityTrigger(pos, range, null, invokeExit);
|
triggerId = Context.World.ActorMap.AddProximityTrigger(pos, range, null, invokeExit);
|
||||||
|
|
||||||
return triggerId;
|
return triggerId;
|
||||||
}
|
}
|
||||||
@@ -395,14 +395,14 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Removes a previously created proximitry trigger.")]
|
[Desc("Removes a previously created proximitry trigger.")]
|
||||||
public void RemoveProximityTrigger(int id)
|
public void RemoveProximityTrigger(int id)
|
||||||
{
|
{
|
||||||
context.World.ActorMap.RemoveProximityTrigger(id);
|
Context.World.ActorMap.RemoveProximityTrigger(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Call a function when this actor is infiltrated. The callback function " +
|
[Desc("Call a function when this actor is infiltrated. The callback function " +
|
||||||
"will be called as func(Actor self, Actor infiltrator).")]
|
"will be called as func(Actor self, Actor infiltrator).")]
|
||||||
public void OnInfiltrated(Actor a, LuaFunction func)
|
public void OnInfiltrated(Actor a, LuaFunction func)
|
||||||
{
|
{
|
||||||
GetScriptTriggers(a).RegisterCallback(Trigger.OnInfiltrated, func, context);
|
GetScriptTriggers(a).RegisterCallback(Trigger.OnInfiltrated, func, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Removes all triggers from this actor." +
|
[Desc("Removes all triggers from this actor." +
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Skips over the first numElements members of a table and return the rest.")]
|
[Desc("Skips over the first numElements members of a table and return the rest.")]
|
||||||
public LuaTable Skip(LuaTable table, int numElements)
|
public LuaTable Skip(LuaTable table, int numElements)
|
||||||
{
|
{
|
||||||
var t = context.CreateTable();
|
var t = Context.CreateTable();
|
||||||
|
|
||||||
for (var i = numElements; i <= table.Count; i++)
|
for (var i = numElements; i <= table.Count; i++)
|
||||||
t.Add(t.Count + 1, table[i]);
|
t.Add(t.Count + 1, table[i]);
|
||||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Returns a random value from a collection.")]
|
[Desc("Returns a random value from a collection.")]
|
||||||
public LuaValue Random(LuaValue[] collection)
|
public LuaValue Random(LuaValue[] collection)
|
||||||
{
|
{
|
||||||
return collection.Random(context.World.SharedRandom);
|
return collection.Random(Context.World.SharedRandom);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Expands the given footprint one step along the coordinate axes, and (if requested) diagonals.")]
|
[Desc("Expands the given footprint one step along the coordinate axes, and (if requested) diagonals.")]
|
||||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
if (high <= low)
|
if (high <= low)
|
||||||
return low;
|
return low;
|
||||||
|
|
||||||
return context.World.SharedRandom.Next(low, high);
|
return Context.World.SharedRandom.Next(low, high);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Returns true if the player is allied with the other player.")]
|
[Desc("Returns true if the player is allied with the other player.")]
|
||||||
public bool IsAlliedWith(Player targetPlayer)
|
public bool IsAlliedWith(Player targetPlayer)
|
||||||
{
|
{
|
||||||
return player.IsAlliedWith(targetPlayer);
|
return Player.IsAlliedWith(targetPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Changes the current stance of the player against the target player. " +
|
[Desc("Changes the current stance of the player against the target player. " +
|
||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public void SetStance(Player targetPlayer, string newStance)
|
public void SetStance(Player targetPlayer, string newStance)
|
||||||
{
|
{
|
||||||
var emergingStance = Enum<Stance>.Parse(newStance);
|
var emergingStance = Enum<Stance>.Parse(newStance);
|
||||||
player.SetStance(targetPlayer, emergingStance);
|
Player.SetStance(targetPlayer, emergingStance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public int Health
|
public int Health
|
||||||
{
|
{
|
||||||
get { return health.HP; }
|
get { return health.HP; }
|
||||||
set { health.InflictDamage(self, self, health.HP - value, null, true); }
|
set { health.InflictDamage(Self, Self, health.HP - value, null, true); }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Maximum health of the actor.")]
|
[Desc("Maximum health of the actor.")]
|
||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Kill the actor.")]
|
[Desc("Kill the actor.")]
|
||||||
public void Kill()
|
public void Kill()
|
||||||
{
|
{
|
||||||
health.InflictDamage(self, self, health.MaxHP, null, true);
|
health.InflictDamage(Self, Self, health.MaxHP, null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,25 +27,25 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Grant an upgrade to this actor.")]
|
[Desc("Grant an upgrade to this actor.")]
|
||||||
public void GrantUpgrade(string upgrade)
|
public void GrantUpgrade(string upgrade)
|
||||||
{
|
{
|
||||||
um.GrantUpgrade(self, upgrade, this);
|
um.GrantUpgrade(Self, upgrade, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Revoke an upgrade that was previously granted using GrantUpgrade.")]
|
[Desc("Revoke an upgrade that was previously granted using GrantUpgrade.")]
|
||||||
public void RevokeUpgrade(string upgrade)
|
public void RevokeUpgrade(string upgrade)
|
||||||
{
|
{
|
||||||
um.RevokeUpgrade(self, upgrade, this);
|
um.RevokeUpgrade(Self, upgrade, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Grant a limited-time upgrade to this actor.")]
|
[Desc("Grant a limited-time upgrade to this actor.")]
|
||||||
public void GrantTimedUpgrade(string upgrade, int duration)
|
public void GrantTimedUpgrade(string upgrade, int duration)
|
||||||
{
|
{
|
||||||
um.GrantTimedUpgrade(self, upgrade, duration);
|
um.GrantTimedUpgrade(Self, upgrade, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Check whether this actor accepts a specific upgrade.")]
|
[Desc("Check whether this actor accepts a specific upgrade.")]
|
||||||
public bool AcceptsUpgrade(string upgrade)
|
public bool AcceptsUpgrade(string upgrade)
|
||||||
{
|
{
|
||||||
return um.AcceptsUpgrade(self, upgrade);
|
return um.AcceptsUpgrade(Self, upgrade);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")]
|
[Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")]
|
||||||
public class ScriptTriggersInfo : ITraitInfo
|
public class ScriptTriggersInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public object Create(ActorInitializer init) { return new ScriptTriggers(init.world); }
|
public object Create(ActorInitializer init) { return new ScriptTriggers(init.World); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction, INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisposable
|
public sealed class ScriptTriggers : INotifyIdle, INotifyDamage, INotifyKilled, INotifyProduction, INotifyOtherProduction, INotifyObjectivesUpdated, INotifyCapture, INotifyInfiltrated, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisposable
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var defaults = new Session.Global();
|
var defaults = new Session.Global();
|
||||||
FieldLoader.Load(defaults, Game.modData.Manifest.LobbyDefaults);
|
FieldLoader.Load(defaults, Game.ModData.Manifest.LobbyDefaults);
|
||||||
|
|
||||||
if (server.LobbyInfo.GlobalSettings.FragileAlliances != defaults.FragileAlliances)
|
if (server.LobbyInfo.GlobalSettings.FragileAlliances != defaults.FragileAlliances)
|
||||||
server.SendOrderTo(conn, "Message", "Diplomacy Changes: {0}".F(server.LobbyInfo.GlobalSettings.FragileAlliances));
|
server.SendOrderTo(conn, "Message", "Diplomacy Changes: {0}".F(server.LobbyInfo.GlobalSettings.FragileAlliances));
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public Aircraft(ActorInitializer init, AircraftInfo info)
|
public Aircraft(ActorInitializer init, AircraftInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.self = init.self;
|
this.self = init.Self;
|
||||||
|
|
||||||
if (init.Contains<LocationInit>())
|
if (init.Contains<LocationInit>())
|
||||||
SetPosition(self, init.Get<LocationInit, CPos>());
|
SetPosition(self, init.Get<LocationInit, CPos>());
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly string Guns = "secondary";
|
public readonly string Guns = "secondary";
|
||||||
public readonly int FacingTolerance = 2;
|
public readonly int FacingTolerance = 2;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new AttackBomber(init.self, this); }
|
public override object Create(ActorInitializer init) { return new AttackBomber(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AttackBomber : AttackBase, ITick, ISync, INotifyRemovedFromWorld
|
public class AttackBomber : AttackBase, ITick, ISync, INotifyRemovedFromWorld
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
public class AttackHeliInfo : AttackFrontalInfo
|
public class AttackHeliInfo : AttackFrontalInfo
|
||||||
{
|
{
|
||||||
public override object Create(ActorInitializer init) { return new AttackHeli(init.self, this); }
|
public override object Create(ActorInitializer init) { return new AttackHeli(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AttackHeli : AttackFrontal
|
public class AttackHeli : AttackFrontal
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
public class AttackPlaneInfo : AttackFrontalInfo
|
public class AttackPlaneInfo : AttackFrontalInfo
|
||||||
{
|
{
|
||||||
public override object Create(ActorInitializer init) { return new AttackPlane(init.self, this); }
|
public override object Create(ActorInitializer init) { return new AttackPlane(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AttackPlane : AttackFrontal
|
public class AttackPlane : AttackFrontal
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly bool Moves = false;
|
public readonly bool Moves = false;
|
||||||
public readonly WRange Velocity = new WRange(43);
|
public readonly WRange Velocity = new WRange(43);
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new FallsToEarth(init.self, this); }
|
public object Create(ActorInitializer init) { return new FallsToEarth(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FallsToEarth
|
public class FallsToEarth
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user