StyleCop clean OpenRA.Game

This commit is contained in:
Matthias Mailänder
2015-01-04 11:56:13 +01:00
parent d2d715765c
commit bc3acfeee7
345 changed files with 835 additions and 833 deletions

View File

@@ -179,6 +179,8 @@ test:
@mono --debug OpenRA.Utility.exe ts --check-yaml
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..."
@mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Renderer.Null
@echo "Checking for code style violations in OpenRA.GameMonitor..."

View File

@@ -47,11 +47,11 @@ namespace OpenRA.Editor
currentMod = toolStripComboBox1.SelectedItem as string;
Game.InitializeSettings(Arguments.Empty);
Game.modData = new ModData(currentMod);
GlobalFileSystem.LoadFromManifest(Game.modData.Manifest);
Program.Rules = Game.modData.RulesetCache.LoadDefaultRules();
Game.ModData = new ModData(currentMod);
GlobalFileSystem.LoadFromManifest(Game.ModData.Manifest);
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);
loadedMapName = null;
@@ -129,7 +129,7 @@ namespace OpenRA.Editor
if (map.Players.Count == 0)
map.MakeDefaultPlayers();
PrepareMapResources(Game.modData, map);
PrepareMapResources(Game.ModData, map);
// Calculate total net worth of resources in cash
cashToolStripStatusLabel.Text = CalculateTotalResource().ToString();
@@ -144,7 +144,7 @@ namespace OpenRA.Editor
resourcePalette.Controls.Clear();
loadedMapName = null;
PrepareMapResources(Game.modData, map);
PrepareMapResources(Game.ModData, map);
MakeDirty();
}

View File

@@ -312,7 +312,7 @@ namespace OpenRA.Editor
{
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);
ControlPaint.DrawGrid(g, rect, new Size(2, ts.Height), Color.DarkRed);
ControlPaint.DrawGrid(g, rect, new Size(ts.Width, 2), Color.DarkRed);

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Editor
this.TileSize = Math.Min(tileSize.Width, tileSize.Height);
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)
{
var allFrames = frameCache[t.Value.Image];

View File

@@ -180,27 +180,27 @@ namespace OpenRA
public T Trait<T>()
{
return World.traitDict.Get<T>(this);
return World.TraitDict.Get<T>(this);
}
public T TraitOrDefault<T>()
{
return World.traitDict.GetOrDefault<T>(this);
return World.TraitDict.GetOrDefault<T>(this);
}
public IEnumerable<T> TraitsImplementing<T>()
{
return World.traitDict.WithInterface<T>(this);
return World.TraitDict.WithInterface<T>(this);
}
public bool HasTrait<T>()
{
return World.traitDict.Contains<T>(this);
return World.TraitDict.Contains<T>(this);
}
public void AddTrait(object trait)
{
World.traitDict.AddTrait(this, trait);
World.TraitDict.AddTrait(this, trait);
}
public void Destroy()
@@ -213,7 +213,7 @@ namespace OpenRA
if (IsInWorld)
World.Remove(this);
World.traitDict.RemoveActor(this);
World.TraitDict.RemoveActor(this);
Destroyed = true;
if (luaInterface != null)

View File

@@ -31,12 +31,12 @@ namespace OpenRA
public const int Timestep = 40;
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 ICursor Cursor;
static WorldRenderer worldRenderer;
internal static OrderManager orderManager;
internal static OrderManager OrderManager;
static Server.Server server;
public static MersenneTwister CosmeticRandom = new MersenneTwister(); // not synced
@@ -64,10 +64,10 @@ namespace OpenRA
static void JoinInner(OrderManager om)
{
if (orderManager != null) orderManager.Dispose();
orderManager = om;
if (OrderManager != null) OrderManager.Dispose();
OrderManager = om;
lastConnectionState = ConnectionState.PreConnecting;
ConnectionStateChanged(orderManager);
ConnectionStateChanged(OrderManager);
}
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 RenderFrame = 0;
public static int NetFrameNumber { get { return orderManager.NetFrameNumber; } }
public static int LocalTick { get { return orderManager.LocalFrameNumber; } }
public static int NetFrameNumber { get { return OrderManager.NetFrameNumber; } }
public static int LocalTick { get { return OrderManager.LocalFrameNumber; } }
public static event Action<string, int> OnRemoteDirectConnect = (a, b) => { };
public static event Action<OrderManager> ConnectionStateChanged = _ => { };
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)
{
@@ -101,7 +101,7 @@ namespace OpenRA
// Hacky workaround for orderManager visibility
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
@@ -110,8 +110,8 @@ namespace OpenRA
{
return Ui.OpenWindow(widget, new WidgetArgs(args)
{
{ "world", worldRenderer.world },
{ "orderManager", orderManager },
{ "world", worldRenderer.World },
{ "orderManager", OrderManager },
{ "worldRenderer", worldRenderer },
});
}
@@ -119,10 +119,10 @@ namespace OpenRA
// 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)
{
return modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
return ModData.WidgetLoader.LoadWidget(new WidgetArgs(args)
{
{ "world", world },
{ "orderManager", orderManager },
{ "orderManager", OrderManager },
{ "worldRenderer", worldRenderer },
}, parent, id);
}
@@ -143,29 +143,29 @@ namespace OpenRA
Map map;
using (new PerfTimer("PrepareMap"))
map = modData.PrepareMap(mapUID);
map = ModData.PrepareMap(mapUID);
using (new PerfTimer("NewWorld"))
{
orderManager.World = new World(map, orderManager, isShellmap);
orderManager.World.Timestep = Timestep;
OrderManager.World = new World(map, OrderManager, isShellmap);
OrderManager.World.Timestep = Timestep;
}
if (worldRenderer != null)
worldRenderer.Dispose();
worldRenderer = new WorldRenderer(orderManager.World);
worldRenderer = new WorldRenderer(OrderManager.World);
using (new PerfTimer("LoadComplete"))
orderManager.World.LoadComplete(worldRenderer);
OrderManager.World.LoadComplete(worldRenderer);
if (orderManager.GameStarted)
if (OrderManager.GameStarted)
return;
Ui.MouseFocusWidget = null;
Ui.KeyboardFocusWidget = null;
orderManager.LocalFrameNumber = 0;
orderManager.LastTickTime = RunTime;
orderManager.StartGame();
OrderManager.LocalFrameNumber = 0;
OrderManager.LastTickTime = RunTime;
OrderManager.StartGame();
worldRenderer.RefreshPalette();
Cursor.SetCursor("default");
@@ -176,8 +176,8 @@ namespace OpenRA
{
get
{
var id = orderManager.Connection.LocalClientId;
var client = orderManager.LobbyInfo.ClientWithIndex(id);
var id = OrderManager.Connection.LocalClientId;
var client = OrderManager.LobbyInfo.ClientWithIndex(id);
return client != null && client.IsAdmin;
}
}
@@ -282,12 +282,12 @@ namespace OpenRA
worldRenderer = null;
if (server != null)
server.Shutdown();
if (orderManager != null)
orderManager.Dispose();
if (OrderManager != null)
OrderManager.Dispose();
if (modData != null)
modData.Dispose();
modData = null;
if (ModData != null)
ModData.Dispose();
ModData = null;
// Fall back to default if the mod doesn't exist
if (!ModMetadata.AllMods.ContainsKey(mod))
@@ -300,18 +300,18 @@ namespace OpenRA
Sound.StopVideo();
Sound.Initialize();
modData = new ModData(mod, true);
ModData = new ModData(mod, true);
Renderer.InitializeFonts(modData.Manifest);
modData.InitializeLoaders();
Renderer.InitializeFonts(ModData.Manifest);
ModData.InitializeLoaders();
using (new PerfTimer("LoadMaps"))
modData.MapCache.LoadMaps();
ModData.MapCache.LoadMaps();
if (Settings.Graphics.HardwareCursors)
{
try
{
Cursor = new HardwareCursor(modData.CursorProvider);
Cursor = new HardwareCursor(ModData.CursorProvider);
}
catch (Exception e)
{
@@ -321,12 +321,12 @@ namespace OpenRA
Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors.");
Console.WriteLine("Error was: " + e.Message);
Cursor = new SoftwareCursor(modData.CursorProvider);
Cursor = new SoftwareCursor(ModData.CursorProvider);
Settings.Graphics.HardwareCursors = false;
}
}
else
Cursor = new SoftwareCursor(modData.CursorProvider);
Cursor = new SoftwareCursor(ModData.CursorProvider);
PerfHistory.Items["render"].HasNormalTick = false;
PerfHistory.Items["batches"].HasNormalTick = false;
@@ -357,7 +357,7 @@ namespace OpenRA
if (Settings.Server.DedicatedLoop)
{
Console.WriteLine("Starting a new server instance...");
modData.MapCache.LoadMaps();
ModData.MapCache.LoadMaps();
continue;
}
@@ -367,7 +367,7 @@ namespace OpenRA
Environment.Exit(0);
}
else
modData.LoadScreen.StartGame(args);
ModData.LoadScreen.StartGame(args);
}
public static void LoadShellMap()
@@ -380,7 +380,7 @@ namespace OpenRA
static string ChooseShellmap()
{
var shellmaps = modData.MapCache
var shellmaps = ModData.MapCache
.Where(m => m.Status == MapStatus.Available && m.Map.Visibility.HasFlag(MapVisibility.Shellmap))
.Select(m => m.Uid);
@@ -471,15 +471,15 @@ namespace OpenRA
{
delayedActions.PerformActions();
if (orderManager.Connection.ConnectionState != lastConnectionState)
if (OrderManager.Connection.ConnectionState != lastConnectionState)
{
lastConnectionState = orderManager.Connection.ConnectionState;
ConnectionStateChanged(orderManager);
lastConnectionState = OrderManager.Connection.ConnectionState;
ConnectionStateChanged(OrderManager);
}
InnerLogicTick(orderManager);
if (worldRenderer != null && orderManager.World != worldRenderer.world)
InnerLogicTick(worldRenderer.world.orderManager);
InnerLogicTick(OrderManager);
if (worldRenderer != null && OrderManager.World != worldRenderer.World)
InnerLogicTick(worldRenderer.World.OrderManager);
}
static void RenderTick()
@@ -502,7 +502,7 @@ namespace OpenRA
{
Ui.Draw();
if (modData != null && modData.CursorProvider != null)
if (ModData != null && ModData.CursorProvider != null)
{
Cursor.SetCursor(Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default");
Cursor.Render(Renderer);
@@ -510,7 +510,7 @@ namespace OpenRA
}
using (new PerfSample("render_flip"))
Renderer.EndFrame(new DefaultInputHandler(orderManager.World));
Renderer.EndFrame(new DefaultInputHandler(OrderManager.World));
}
PerfHistory.Items["render"].Tick();
@@ -567,7 +567,7 @@ namespace OpenRA
{
// Ideal time between logic updates. Timestep = 0 means the game is paused
// 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
var maxFramerate = Settings.Graphics.CapFramerate ? Settings.Graphics.MaxFramerate.Clamp(1, 1000) : 1000;
@@ -592,7 +592,7 @@ namespace OpenRA
LogicTick();
// 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;
}
@@ -636,13 +636,13 @@ namespace OpenRA
finally
{
// Ensure that the active replay is properly saved
if (orderManager != null)
orderManager.Dispose();
if (OrderManager != null)
OrderManager.Dispose();
}
if (worldRenderer != null)
worldRenderer.Dispose();
modData.Dispose();
ModData.Dispose();
ChromeProvider.Deinitialize();
Renderer.Dispose();
@@ -663,7 +663,7 @@ namespace OpenRA
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)
@@ -673,10 +673,10 @@ namespace OpenRA
public static void Disconnect()
{
if (orderManager.World != null)
orderManager.World.traitDict.PrintReport();
if (OrderManager.World != null)
OrderManager.World.TraitDict.PrintReport();
orderManager.Dispose();
OrderManager.Dispose();
CloseServer();
JoinLocal();
}
@@ -689,12 +689,12 @@ namespace OpenRA
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)
{
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)
@@ -707,14 +707,14 @@ namespace OpenRA
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;
}
public static bool IsCurrentWorld(World world)
{
return orderManager != null && orderManager.World == world;
return OrderManager != null && OrderManager.World == world;
}
}
}

View File

@@ -29,7 +29,7 @@ namespace OpenRA
// replay recording stopped.
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } }
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 bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } }

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Graphics
static void LoadCollection(string name, MiniYaml yaml)
{
Game.modData.LoadScreen.Display();
Game.ModData.LoadScreen.Display();
var collection = new Collection()
{
Src = yaml.Value,

View File

@@ -87,19 +87,19 @@ namespace OpenRA.Graphics
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 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)
{
var offset = ScreenPosition(wr) + sprite.offset;
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + sprite.size, Color.Red);
var offset = ScreenPosition(wr) + sprite.Offset;
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + sprite.Size, Color.Red);
}
}
}

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Graphics
// Apply offset to each sprite in the sequence
// Different sequences may apply different offsets to the same frame
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"))
Length = 1;

View File

@@ -79,11 +79,11 @@ namespace OpenRA.Graphics
var cursorSequence = cursorProvider.GetCursorSequence(cursorName);
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 ?
(2 * cursorSequence.Hotspot) + cursorSprite.size.ToInt2() :
cursorSequence.Hotspot + (0.5f * cursorSprite.size).ToInt2();
(2 * cursorSequence.Hotspot) + cursorSprite.Size.ToInt2() :
cursorSequence.Hotspot + (0.5f * cursorSprite.Size).ToInt2();
renderer.SetPalette(palette);
renderer.SpriteRenderer.DrawSprite(cursorSprite,

View File

@@ -14,14 +14,14 @@ namespace OpenRA.Graphics
{
public class Sprite
{
public readonly Rectangle bounds;
public readonly Sheet sheet;
public readonly BlendMode blendMode;
public readonly TextureChannel channel;
public readonly float2 size;
public readonly float2 offset;
public readonly float2 fractionalOffset;
public readonly float top, left, bottom, right;
public readonly Rectangle Bounds;
public readonly Sheet Sheet;
public readonly BlendMode BlendMode;
public readonly TextureChannel Channel;
public readonly float2 Size;
public readonly float2 Offset;
public readonly float2 FractionalOffset;
public readonly float Top, Left, Bottom, Right;
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
: 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)
{
this.sheet = sheet;
this.bounds = bounds;
this.offset = offset;
this.channel = channel;
this.size = new float2(bounds.Size);
this.blendMode = blendMode;
Sheet = sheet;
Bounds = bounds;
Offset = offset;
Channel = channel;
Size = new float2(bounds.Size);
BlendMode = blendMode;
this.fractionalOffset = offset / this.size;
FractionalOffset = offset / Size;
left = (float)bounds.Left / sheet.Size.Width;
top = (float)bounds.Top / sheet.Size.Height;
right = (float)bounds.Right / sheet.Size.Width;
bottom = (float)bounds.Bottom / sheet.Size.Height;
Left = (float)bounds.Left / sheet.Size.Width;
Top = (float)bounds.Top / sheet.Size.Height;
Right = (float)bounds.Right / sheet.Size.Width;
Bottom = (float)bounds.Bottom / sheet.Size.Height;
}
}

View File

@@ -117,15 +117,15 @@ namespace OpenRA.Graphics
unsafe
{
var p = (byte*)bitmap.Buffer;
var dest = s.sheet.GetData();
var destStride = s.sheet.Size.Width * 4;
var dest = s.Sheet.GetData();
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)
{
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 + 1] = c.Second.G;
dest[q + 2] = c.Second.R;
@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
}
}
s.sheet.CommitData();
s.Sheet.CommitData();
return g;
}

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Graphics
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)
@@ -63,25 +63,25 @@ namespace OpenRA.Graphics
{
renderer.CurrentBatchRenderer = this;
if (s.sheet != currentSheet)
if (s.Sheet != currentSheet)
Flush();
if (s.blendMode != currentBlend)
if (s.BlendMode != currentBlend)
Flush();
if (nv + 4 > renderer.TempBufferSize)
Flush();
currentBlend = s.blendMode;
currentSheet = s.sheet;
Util.FastCreateQuad(vertices, location + s.fractionalOffset * size, s, paletteIndex, nv, size);
currentBlend = s.BlendMode;
currentSheet = s.Sheet;
Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, paletteIndex, nv, size);
nv += 4;
}
// For RGBASpriteRenderer, which doesn't use palettes
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)
@@ -93,17 +93,17 @@ namespace OpenRA.Graphics
{
renderer.CurrentBatchRenderer = this;
if (s.sheet != currentSheet)
if (s.Sheet != currentSheet)
Flush();
if (s.blendMode != currentBlend)
if (s.BlendMode != currentBlend)
Flush();
if (nv + 4 > renderer.TempBufferSize)
Flush();
currentSheet = s.sheet;
currentBlend = s.blendMode;
currentSheet = s.Sheet;
currentBlend = s.BlendMode;
Util.FastCreateQuad(vertices, a, b, c, d, s, 0, nv);
nv += 4;
}

View File

@@ -31,8 +31,8 @@ namespace OpenRA.Graphics
foreach (var cell in map.Cells)
{
var tile = wr.Theater.TileSprite(map.MapTiles.Value[cell]);
var pos = wr.ScreenPosition(map.CenterOfCell(cell)) + tile.offset - 0.5f * tile.size;
Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.size);
var pos = wr.ScreenPosition(map.CenterOfCell(cell)) + tile.Offset - 0.5f * tile.Size;
Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.Size);
nv += 4;
}
@@ -44,7 +44,7 @@ namespace OpenRA.Graphics
{
var verticesPerRow = 4 * map.Bounds.Width;
var cells = viewport.VisibleCells;
var shape = wr.world.Map.TileShape;
var shape = wr.World.Map.TileShape;
// Only draw the rows that are visible.
// VisibleCells is clamped to the map, so additional checks are unnecessary

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Graphics
sheetBuilder = new SheetBuilder(SheetType.Indexed, allocate);
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)
{
var allFrames = frameCache[t.Value.Image];
@@ -48,7 +48,7 @@ namespace OpenRA.Graphics
// Ignore the offsets baked into R8 sprites
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());
}
@@ -91,8 +91,8 @@ namespace OpenRA.Graphics
var u = tileShape == TileShape.Rectangle ? x : (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 rect = new Rectangle((int)(tl.X + sprite.offset.X), (int)(tl.Y + sprite.offset.Y), (int)sprite.size.X, (int)sprite.size.Y);
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);
templateRect = templateRect.HasValue ? Rectangle.Union(templateRect.Value, rect) : rect;
}
}

View File

@@ -49,13 +49,13 @@ namespace OpenRA.Graphics
public void BeforeRender(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)
{
var offset = screenPos + sprite.offset;
Game.Renderer.LineRenderer.DrawRect(offset, offset + sprite.size, Color.Red);
var offset = screenPos + sprite.Offset;
Game.Renderer.LineRenderer.DrawRect(offset, offset + sprite.Size, Color.Red);
}
}
}

View File

@@ -18,8 +18,8 @@ namespace OpenRA.Graphics
public static class Util
{
// yes, our channel order is nuts.
static readonly int[] channelMasks = { 2, 1, 0, 3 };
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
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)
{
@@ -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)
{
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 + 1] = new Vertex(b, r.right, r.top, 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] = new Vertex(a, r.Left, 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 + 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, int channelOffset, byte[] src)
{
var data = dest.sheet.GetData();
var srcStride = dest.bounds.Width;
var destStride = dest.sheet.Size.Width * 4;
var destOffset = destStride * dest.bounds.Top + dest.bounds.Left * 4 + channelMasks[(int)dest.channel + channelOffset];
var data = dest.Sheet.GetData();
var srcStride = dest.Bounds.Width;
var destStride = dest.Sheet.Size.Width * 4;
var destOffset = destStride * dest.Bounds.Top + dest.Bounds.Left * 4 + ChannelMasks[(int)dest.Channel + channelOffset];
var destSkip = destStride - 4 * srcStride;
var height = dest.bounds.Height;
var height = dest.Bounds.Height;
var srcOffset = 0;
for (var j = 0; j < height; j++)
@@ -65,12 +65,12 @@ namespace OpenRA.Graphics
public static void FastCopyIntoSprite(Sprite dest, Bitmap src)
{
var data = dest.sheet.GetData();
var dataStride = dest.sheet.Size.Width * 4;
var x = dest.bounds.Left * 4;
var width = dest.bounds.Width * 4;
var y = dest.bounds.Top;
var height = dest.bounds.Height;
var data = dest.Sheet.GetData();
var dataStride = dest.Sheet.Size.Width * 4;
var x = dest.Bounds.Left * 4;
var width = dest.Bounds.Width * 4;
var y = dest.Bounds.Top;
var height = dest.Bounds.Height;
var bd = src.LockBits(src.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

View File

@@ -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));
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;
Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
}
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; }
@@ -142,7 +142,7 @@ namespace OpenRA.Graphics
get
{
// 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 cbr = map.CenterOfCell(VisibleCells.BottomRight) + new WVec(512, 512, 0);
@@ -159,7 +159,7 @@ namespace OpenRA.Graphics
{
if (cellsDirty)
{
var map = worldRenderer.world.Map;
var map = worldRenderer.World.Map;
var wtl = worldRenderer.Position(TopLeft);
var wbr = worldRenderer.Position(BottomRight);

View File

@@ -86,16 +86,16 @@ namespace OpenRA.Graphics
var s = sheetBuilder.Allocate(new Size(su, sv));
Util.FastCopyIntoChannel(s, 0, colors);
Util.FastCopyIntoChannel(s, 1, normals);
s.sheet.CommitData();
s.Sheet.CommitData();
var channelP = ChannelSelect[(int)s.channel];
var channelC = ChannelSelect[(int)s.channel + 1];
var channelP = ChannelSelect[(int)s.Channel];
var channelC = ChannelSelect[(int)s.Channel + 1];
return new Vertex[4]
{
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, sv), s.right, s.bottom, channelP, channelC),
new Vertex(coord(0, sv), s.left, s.bottom, 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, sv), s.Right, s.Bottom, channelP, channelC),
new Vertex(coord(0, sv), s.Left, s.Bottom, channelP, channelC)
};
}

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
foreach (var s in sequences)
LoadVoxelsForUnit(s.Key, s.Value);
Game.modData.VoxelLoader.RefreshBuffer();
Game.ModData.VoxelLoader.RefreshBuffer();
}
static Voxel LoadVoxel(string unit, MiniYaml info)
@@ -47,12 +47,12 @@ namespace OpenRA.Graphics
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)
{
Game.modData.LoadScreen.Display();
Game.ModData.LoadScreen.Display();
try
{
var seq = sequences.ToDictionary(my => LoadVoxel(unit, my));

View File

@@ -161,8 +161,8 @@ namespace OpenRA.Graphics
var sprite = sheetBuilder.Allocate(spriteSize, spriteOffset);
var shadowSprite = sheetBuilder.Allocate(shadowSpriteSize, shadowSpriteOffset);
var sb = sprite.bounds;
var ssb = shadowSprite.bounds;
var sb = sprite.Bounds;
var ssb = shadowSprite.Bounds;
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);
@@ -171,7 +171,7 @@ namespace OpenRA.Graphics
var correctionTransform = Util.MatrixMultiply(translateMtx, FlipMtx);
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)
{
@@ -262,7 +262,7 @@ namespace OpenRA.Graphics
shader.SetVec("AmbientLight", ambientLight, 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()

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Graphics
public sealed class WorldRenderer : IDisposable
{
public readonly World world;
public readonly World World;
public readonly Theater Theater;
public Viewport Viewport { get; private set; }
@@ -42,10 +42,10 @@ namespace OpenRA.Graphics
internal WorldRenderer(World world)
{
this.world = world;
World = world;
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);
palette.Initialize();
@@ -70,27 +70,27 @@ namespace OpenRA.Graphics
List<IRenderable> GenerateRenderables()
{
var comparer = new RenderableComparer(this);
var actors = world.ScreenMap.ActorsInBox(Viewport.TopLeft, Viewport.BottomRight)
.Append(world.WorldActor)
var actors = World.ScreenMap.ActorsInBox(Viewport.TopLeft, Viewport.BottomRight)
.Append(World.WorldActor)
.ToList();
// Include player actor for the rendered player
if (world.RenderPlayer != null)
actors.Add(world.RenderPlayer.PlayerActor);
if (World.RenderPlayer != null)
actors.Add(World.RenderPlayer.PlayerActor);
var worldRenderables = actors.SelectMany(a => a.Render(this));
if (world.OrderGenerator != null)
worldRenderables = worldRenderables.Concat(world.OrderGenerator.Render(this, world));
if (World.OrderGenerator != null)
worldRenderables = worldRenderables.Concat(World.OrderGenerator.Render(this, World));
worldRenderables = worldRenderables.OrderBy(r => r, comparer);
// Effects are drawn on top of all actors
// HACK: Effects aren't interleaved with actors.
var effectRenderables = world.Effects
var effectRenderables = World.Effects
.SelectMany(e => e.Render(this));
if (world.OrderGenerator != null)
effectRenderables = effectRenderables.Concat(world.OrderGenerator.RenderAfterWorld(this, world));
if (World.OrderGenerator != null)
effectRenderables = effectRenderables.Concat(World.OrderGenerator.RenderAfterWorld(this, World));
// Iterating via foreach copies the structs, so enumerate by index
var renderables = worldRenderables.Concat(effectRenderables).ToList();
@@ -107,7 +107,7 @@ namespace OpenRA.Graphics
{
RefreshPalette();
if (world.IsShellmap && !Game.Settings.Game.ShowShellmap)
if (World.IsShellmap && !Game.Settings.Game.ShowShellmap)
return;
var renderables = GenerateRenderables();
@@ -121,13 +121,13 @@ namespace OpenRA.Graphics
renderables[i].Render(this);
// added for contrails
foreach (var a in world.ActorsWithTrait<IPostRender>())
foreach (var a in World.ActorsWithTrait<IPostRender>())
if (a.Actor.IsInWorld && !a.Actor.Destroyed)
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);
if (devTrait.Value != null && devTrait.Value.ShowDebugGeometry)
@@ -136,7 +136,7 @@ namespace OpenRA.Graphics
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(t => t.RenderAfterWorld(this))
.ToList();
@@ -156,12 +156,12 @@ namespace OpenRA.Graphics
foreach (var r in g)
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>()
&& !world.FogObscures(a)
&& !world.Selection.Actors.Contains(a)))
&& !World.FogObscures(a)
&& !World.Selection.Actors.Contains(a)))
DrawRollover(g);
}
@@ -206,14 +206,14 @@ namespace OpenRA.Graphics
public void RefreshPalette()
{
palette.ApplyModifiers(world.WorldActor.TraitsImplementing<IPaletteModifier>());
palette.ApplyModifiers(World.WorldActor.TraitsImplementing<IPaletteModifier>());
Game.Renderer.SetPalette(palette);
}
// Conversion between world and screen coordinates
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);
}
@@ -227,7 +227,7 @@ namespace OpenRA.Graphics
// For scaling vectors to pixel sizes in the voxel renderer
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 };
}
@@ -240,13 +240,13 @@ namespace OpenRA.Graphics
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;
}
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);
}

View File

@@ -16,19 +16,19 @@ namespace OpenRA
{
public class ActorInitializer
{
public readonly Actor self;
public World world { get { return self.World; } }
public readonly Actor Self;
public World World { get { return Self.World; } }
internal TypeDictionary Dict;
public ActorInitializer(Actor actor, TypeDictionary dict)
{
self = actor;
Self = actor;
Dict = dict;
}
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>(); }
}

View File

@@ -204,7 +204,7 @@ namespace OpenRA
public static Map FromTileset(TileSet tileset)
{
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 makeMapTiles = Exts.Lazy(() =>
@@ -328,10 +328,10 @@ namespace OpenRA
MapResources = Exts.Lazy(() => LoadResourceTiles());
MapHeight = Exts.Lazy(() => LoadMapHeight());
TileShape = Game.modData.Manifest.TileShape;
SubCellOffsets = Game.modData.Manifest.SubCellOffsets;
TileShape = Game.ModData.Manifest.TileShape;
SubCellOffsets = Game.ModData.Manifest.SubCellOffsets;
LastSubCell = (SubCell)(SubCellOffsets.Length - 1);
DefaultSubCell = (SubCell)Game.modData.Manifest.SubCellDefaultIndex;
DefaultSubCell = (SubCell)Game.ModData.Manifest.SubCellDefaultIndex;
if (Container.Exists("map.png"))
using (var dataStream = Container.GetContent("map.png"))
@@ -354,7 +354,7 @@ namespace OpenRA
{
try
{
return Game.modData.RulesetCache.LoadMapRules(this);
return Game.ModData.RulesetCache.LoadMapRules(this);
}
catch (Exception e)
{
@@ -362,7 +362,7 @@ namespace OpenRA
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]);

View File

@@ -167,7 +167,7 @@ namespace OpenRA
return;
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
if (!Directory.Exists(baseMapPath))

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Network
else
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;
}
}

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Network
void StartSavingReplay(byte[] initialContent)
{
var filename = chooseFilename();
var mod = Game.modData.Manifest.Mod;
var mod = Game.ModData.Manifest.Mod;
var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Version);
if (!Directory.Exists(dir))

View File

@@ -101,7 +101,7 @@ namespace OpenRA.Network
{
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", "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);

View File

@@ -93,7 +93,7 @@ namespace OpenRA.Network
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.LoadShellMap();
@@ -129,7 +129,7 @@ namespace OpenRA.Network
case "HandshakeRequest":
{
// 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);
ModMetadata serverMod;
@@ -142,7 +142,7 @@ namespace OpenRA.Network
"Launch.Replay=" + replay.Filename :
"Launch.Connect=" + orderManager.Host + ":" + orderManager.Port;
Game.modData.LoadScreen.Display();
Game.ModData.LoadScreen.Display();
Game.InitializeMod(request.Mod, new Arguments(launchCommand));
break;
@@ -261,7 +261,7 @@ namespace OpenRA.Network
case "SetStance":
{
if (!Game.orderManager.LobbyInfo.GlobalSettings.FragileAlliances)
if (!Game.OrderManager.LobbyInfo.GlobalSettings.FragileAlliances)
return;
var targetPlayer = order.Player.World.Players.FirstOrDefault(p => p.InternalName == order.TargetString);

View File

@@ -38,13 +38,13 @@ namespace OpenRA.Scripting
void InitializeBindings()
{
var commandClasses = context.ActorCommands[actor.Info].AsEnumerable();
var commandClasses = Context.ActorCommands[actor.Info].AsEnumerable();
// Destroyed actors cannot have their traits queried
if (actor.Destroyed)
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 groupCtor = cg.GetConstructor(new Type[] { typeof(ScriptContext), typeof(Actor) });

View File

@@ -47,23 +47,23 @@ namespace OpenRA.Scripting
public abstract class ScriptActorProperties
{
protected readonly Actor self;
protected readonly ScriptContext context;
protected readonly Actor Self;
protected readonly ScriptContext Context;
public ScriptActorProperties(ScriptContext context, Actor self)
{
this.self = self;
this.context = context;
Self = self;
Context = context;
}
}
public abstract class ScriptPlayerProperties
{
protected readonly Player player;
protected readonly ScriptContext context;
protected readonly Player Player;
protected readonly ScriptContext Context;
public ScriptPlayerProperties(ScriptContext context, Player player)
{
this.player = player;
this.context = context;
Player = player;
Context = context;
}
}
@@ -123,12 +123,12 @@ namespace OpenRA.Scripting
World = world;
WorldRenderer = worldRenderer;
knownActorCommands = Game.modData.ObjectCreator
knownActorCommands = Game.ModData.ObjectCreator
.GetTypesImplementing<ScriptActorProperties>()
.ToArray();
ActorCommands = new Cache<ActorInfo, Type[]>(FilterActorCommands);
PlayerCommands = Game.modData.ObjectCreator
PlayerCommands = Game.ModData.ObjectCreator
.GetTypesImplementing<ScriptPlayerProperties>()
.ToArray();
@@ -148,7 +148,7 @@ namespace OpenRA.Scripting
registerGlobal.Call("print", fn).Dispose();
// Register global tables
var bindings = Game.modData.ObjectCreator.GetTypesImplementing<ScriptGlobal>();
var bindings = Game.ModData.ObjectCreator.GetTypesImplementing<ScriptGlobal>();
foreach (var b in bindings)
{
var ctor = b.GetConstructors(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(c =>

View File

@@ -19,12 +19,12 @@ namespace OpenRA.Scripting
protected abstract string DuplicateKeyError(string memberName);
protected abstract string MemberNotFoundError(string memberName);
protected readonly ScriptContext context;
protected readonly ScriptContext Context;
Dictionary<string, ScriptMemberWrapper> members;
public ScriptObjectWrapper(ScriptContext context)
{
this.context = context;
Context = context;
}
protected void Bind(IEnumerable<object> clrObjects)
@@ -38,7 +38,7 @@ namespace OpenRA.Scripting
if (members.ContainsKey(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));
}
}
}

View File

@@ -148,7 +148,7 @@ namespace OpenRA
return null;
}
var currFrame = Game.orderManager.LocalFrameNumber;
var currFrame = Game.OrderManager.LocalFrameNumber;
var atten = 1f;
// Check if max # of instances-per-location reached:

View File

@@ -49,9 +49,9 @@ namespace OpenRA
{
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);
}

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Traits
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

View File

@@ -13,7 +13,7 @@ namespace OpenRA.Traits
[Desc("Checks for pause related desyncs. Attach this to the world actor.")]
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

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Traits
{
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

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Traits
[Desc("Required for FrozenUnderFog to work. Attach this to the player actor.")]
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

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Traits
[Desc("Allow palette modifiers to change the palette.")]
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

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Traits
[Desc("The prefix for the resulting player palettes")]
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

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Traits
public readonly int DefaultCash = 5000;
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

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Traits
public readonly int[] Bounds = 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

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Traits
{
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
@@ -68,7 +68,7 @@ namespace OpenRA.Traits
pipImages.PlayFetchIndex("groups", () => (int)group);
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);
}
@@ -81,7 +81,7 @@ namespace OpenRA.Traits
var pipImages = new Animation(self.World, "pips");
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 pipxyOffset = new int2(0, 0);
var pal = wr.Palette(Info.Palette);
@@ -127,7 +127,7 @@ namespace OpenRA.Traits
continue;
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);
// Increment row

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Traits
[Desc("Size of partition bins (cells)")]
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

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Traits
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

4
OpenRA.Game/Traits/World/ScreenMap.cs Executable file → Normal file
View File

@@ -22,7 +22,7 @@ namespace OpenRA.Traits
[Desc("Size of partition bins (world pixels)")]
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
@@ -36,7 +36,7 @@ namespace OpenRA.Traits
public ScreenMap(World world, ScreenMapInfo 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;
rows = world.Map.MapSize.Y * ts.Height / info.BinSize + 1;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Traits
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
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

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Widgets
var color = GetColor();
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,
stateOffset.Y + rb.Top + 3, 1, rb.Height - 6),

View File

@@ -132,7 +132,7 @@ namespace OpenRA.Widgets
public int2 ConvertToPreview(CPos cell)
{
var preview = Preview();
var tileShape = Game.modData.Manifest.TileShape;
var tileShape = Game.ModData.Manifest.TileShape;
var point = Map.CellToMap(tileShape, cell);
var dx = (int)(previewScale * (point.X - preview.Bounds.Left));
var dy = (int)(previewScale * (point.Y - preview.Bounds.Top));
@@ -152,9 +152,9 @@ namespace OpenRA.Widgets
return;
// Update map rect
previewScale = Math.Min(RenderBounds.Width / minimap.size.X, RenderBounds.Height / minimap.size.Y);
var w = (int)(previewScale * minimap.size.X);
var h = (int)(previewScale * minimap.size.Y);
previewScale = Math.Min(RenderBounds.Width / minimap.Size.X, RenderBounds.Height / minimap.Size.Y);
var w = (int)(previewScale * minimap.Size.X);
var h = (int)(previewScale * minimap.Size.Y);
var x = RenderBounds.X + (RenderBounds.Width - w) / 2;
var y = RenderBounds.Y + (RenderBounds.Height - h) / 2;
mapRect = new Rectangle(x, y, w, h);
@@ -172,10 +172,10 @@ namespace OpenRA.Widgets
var owned = colors.ContainsKey(p);
var pos = ConvertToPreview(p);
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)
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);
var number = Convert.ToChar('A' + spawnPoints.IndexOf(p)).ToString();

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Widgets
if (hk == Game.Settings.Keys.DevReloadChromeKey)
{
ChromeProvider.Initialize(Game.modData.Manifest.Chrome);
ChromeProvider.Initialize(Game.ModData.Manifest.Chrome);
return true;
}
}

2
OpenRA.Game/Widgets/SliderWidget.cs Executable file → Normal file
View File

@@ -118,7 +118,7 @@ namespace OpenRA.Widgets
for (var i = 0; i < Ticks; i++)
{
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);
WidgetUtils.DrawRGBA(tick, tickPos);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Widgets
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);
GetAnimation = () => anim;
}

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Widgets
if (sprite != cachedSprite)
{
offset = 0.5f * (new float2(RenderBounds.Size) - sprite.size);
offset = 0.5f * (new float2(RenderBounds.Size) - sprite.Size);
cachedSprite = sprite;
}

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Widgets
while (nextFrame > video.CurrentFrame)
{
video.AdvanceFrame();
videoSprite.sheet.GetTexture().SetData(video.FrameData);
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
skippedFrames++;
}
@@ -185,7 +185,7 @@ namespace OpenRA.Widgets
paused = true;
Sound.StopVideo();
video.Reset();
videoSprite.sheet.GetTexture().SetData(video.FrameData);
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
world.AddFrameEndTask(_ => onComplete());
}
}

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Widgets
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)
Root.RemoveChild(WindowList.Peek());
WindowList.Push(window);
@@ -67,7 +67,7 @@ namespace OpenRA.Widgets
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(); }
@@ -235,7 +235,7 @@ namespace OpenRA.Widgets
args["widget"] = this;
LogicObject = Game.modData.ObjectCreator.CreateObject<object>(Logic, args);
LogicObject = Game.ModData.ObjectCreator.CreateObject<object>(Logic, args);
args.Remove("widget");
}

View File

@@ -74,7 +74,7 @@ namespace OpenRA
static Widget NewWidget(string widgetType, WidgetArgs args)
{
widgetType = widgetType.Split('@')[0];
return Game.modData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args);
return Game.ModData.ObjectCreator.CreateObject<Widget>(widgetType + "Widget", args);
}
}
}

View File

@@ -29,33 +29,33 @@ namespace OpenRA.Widgets
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)
{
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)
{
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 x = r.Left; x < r.Right; x += (int)s.Size.X)
for (var y = r.Top; y < r.Bottom; y += (int)s.Size.Y)
{
var ss = s;
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,
s.bounds.Top,
Math.Min(left.X, (int)s.size.X),
Math.Min(left.Y, (int)s.size.Y));
ss = new Sprite(s.sheet, rr, s.channel);
var rr = new Rectangle(s.Bounds.Left,
s.Bounds.Top,
Math.Min(left.X, (int)s.Size.X),
Math.Min(left.Y, (int)s.Size.Y));
ss = new Sprite(s.Sheet, rr, s.Channel);
}
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 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; }
@@ -95,10 +95,10 @@ namespace OpenRA.Widgets
public static void DrawPanelPartial(Sprite[] ss, Rectangle bounds, PanelSides ps)
{
var marginLeft = ss[2] == null ? 0 : (int)ss[2].size.X;
var marginTop = ss[0] == null ? 0 : (int)ss[0].size.Y;
var marginRight = ss[3] == null ? 0 : (int)ss[3].size.X;
var marginBottom = ss[1] == null ? 0 : (int)ss[1].size.Y;
var marginLeft = ss[2] == null ? 0 : (int)ss[2].Size.X;
var marginTop = ss[0] == null ? 0 : (int)ss[0].Size.Y;
var marginRight = ss[3] == null ? 0 : (int)ss[3].Size.X;
var marginBottom = ss[1] == null ? 0 : (int)ss[1].Size.Y;
var marginWidth = marginRight + marginLeft;
var marginHeight = marginBottom + marginTop;
@@ -135,11 +135,11 @@ namespace OpenRA.Widgets
if (ps.HasFlags(PanelSides.Left | PanelSides.Top) && ss[4] != null)
DrawRGBA(ss[4], new float2(bounds.Left, bounds.Top));
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)
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)
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)
@@ -215,7 +215,7 @@ namespace OpenRA.Widgets
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 =>
{
@@ -237,8 +237,8 @@ namespace OpenRA.Widgets
return true;
};
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));
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));
return selected.Uid;
}

View File

@@ -25,15 +25,15 @@ namespace OpenRA
public class World
{
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 List<IEffect> effects = new List<IEffect>();
readonly Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
public int Timestep;
internal readonly OrderManager orderManager;
public Session LobbyInfo { get { return orderManager.LobbyInfo; } }
internal readonly OrderManager OrderManager;
public Session LobbyInfo { get { return OrderManager.LobbyInfo; } }
public readonly MersenneTwister SharedRandom;
@@ -87,7 +87,7 @@ namespace OpenRA
public bool IsReplay
{
get { return orderManager.Connection is ReplayConnection; }
get { return OrderManager.Connection is ReplayConnection; }
}
public bool AllowDevCommands
@@ -111,20 +111,20 @@ namespace OpenRA
public readonly ScreenMap ScreenMap;
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
{
get
{
return orderGenerator_;
return orderGenerator;
}
set
{
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)
{
IsShellmap = isShellmap;
this.orderManager = orderManager;
orderGenerator_ = new UnitOrderGenerator();
OrderManager = orderManager;
orderGenerator = new UnitOrderGenerator();
Map = map;
TileSet = map.Rules.TileSets[Map.Tileset];
@@ -189,9 +189,9 @@ namespace OpenRA
gameInfo.StartTimeUtc = DateTime.UtcNow;
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)
rc.Metadata = new ReplayMetadata(gameInfo);
}
@@ -330,7 +330,7 @@ namespace OpenRA
public IEnumerable<TraitPair<T>> ActorsWithTrait<T>()
{
return traitDict.ActorsWithTrait<T>();
return TraitDict.ActorsWithTrait<T>();
}
public void OnPlayerWinStateChanged(Player player)

View File

@@ -44,11 +44,11 @@ namespace OpenRA.Mods.Cnc.Traits
bool skippedMakeAnimation;
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
: base(init.self, info)
: base(init.Self, info)
{
this.info = info;
turret = turrets.FirstOrDefault();
rb = init.self.Trait<RenderBuilding>();
rb = init.Self.Trait<RenderBuilding>();
skippedMakeAnimation = init.Contains<SkipMakeAnimsInit>();
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Cargo aircraft used.")]
[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

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Cnc.Traits
{
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

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly string WakeLeftSequence = "wake-left";
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)
{

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Passenger CargoType to display.")]
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

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Traits
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

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly string StartSequence = "fire-start";
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

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Traits
{
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

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Apply the weapon impact this many ticks into the effect")]
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

View File

@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Common.Effects
if (anim == null || ticks >= length)
yield break;
var cell = wr.world.Map.CellContaining(pos);
var cell = wr.World.Map.CellContaining(pos);
if (!args.SourceActor.World.FogObscures(cell))
{
if (info.Shadow)

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Use player remap color instead of a custom color?")]
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

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Effects
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 return new TextRenderable(font, pos, 0, color, text);

View File

@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Effects
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 (info.Shadow)

View File

@@ -83,8 +83,8 @@ namespace OpenRA.Mods.Common.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (wr.world.FogObscures(wr.world.Map.CellContaining(target)) &&
wr.world.FogObscures(wr.world.Map.CellContaining(args.Source)))
if (wr.World.FogObscures(wr.World.Map.CellContaining(target)) &&
wr.World.FogObscures(wr.World.Map.CellContaining(args.Source)))
yield break;
if (ticks < info.BeamDuration)

View File

@@ -202,7 +202,7 @@ namespace OpenRA.Mods.Common.Effects
if (info.ContrailLength > 0)
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)
{

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (a.Destroyed || wr.world.FogObscures(a))
if (a.Destroyed || wr.World.FogObscures(a))
return SpriteRenderable.None;
return anim.Render(a.CenterPosition, wr.Palette("chrome"));

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Effects
if (!building.IsInWorld || !building.World.Selection.Actors.Contains(building))
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);
return circles.Render(pos, palette).Concat(flag.Render(pos, palette));
}

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Effects
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
yield break;
if (wr.world.FogObscures(self))
if (wr.World.FogObscures(self))
yield break;
var pos = wr.ScreenPxPosition(self.CenterPosition);

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Graphics
public readonly ActorInfo Actor;
public readonly Player Owner;
public readonly WorldRenderer WorldRenderer;
public World World { get { return WorldRenderer.world; } }
public World World { get { return WorldRenderer.World; } }
readonly TypeDictionary dict;

View File

@@ -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.
var curPos = trail[Index(next - skip - 1)];
var curCell = wr.world.Map.CellContaining(curPos);
var curCell = wr.World.Map.CellContaining(curPos);
var curColor = color;
for (var i = 0; i < length - skip - 4; i++)
{
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 nextCell = wr.world.Map.CellContaining(nextPos);
var nextCell = wr.World.Map.CellContaining(nextPos);
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
if (!world.FogObscures(curCell) && !world.FogObscures(nextCell))

View File

@@ -101,9 +101,9 @@ namespace OpenRA.Mods.Common.Graphics
public void Render(WorldRenderer wr)
{
// 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 pxOrigin = wr.ScreenPosition(pos);
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Graphics
var sc = shadowOrigin + psb[1];
var sd = shadowOrigin + psb[3];
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)
@@ -125,8 +125,8 @@ namespace OpenRA.Mods.Common.Graphics
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
// Draw sprite rect
var offset = pxOrigin + renderProxy.Sprite.offset - 0.5f * renderProxy.Sprite.size;
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + renderProxy.Sprite.size, Color.Red);
var offset = pxOrigin + renderProxy.Sprite.Offset - 0.5f * renderProxy.Sprite.Size;
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + renderProxy.Sprite.Size, Color.Red);
// Draw transformed shadow sprite rect
var c = Color.Purple;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.LoadScreens
// Check whether the mod content is installed
// 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.
var installData = Game.modData.Manifest.ContentInstaller;
var installData = Game.ModData.Manifest.ContentInstaller;
var installModContent = !installData.TestFiles.All(f => GlobalFileSystem.Exists(f));
var installModMusic = args != null && args.Contains("Install.Music");

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.LoadScreens
public void Dispose()
{
if (sprite != null)
sprite.sheet.Dispose();
sprite.Sheet.Dispose();
}
}
}

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Scripting
{
// Find the requested type
var typeName = kv.Key.ToString();
var initType = Game.modData.ObjectCreator.FindType(typeName + "Init");
var initType = Game.ModData.ObjectCreator.FindType(typeName + "Init");
if (initType == null)
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
var a = context.World.CreateActor(false, type, initDict);
var a = Context.World.CreateActor(false, type, initDict);
if (addToWorld)
context.World.AddFrameEndTask(w => w.Add(a));
Context.World.AddFrameEndTask(w => w.Add(a));
return a;
}
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Scripting
public int BuildTime(string type)
{
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));
return ai.GetBuildTime();
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Scripting
public int CruiseAltitude(string type)
{
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));
var pi = ai.Traits.GetOrDefault<ICruiseAltitudeInfo>();

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("The center of the visible viewport.")]
public WPos Position
{
get { return context.WorldRenderer.Viewport.CenterPosition; }
set { context.WorldRenderer.Viewport.Center(value); }
get { return Context.WorldRenderer.Viewport.CenterPosition; }
set { Context.WorldRenderer.Viewport.Center(value); }
}
}
}

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Get the current game time (in ticks)")]
public int GameTime
{
get { return context.World.WorldTick; }
get { return Context.World.WorldTick; }
}
[Desc("Converts the number of seconds into game time (ticks).")]

View File

@@ -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.")]
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)
{
actors = actors.Where(a =>
{
using (var f = filter.Call(a.ToLuaValue(context)))
using (var f = filter.Call(a.ToLuaValue(Context)))
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.")]
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)
{
actors = actors.Where(a =>
{
using (var f = filter.Call(a.ToLuaValue(context)))
using (var f = filter.Call(a.ToLuaValue(Context)))
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.")]
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.")]
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.")]
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.")]
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.")]
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.")]
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.")]
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.")]
public Actor[] NamedActors { get { return sma.Actors.Values.ToArray(); } }

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (LuaException e)
{
context.FatalError(e.Message);
Context.FatalError(e.Message);
}
};
}

View File

@@ -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.")]
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.")]
public Player[] GetPlayers(LuaFunction filter)
{
return context.World.Players
return Context.World.Players
.Where(p =>
{
using (var f = filter.Call(p.ToLuaValue(context)))
using (var f = filter.Call(p.ToLuaValue(Context)))
return f.First().ToBoolean();
}).ToArray();
}

View File

@@ -45,32 +45,32 @@ namespace OpenRA.Mods.Common.Scripting
}
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. " +
"The callback function will be called as func(Actor self).")]
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 " +
"function will be called as func(Actor self, Actor attacker).")]
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 " +
"function will be called as func(Actor self, Actor killer).")]
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 " +
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
context.FatalError(e.Message);
Context.FatalError(e.Message);
}
};
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Scripting
if (called)
return;
using (var killed = m.ToLuaValue(context))
using (var killed = m.ToLuaValue(Context))
copy.Call(killed).Dispose();
copy.Dispose();
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Scripting
}
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).")]
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. " +
"The callback function will be called as func(Player player).")]
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. " +
"The callback function will be called as func(Player player).")]
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. " +
"The callback function will be called as func(Player player, int objectiveID).")]
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. " +
"The callback function will be called as func(Player player, int objectiveID).")]
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. " +
"The callback function will be called as func(Player player, int objectiveID).")]
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. " +
"The callback function will be called as func(Actor self).")]
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. " +
"The callback function will be called as func(Actor self).")]
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. " +
@@ -205,7 +205,7 @@ namespace OpenRA.Mods.Common.Scripting
}
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).")]
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. " +
@@ -240,7 +240,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
context.FatalError(e.Message);
Context.FatalError(e.Message);
}
};
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
context.FatalError(e.Message);
Context.FatalError(e.Message);
}
};
@@ -293,17 +293,17 @@ namespace OpenRA.Mods.Common.Scripting
{
try
{
using (var luaActor = a.ToLuaValue(context))
using (var id = triggerId.ToLuaValue(context))
using (var luaActor = a.ToLuaValue(Context))
using (var id = triggerId.ToLuaValue(Context))
onEntry.Call(luaActor, id).Dispose();
}
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;
}
@@ -319,17 +319,17 @@ namespace OpenRA.Mods.Common.Scripting
{
try
{
using (var luaActor = a.ToLuaValue(context))
using (var id = triggerId.ToLuaValue(context))
using (var luaActor = a.ToLuaValue(Context))
using (var id = triggerId.ToLuaValue(Context))
onExit.Call(luaActor, id).Dispose();
}
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;
}
@@ -337,7 +337,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Removes a previously created footprint trigger.")]
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." +
@@ -351,17 +351,17 @@ namespace OpenRA.Mods.Common.Scripting
{
try
{
using (var luaActor = a.ToLuaValue(context))
using (var id = triggerId.ToLuaValue(context))
using (var luaActor = a.ToLuaValue(Context))
using (var id = triggerId.ToLuaValue(Context))
onEntry.Call(luaActor, id).Dispose();
}
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;
}
@@ -377,17 +377,17 @@ namespace OpenRA.Mods.Common.Scripting
{
try
{
using (var luaActor = a.ToLuaValue(context))
using (var id = triggerId.ToLuaValue(context))
using (var luaActor = a.ToLuaValue(Context))
using (var id = triggerId.ToLuaValue(Context))
onExit.Call(luaActor, id).Dispose();
}
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;
}
@@ -395,14 +395,14 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Removes a previously created proximitry trigger.")]
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 " +
"will be called as func(Actor self, Actor infiltrator).")]
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." +

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Skips over the first numElements members of a table and return the rest.")]
public LuaTable Skip(LuaTable table, int numElements)
{
var t = context.CreateTable();
var t = Context.CreateTable();
for (var i = numElements; i <= table.Count; 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.")]
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.")]
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Scripting
if (high <= low)
return low;
return context.World.SharedRandom.Next(low, high);
return Context.World.SharedRandom.Next(low, high);
}
}
}

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Returns true if the player is allied with the other player.")]
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. " +
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
public void SetStance(Player targetPlayer, string newStance)
{
var emergingStance = Enum<Stance>.Parse(newStance);
player.SetStance(targetPlayer, emergingStance);
Player.SetStance(targetPlayer, emergingStance);
}
}
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Scripting
public int Health
{
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.")]
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Kill the actor.")]
public void Kill()
{
health.InflictDamage(self, self, health.MaxHP, null, true);
health.InflictDamage(Self, Self, health.MaxHP, null, true);
}
}
}

View File

@@ -27,25 +27,25 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Grant an upgrade to this actor.")]
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.")]
public void RevokeUpgrade(string upgrade)
{
um.RevokeUpgrade(self, upgrade, this);
um.RevokeUpgrade(Self, upgrade, this);
}
[Desc("Grant a limited-time upgrade to this actor.")]
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.")]
public bool AcceptsUpgrade(string upgrade)
{
return um.AcceptsUpgrade(self, upgrade);
return um.AcceptsUpgrade(Self, upgrade);
}
}
}

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")]
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

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Server
return;
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)
server.SendOrderTo(conn, "Message", "Diplomacy Changes: {0}".F(server.LobbyInfo.GlobalSettings.FragileAlliances));

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
public Aircraft(ActorInitializer init, AircraftInfo info)
{
this.info = info;
this.self = init.self;
this.self = init.Self;
if (init.Contains<LocationInit>())
SetPosition(self, init.Get<LocationInit, CPos>());

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly string Guns = "secondary";
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

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{
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

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{
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

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool Moves = false;
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

Some files were not shown because too many files have changed in this diff Show More