diff --git a/AUTHORS b/AUTHORS index 04b4c0bccf..4a88044ee7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,6 +37,7 @@ Also thanks to: * Raymond Martineau (mart0258) * Riderr3 * Tim Mylemans (gecko) + * Tirili Past developers included: * Paul Chote (pchote) diff --git a/OpenRA.FileFormats/Palette.cs b/OpenRA.FileFormats/Palette.cs index 9b96021f6f..be5bf5e6bf 100644 --- a/OpenRA.FileFormats/Palette.cs +++ b/OpenRA.FileFormats/Palette.cs @@ -39,6 +39,12 @@ namespace OpenRA.FileFormats get { return colors; } } + public void ApplyRemap(IPaletteRemap r) + { + for(int i = 0; i < 256; i++) + colors[i] = (uint)r.GetRemappedColor(Color.FromArgb((int)colors[i]),i).ToArgb(); + } + public Palette(Stream s, int[] remapShadow) { colors = new uint[256]; @@ -61,9 +67,8 @@ namespace OpenRA.FileFormats public Palette(Palette p, IPaletteRemap r) { - colors = new uint[256]; - for(int i = 0; i < 256; i++) - colors[i] = (uint)r.GetRemappedColor(Color.FromArgb((int)p.colors[i]),i).ToArgb(); + colors = (uint[])p.colors.Clone(); + ApplyRemap(r); } public Palette(Palette p) @@ -71,6 +76,13 @@ namespace OpenRA.FileFormats colors = (uint[])p.colors.Clone(); } + public Palette(uint[] data) + { + if (data.Length != 256) + throw new InvalidDataException("Attempting to create palette with incorrect array size"); + colors = (uint[])data.Clone(); + } + public ColorPalette AsSystemPalette() { ColorPalette pal; @@ -88,6 +100,21 @@ namespace OpenRA.FileFormats return pal; } + public Bitmap AsBitmap() + { + var b = new Bitmap(256, 1, PixelFormat.Format32bppArgb); + var data = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), + ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); + unsafe + { + uint* c = (uint*)data.Scan0; + for (var x = 0; x < 256; x++) + *(c + x) = colors[x]; + } + b.UnlockBits(data); + return b; + } + public static Palette Load(string filename, int[] remap) { using(var s = File.OpenRead(filename)) diff --git a/OpenRA.FileFormats/Thirdparty/Random.cs b/OpenRA.FileFormats/Thirdparty/Random.cs index 8ef212f0c3..5bc9d5797a 100644 --- a/OpenRA.FileFormats/Thirdparty/Random.cs +++ b/OpenRA.FileFormats/Thirdparty/Random.cs @@ -20,6 +20,7 @@ namespace OpenRA.Thirdparty int index = 0; public int Last; + public int TotalCount = 0; public Random() : this(Environment.TickCount) { } @@ -41,13 +42,14 @@ namespace OpenRA.Thirdparty y ^= y >> 18; index = (index + 1) % 624; + TotalCount++; Last = (int)(y % int.MaxValue); return Last; } public int Next(int low, int high) { return low + Next() % (high - low); } public int Next(int high) { return Next() % high; } - public double NextDouble() { return Math.Abs(Next() / (double)0x7fffffff); } + public float NextFloat() { return Math.Abs(Next() / (float)0x7fffffff); } void Generate() { diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 3eea3d1ed0..8bd5730a10 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.FileFormats; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA @@ -73,7 +74,7 @@ namespace OpenRA AddTrait(trait.Create(init)); } - Move = Lazy.New( () => TraitOrDefault() ); + Move = Lazy.New(() => TraitOrDefault()); Size = Lazy.New(() => { @@ -81,27 +82,23 @@ namespace OpenRA if (si != null && si.Bounds != null) return new int2(si.Bounds[0], si.Bounds[1]); - // auto size from render - var firstSprite = TraitsImplementing().SelectMany(ApplyIRender).FirstOrDefault(); - if (firstSprite.Sprite == null) return int2.Zero; - return (firstSprite.Sprite.size * firstSprite.Scale).ToInt2(); + return TraitsImplementing().Select(x => x.SelectionSize(this)).FirstOrDefault(); }); - if(this.HasTrait()) + if (this.HasTrait()) { Sight = new Shroud.ActorVisibility { range = this.Trait().RevealRange, vis = Shroud.GetVisOrigins(this).ToArray() }; - } - - ApplyIRender = x => x.Render(this); - ApplyRenderModifier = (m, p) => p.ModifyRender(this, m); - Bounds = Cached.New( () => CalculateBounds(false) ); - ExtendedBounds = Cached.New( () => CalculateBounds(true) ); + ApplyIRender = (x, wr) => x.Render(this, wr); + ApplyRenderModifier = (m, p, wr) => p.ModifyRender(this, wr, m); + + Bounds = Cached.New(() => CalculateBounds(false)); + ExtendedBounds = Cached.New(() => CalculateBounds(true)); } public void Tick() @@ -109,7 +106,7 @@ namespace OpenRA Bounds.Invalidate(); ExtendedBounds.Invalidate(); - currentActivity = Util.RunActivity( this, currentActivity ); + currentActivity = Traits.Util.RunActivity( this, currentActivity ); } public void UpdateSight() @@ -125,13 +122,13 @@ namespace OpenRA OpenRA.FileFormats.Lazy Size; // note: these delegates are cached to avoid massive allocation. - Func> ApplyIRender; - Func, IRenderModifier, IEnumerable> ApplyRenderModifier; - public IEnumerable Render() + Func> ApplyIRender; + Func, IRenderModifier, WorldRenderer, IEnumerable> ApplyRenderModifier; + public IEnumerable Render(WorldRenderer wr) { var mods = TraitsImplementing(); - var sprites = TraitsImplementing().SelectMany(ApplyIRender); - return mods.Aggregate(sprites, ApplyRenderModifier); + var sprites = TraitsImplementing().SelectMany(x => ApplyIRender(x, wr)); + return mods.Aggregate(sprites, (m,p) => ApplyRenderModifier(m,p,wr)); } // When useAltitude = true, the bounding box is extended @@ -146,22 +143,14 @@ namespace OpenRA var si = Info.Traits.GetOrDefault(); if (si != null && si.Bounds != null && si.Bounds.Length > 2) { -#if true loc += new PVecInt(si.Bounds[2], si.Bounds[3]); -#else - loc.X += si.Bounds[2]; - loc.Y += si.Bounds[3]; -#endif } var move = Move.Value; if (move != null) { -#if true loc -= new PVecInt(0, move.Altitude); -#else - loc.Y -= move.Altitude; -#endif + if (useAltitude) size = new PVecInt(size.X, size.Y + move.Altitude); } @@ -257,10 +246,15 @@ namespace OpenRA { World.AddFrameEndTask(w => { + var oldOwner = Owner; + // momentarily remove from world so the ownership queries don't get confused w.Remove(this); Owner = newOwner; w.Add(this); + + foreach (var t in this.TraitsImplementing()) + t.OnOwnerChanged(this, oldOwner, newOwner); }); } } diff --git a/OpenRA.Game/Effects/DelayedAction.cs b/OpenRA.Game/Effects/DelayedAction.cs index 64603bc9bf..609af16c4a 100755 --- a/OpenRA.Game/Effects/DelayedAction.cs +++ b/OpenRA.Game/Effects/DelayedAction.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Effects @@ -25,12 +26,12 @@ namespace OpenRA.Effects this.delay = delay; } - public void Tick( World world ) + public void Tick(World world) { if (--delay <= 0) world.AddFrameEndTask(w => { w.Remove(this); a(); }); } - public IEnumerable Render() { yield break; } + public IEnumerable Render(WorldRenderer wr) { yield break; } } } diff --git a/OpenRA.Game/Effects/FlashTarget.cs b/OpenRA.Game/Effects/FlashTarget.cs index 17b8fe42fd..c8c422d791 100755 --- a/OpenRA.Game/Effects/FlashTarget.cs +++ b/OpenRA.Game/Effects/FlashTarget.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Effects @@ -32,14 +33,14 @@ namespace OpenRA.Effects world.AddFrameEndTask(w => w.Remove(this)); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (!target.IsInWorld) yield break; if (remainingTicks % 2 == 0) - foreach (var r in target.Render()) - yield return r.WithPalette("highlight"); + foreach (var r in target.Render(wr)) + yield return r.WithPalette(wr.Palette("highlight")); } } } diff --git a/OpenRA.Game/Effects/IEffect.cs b/OpenRA.Game/Effects/IEffect.cs index be2f2fb988..5bab9cfcf3 100755 --- a/OpenRA.Game/Effects/IEffect.cs +++ b/OpenRA.Game/Effects/IEffect.cs @@ -9,13 +9,14 @@ #endregion using System.Collections.Generic; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Effects { public interface IEffect { - void Tick( World world ); - IEnumerable Render(); + void Tick(World world); + IEnumerable Render(WorldRenderer r); } } diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index b4af0f25d4..8f33d9500e 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -58,7 +58,7 @@ namespace OpenRA static string ChooseReplayFilename() { - return DateTime.UtcNow.ToString("OpenRA-yyyy-MM-ddTHHmmssZ.rep"); + return DateTime.UtcNow.ToString("OpenRA-yyyy-MM-ddTHHmmssZ"); } static void JoinInner(OrderManager om) diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index e270d78d49..bb8d3fc0ed 100644 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -120,6 +120,26 @@ namespace OpenRA.GameRules public string ConnectTo = ""; } + public class KeySettings + { + public string PauseKey = "f3"; + + public string CycleBaseKey = "backspace"; + public string GotoLastEventKey = "space"; + public string SellKey = "v"; + public string PowerDownKey = "b"; + public string RepairKey = "n"; + + public string AttackMoveKey = "a"; + public string StopKey = "s"; + public string ScatterKey = "x"; + public string StanceCycleKey = "z"; + public string DeployKey = "f"; + + public string CycleTabsKey = "tab"; + } + + public class Settings { string SettingsFile; @@ -130,6 +150,7 @@ namespace OpenRA.GameRules public GraphicSettings Graphics = new GraphicSettings(); public ServerSettings Server = new ServerSettings(); public DebugSettings Debug = new DebugSettings(); + public KeySettings Keys = new KeySettings(); public Dictionary Sections; @@ -144,6 +165,7 @@ namespace OpenRA.GameRules {"Graphics", Graphics}, {"Server", Server}, {"Debug", Debug}, + {"Keys", Keys}, }; // Override fieldloader to ignore invalid entries diff --git a/OpenRA.Game/Graphics/AnimationWithOffset.cs b/OpenRA.Game/Graphics/AnimationWithOffset.cs index c29c341688..c048f5c8fd 100644 --- a/OpenRA.Game/Graphics/AnimationWithOffset.cs +++ b/OpenRA.Game/Graphics/AnimationWithOffset.cs @@ -32,7 +32,7 @@ namespace OpenRA.Graphics this.DisableFunc = d; } - public Renderable Image(Actor self, string pal) + public Renderable Image(Actor self, PaletteReference pal) { var p = self.CenterLocation; var loc = p.ToFloat2() - 0.5f * Animation.Image.size diff --git a/OpenRA.Game/Graphics/CursorProvider.cs b/OpenRA.Game/Graphics/CursorProvider.cs index a0dc94b86d..823e231c41 100644 --- a/OpenRA.Game/Graphics/CursorProvider.cs +++ b/OpenRA.Game/Graphics/CursorProvider.cs @@ -19,6 +19,7 @@ namespace OpenRA.Graphics { public static class CursorProvider { + public static Dictionary Palettes { get; private set; } static Dictionary cursors; public static void Initialize(string[] sequenceFiles) @@ -28,13 +29,14 @@ namespace OpenRA.Graphics int[] ShadowIndex = { }; if (sequences.NodesDict.ContainsKey("ShadowIndex")) - { - Array.Resize(ref ShadowIndex, ShadowIndex.Length + 1); - ShadowIndex[ShadowIndex.Length - 1] = Convert.ToInt32(sequences.NodesDict["ShadowIndex"].Value); - } + { + Array.Resize(ref ShadowIndex, ShadowIndex.Length + 1); + ShadowIndex[ShadowIndex.Length - 1] = Convert.ToInt32(sequences.NodesDict["ShadowIndex"].Value); + } + Palettes = new Dictionary(); foreach (var s in sequences.NodesDict["Palettes"].Nodes) - Game.modData.Palette.AddPalette(s.Key, new Palette(FileSystem.Open(s.Value.Value), ShadowIndex)); + Palettes.Add(s.Key, new Palette(FileSystem.Open(s.Value.Value), ShadowIndex)); foreach (var s in sequences.NodesDict["Cursors"].Nodes) LoadSequencesForCursor(s.Key, s.Value); diff --git a/OpenRA.Game/Graphics/HardwarePalette.cs b/OpenRA.Game/Graphics/HardwarePalette.cs index fcda7438e3..98f486e2cf 100644 --- a/OpenRA.Game/Graphics/HardwarePalette.cs +++ b/OpenRA.Game/Graphics/HardwarePalette.cs @@ -25,11 +25,13 @@ namespace OpenRA.Graphics ITexture texture; Dictionary palettes; Dictionary indices; + Dictionary allowsMods; public HardwarePalette() { palettes = new Dictionary(); indices = new Dictionary(); + allowsMods = new Dictionary(); texture = Game.Renderer.Device.CreateTexture(); } @@ -49,22 +51,24 @@ namespace OpenRA.Graphics return ret; } - public void AddPalette(string name, Palette p) + public void AddPalette(string name, Palette p, bool allowModifiers) { if (palettes.ContainsKey(name)) throw new InvalidOperationException("Palette {0} has already been defined".F(name)); palettes.Add(name, p); indices.Add(name, allocated++); + allowsMods.Add(name, allowModifiers); } uint[,] data = new uint[MaxPalettes, 256]; public void Update(IEnumerable paletteMods) { var copy = palettes.ToDictionary(p => p.Key, p => new Palette(p.Value)); + var modifiable = copy.Where(p => allowsMods[p.Key]).ToDictionary(p => p.Key, p => p.Value); foreach (var mod in paletteMods) - mod.AdjustPalette(copy); + mod.AdjustPalette(modifiable); foreach (var pal in copy) { diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs index 793a656725..e354698882 100644 --- a/OpenRA.Game/Graphics/Renderer.cs +++ b/OpenRA.Game/Graphics/Renderer.cs @@ -50,20 +50,20 @@ namespace OpenRA.Graphics TempBufferCount = Game.Settings.Graphics.NumTempBuffers; SheetSize = Game.Settings.Graphics.SheetSize; - WorldSpriteShader = device.CreateShader("world-shp"); - WorldLineShader = device.CreateShader("world-line"); - LineShader = device.CreateShader("chrome-line"); - RgbaSpriteShader = device.CreateShader("chrome-rgba"); - SpriteShader = device.CreateShader("chrome-shp"); + WorldSpriteShader = device.CreateShader("shp"); + WorldLineShader = device.CreateShader("line"); + LineShader = device.CreateShader("line"); + RgbaSpriteShader = device.CreateShader("rgba"); + SpriteShader = device.CreateShader("shp"); - WorldSpriteRenderer = new SpriteRenderer( this, WorldSpriteShader ); + WorldSpriteRenderer = new SpriteRenderer(this, WorldSpriteShader); WorldLineRenderer = new LineRenderer(this, WorldLineShader); LineRenderer = new LineRenderer(this, LineShader); - RgbaSpriteRenderer = new SpriteRenderer( this, RgbaSpriteShader ); - SpriteRenderer = new SpriteRenderer( this, SpriteShader ); + RgbaSpriteRenderer = new SpriteRenderer(this, RgbaSpriteShader); + SpriteRenderer = new SpriteRenderer(this, SpriteShader); - for( int i = 0 ; i < TempBufferCount ; i++ ) - tempBuffers.Enqueue( device.CreateVertexBuffer( TempBufferSize ) ); + for (int i = 0; i < TempBufferCount; i++) + tempBuffers.Enqueue(device.CreateVertexBuffer(TempBufferSize)); } public void InitializeFonts(Manifest m) @@ -80,22 +80,22 @@ namespace OpenRA.Graphics float2 r2 = new float2(-1, 1); var zr1 = zoom*r1; - SetShaderParams( WorldSpriteShader, zr1, r2, scroll ); - SetShaderParams( WorldLineShader, zr1, r2, scroll ); - SetShaderParams( LineShader, r1, r2, scroll ); - SetShaderParams( RgbaSpriteShader, r1, r2, scroll ); - SetShaderParams( SpriteShader, r1, r2, scroll ); + SetShaderParams(WorldSpriteShader, zr1, r2, scroll); + SetShaderParams(WorldLineShader, zr1, r2, scroll); + SetShaderParams(LineShader, r1, r2, float2.Zero); + SetShaderParams(RgbaSpriteShader, r1, r2, float2.Zero); + SetShaderParams(SpriteShader, r1, r2, float2.Zero); } - void SetShaderParams( IShader s, float2 r1, float2 r2, float2 scroll ) + void SetShaderParams(IShader s, float2 r1, float2 r2, float2 scroll) { - s.SetValue( "Palette", PaletteTexture ); - s.SetValue( "Scroll", (int) scroll.X, (int) scroll.Y ); - s.SetValue( "r1", r1.X, r1.Y ); - s.SetValue( "r2", r2.X, r2.Y ); + s.SetValue("Palette", PaletteTexture); + s.SetValue("Scroll", (int)scroll.X, (int)scroll.Y); + s.SetValue("r1", r1.X, r1.Y); + s.SetValue("r2", r2.X, r2.Y); } - public void EndFrame( IInputHandler inputHandler ) + public void EndFrame(IInputHandler inputHandler) { Flush(); device.PumpInput(inputHandler); @@ -129,17 +129,17 @@ namespace OpenRA.Graphics // which makes the window non-interactive in Windowed/Pseudofullscreen mode. static Screen FixOSX() { return Screen.PrimaryScreen; } - internal static void Initialize( WindowMode windowMode ) + internal static void Initialize(WindowMode windowMode) { if (Platform.CurrentPlatform == PlatformType.OSX) FixOSX(); - var resolution = GetResolution( windowMode ); + var resolution = GetResolution(windowMode); - string renderer = Game.Settings.Server.Dedicated?"Null":Game.Settings.Graphics.Renderer; - var rendererPath = Path.GetFullPath( "OpenRA.Renderer.{0}.dll".F(renderer) ); + string renderer = Game.Settings.Server.Dedicated ? "Null" : Game.Settings.Graphics.Renderer; + var rendererPath = Path.GetFullPath("OpenRA.Renderer.{0}.dll".F(renderer)); - device = CreateDevice( Assembly.LoadFile( rendererPath ), resolution.Width, resolution.Height, windowMode ); + device = CreateDevice(Assembly.LoadFile(rendererPath), resolution.Width, resolution.Height, windowMode); } static Size GetResolution(WindowMode windowmode) @@ -150,12 +150,12 @@ namespace OpenRA.Graphics return new Size(size.X, size.Y); } - static IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, WindowMode window ) + static IGraphicsDevice CreateDevice(Assembly rendererDll, int width, int height, WindowMode window) { - foreach( RendererAttribute r in rendererDll.GetCustomAttributes( typeof( RendererAttribute ), false ) ) + foreach (RendererAttribute r in rendererDll.GetCustomAttributes(typeof(RendererAttribute), false)) { - var factory = (IDeviceFactory) r.Type.GetConstructor( Type.EmptyTypes ).Invoke( null ); - return factory.Create( new Size( width, height ), window ); + var factory = (IDeviceFactory)r.Type.GetConstructor(Type.EmptyTypes).Invoke(null); + return factory.Create(new Size(width, height), window); } throw new InvalidOperationException("Renderer DLL is missing RendererAttribute to tell us what type to use!"); @@ -164,7 +164,7 @@ namespace OpenRA.Graphics internal IVertexBuffer GetTempVertexBuffer() { var ret = tempBuffers.Dequeue(); - tempBuffers.Enqueue( ret ); + tempBuffers.Enqueue(ret); return ret; } @@ -176,8 +176,8 @@ namespace OpenRA.Graphics get { return currentBatchRenderer; } set { - if( currentBatchRenderer == value ) return; - if( currentBatchRenderer != null ) + if (currentBatchRenderer == value) return; + if (currentBatchRenderer != null) currentBatchRenderer.Flush(); currentBatchRenderer = value; } @@ -186,7 +186,7 @@ namespace OpenRA.Graphics public void EnableScissor(int left, int top, int width, int height) { Flush(); - Device.EnableScissor( left, top, width, height ); + Device.EnableScissor(left, top, width, height); } public void DisableScissor() diff --git a/OpenRA.Game/Graphics/Sequence.cs b/OpenRA.Game/Graphics/Sequence.cs index d8a0bfeceb..c4ce07357c 100644 --- a/OpenRA.Game/Graphics/Sequence.cs +++ b/OpenRA.Game/Graphics/Sequence.cs @@ -18,12 +18,13 @@ namespace OpenRA.Graphics public class Sequence { readonly Sprite[] sprites; - readonly int start, length, facings, tick; + readonly int start, length, stride, facings, tick; public readonly string Name; public int Start { get { return start; } } public int End { get { return start + length; } } public int Length { get { return length; } } + public int Stride { get { return stride; } } public int Facings { get { return facings; } } public int Tick { get { return tick; } } @@ -43,6 +44,10 @@ namespace OpenRA.Graphics else length = int.Parse(d["Length"].Value); + if (d.ContainsKey("Stride")) + stride = int.Parse(d["Stride"].Value); + else + stride = length; if(d.ContainsKey("Facings")) facings = int.Parse(d["Facings"].Value); @@ -54,10 +59,15 @@ namespace OpenRA.Graphics else tick = 40; - if (start < 0 || start + facings * length > sprites.Length) + if (length > stride) + throw new InvalidOperationException( + "{0}: Sequence {1}.{2}: Length must be <= stride" + .F(info.Nodes[0].Location, unit, name)); + + if (start < 0 || start + facings * stride > sprites.Length) throw new InvalidOperationException( "{6}: Sequence {0}.{1} uses frames [{2}..{3}] of SHP `{4}`, but only 0..{5} actually exist" - .F(unit, name, start, start + facings * length - 1, srcOverride ?? unit, sprites.Length - 1, + .F(unit, name, start, start + facings * stride - 1, srcOverride ?? unit, sprites.Length - 1, info.Nodes[0].Location)); } @@ -69,7 +79,7 @@ namespace OpenRA.Graphics public Sprite GetSprite(int frame, int facing) { var f = Traits.Util.QuantizeFacing( facing, facings ); - return sprites[ (f * length) + ( frame % length ) + start ]; + return sprites[ (f * stride) + ( frame % length ) + start ]; } } } diff --git a/OpenRA.Game/Graphics/ShroudRenderer.cs b/OpenRA.Game/Graphics/ShroudRenderer.cs index 4229bf9da9..4d467b67dd 100644 --- a/OpenRA.Game/Graphics/ShroudRenderer.cs +++ b/OpenRA.Game/Graphics/ShroudRenderer.cs @@ -105,8 +105,17 @@ namespace OpenRA.Graphics return shadowBits[SpecialShroudTiles[u ^ uSides][v]]; } - internal void Draw( WorldRenderer wr ) + bool initializePalettes = true; + PaletteReference fogPalette, shroudPalette; + internal void Draw(WorldRenderer wr) { + if (initializePalettes) + { + fogPalette = wr.Palette("fog"); + shroudPalette = wr.Palette("shroud"); + initializePalettes = false; + } + if (shroud != null && shroud.dirty) { shroud.dirty = false; @@ -120,14 +129,12 @@ namespace OpenRA.Graphics } var clipRect = Game.viewport.WorldBounds(wr.world); - DrawShroud( wr, clipRect, fogSprites, "fog" ); - DrawShroud( wr, clipRect, sprites, "shroud" ); + DrawShroud(wr, clipRect, fogSprites, fogPalette); + DrawShroud(wr, clipRect, sprites, shroudPalette); } - void DrawShroud( WorldRenderer wr, Rectangle clip, Sprite[,] s, string pal ) + void DrawShroud(WorldRenderer wr, Rectangle clip, Sprite[,] s, PaletteReference pal) { - var shroudPalette = wr.GetPaletteIndex(pal); - for (var j = clip.Top; j < clip.Bottom; j++) { var starti = clip.Left; @@ -142,14 +149,14 @@ namespace OpenRA.Graphics { s[starti, j].DrawAt( Game.CellSize * new float2(starti, j), - shroudPalette, + pal.Index, new float2(Game.CellSize * (i - starti), Game.CellSize)); starti = i + 1; } s[i, j].DrawAt( Game.CellSize * new float2(i, j), - shroudPalette); + pal.Index); starti = i + 1; last = s[i, j]; } @@ -157,7 +164,7 @@ namespace OpenRA.Graphics if (starti < clip.Right) s[starti, j].DrawAt( Game.CellSize * new float2(starti, j), - shroudPalette, + pal.Index, new float2(Game.CellSize * (clip.Right - starti), Game.CellSize)); } } diff --git a/OpenRA.Game/Graphics/SpriteRenderer.cs b/OpenRA.Game/Graphics/SpriteRenderer.cs index 957eb6f701..b1bba04e3a 100644 --- a/OpenRA.Game/Graphics/SpriteRenderer.cs +++ b/OpenRA.Game/Graphics/SpriteRenderer.cs @@ -49,12 +49,12 @@ namespace OpenRA.Graphics public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette) { - DrawSprite(s, location, wr.GetPaletteIndex(palette), s.size); + DrawSprite(s, location, wr.Palette(palette).Index, s.size); } public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette, float2 size) { - DrawSprite(s, location, wr.GetPaletteIndex(palette), size); + DrawSprite(s, location, wr.Palette(palette).Index, size); } public void DrawSprite(Sprite s, float2 location, int paletteIndex, float2 size) diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index 573d480cd1..317820217a 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -39,7 +39,7 @@ namespace OpenRA.Graphics int nv = 0; - var terrainPalette = Game.modData.Palette.GetPaletteIndex("terrain"); + var terrainPalette = wr.Palette("terrain").Index; for( int j = map.Bounds.Top; j < map.Bounds.Bottom; j++ ) for( int i = map.Bounds.Left; i < map.Bounds.Right; i++ ) diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index f5881d2e1e..4a15d081ac 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -133,7 +133,7 @@ namespace OpenRA.Graphics renderer.SpriteRenderer.DrawSprite(cursorSprite, Viewport.LastMousePos - cursorSequence.Hotspot, - Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette), + wr.Palette(cursorSequence.Palette).Index, cursorSprite.size); } diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index ba662975a2..c590105a92 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -17,27 +17,56 @@ using OpenRA.Traits; namespace OpenRA.Graphics { + public class PaletteReference + { + public readonly string Name; + public readonly int Index; + public readonly Palette Palette; + public PaletteReference(string name, int index, Palette palette) + { + Name = name; + Index = index; + Palette = palette; + } + } + public class WorldRenderer { public readonly World world; internal readonly TerrainRenderer terrainRenderer; internal readonly ShroudRenderer shroudRenderer; internal readonly HardwarePalette palette; + internal Cache palettes; internal WorldRenderer(World world) { this.world = world; - this.palette = Game.modData.Palette; - foreach( var pal in world.traitDict.ActorsWithTraitMultiple( world ) ) + palette = new HardwarePalette(); + foreach (var p in CursorProvider.Palettes) + palette.AddPalette(p.Key, p.Value, false); + + palettes = new Cache(CreatePaletteReference); + foreach (var pal in world.traitDict.ActorsWithTraitMultiple(world)) pal.Trait.InitPalette( this ); + // Generate initial palette texture + palette.Update(new IPaletteModifier[] {}); + terrainRenderer = new TerrainRenderer(world, this); shroudRenderer = new ShroudRenderer(world); } - public int GetPaletteIndex(string name) { return palette.GetPaletteIndex(name); } - public Palette GetPalette(string name) { return palette.GetPalette(name); } - public void AddPalette(string name, Palette pal) { palette.AddPalette(name, pal); } + PaletteReference CreatePaletteReference(string name) + { + var pal = palette.GetPalette(name); + if (pal == null) + throw new InvalidOperationException("Palette `{0}` does not exist".F(name)); + + return new PaletteReference(name, palette.GetPaletteIndex(name), pal); + } + + public PaletteReference Palette(string name) { return palettes[name]; } + public void AddPalette(string name, Palette pal, bool allowModifiers) { palette.AddPalette(name, pal, allowModifiers); } class SpriteComparer : IComparer { @@ -57,10 +86,10 @@ namespace OpenRA.Graphics bounds.BottomRightAsCPos().ToPPos() ); - var renderables = actors.SelectMany(a => a.Render()) + var renderables = actors.SelectMany(a => a.Render(this)) .OrderBy(r => r, comparer); - var effects = world.Effects.SelectMany(e => e.Render()); + var effects = world.Effects.SelectMany(e => e.Render(this)); return renderables.Concat(effects); } @@ -77,8 +106,8 @@ namespace OpenRA.Graphics terrainRenderer.Draw(this, Game.viewport); foreach (var a in world.traitDict.ActorsWithTraitMultiple(world)) - foreach (var r in a.Trait.RenderAsTerrain(a.Actor)) - r.Sprite.DrawAt(r.Pos, this.GetPaletteIndex(r.Palette), r.Scale); + foreach (var r in a.Trait.RenderAsTerrain(this, a.Actor)) + r.Sprite.DrawAt(r.Pos, r.Palette.Index, r.Scale); foreach (var a in world.Selection.Actors) if (!a.Destroyed) @@ -91,7 +120,7 @@ namespace OpenRA.Graphics world.OrderGenerator.RenderBeforeWorld(this, world); foreach (var image in SpritesToRender()) - image.Sprite.DrawAt(image.Pos, this.GetPaletteIndex(image.Palette), image.Scale); + image.Sprite.DrawAt(image.Pos, image.Palette.Index, image.Scale); // added for contrails foreach (var a in world.ActorsWithTrait()) diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index c8770da6b5..c614d4604b 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -28,7 +28,6 @@ namespace OpenRA public ILoadScreen LoadScreen = null; public SheetBuilder SheetBuilder; public SpriteLoader SpriteLoader; - public HardwarePalette Palette { get; private set; } public ModData( params string[] mods ) { @@ -51,13 +50,11 @@ namespace OpenRA AvailableMaps = FindMaps(Manifest.Mods); - Palette = new HardwarePalette(); ChromeMetrics.Initialize(Manifest.ChromeMetrics); ChromeProvider.Initialize(Manifest.Chrome); SheetBuilder = new SheetBuilder(TextureChannel.Red); SpriteLoader = new SpriteLoader(new string[] { ".shp" }, SheetBuilder); CursorProvider.Initialize(Manifest.Cursors); - Palette.Update(new IPaletteModifier[] { }); } public Map PrepareMap(string uid) diff --git a/OpenRA.Game/Network/ReplayRecorderConnection.cs b/OpenRA.Game/Network/ReplayRecorderConnection.cs index c7aba98b6b..249574ac1c 100644 --- a/OpenRA.Game/Network/ReplayRecorderConnection.cs +++ b/OpenRA.Game/Network/ReplayRecorderConnection.cs @@ -34,12 +34,23 @@ namespace OpenRA.Network void StartSavingReplay(byte[] initialContent) { var filename = chooseFilename(); - var replayPath = Path.Combine(Platform.SupportDir, "Replays"); + var replaysDirectory = Path.Combine(Platform.SupportDir, "Replays"); - if (!Directory.Exists(replayPath)) - Directory.CreateDirectory(replayPath); + if (!Directory.Exists(replaysDirectory)) + Directory.CreateDirectory(replaysDirectory); - var file = File.Create(Path.Combine(replayPath, filename)); + string fullFilename; + var id = -1; + do + { + fullFilename = Path.Combine(replaysDirectory, id < 0 + ? "{0}.rep".F(filename) + : "{0}-{1}.rep".F(filename, id)); + id++; + } + while (File.Exists(fullFilename)); + + var file = File.Create(fullFilename); file.Write(initialContent); this.writer = new BinaryWriter(file); } diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index 30f7ae16d5..7e63d9ba4a 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -42,7 +42,9 @@ namespace OpenRA.Network public class Client { public int Index; - public ColorRamp ColorRamp; + public ColorRamp PreferredColorRamp; // Color that the client normally uses from settings.yaml. + public ColorRamp ColorRamp; // Actual color that the client is using. + // Usually the same as PreferredColorRamp but can be different on maps with locked colors. public string Country; public int SpawnPoint; public string Name; @@ -79,6 +81,7 @@ namespace OpenRA.Network public bool AllowCheats = false; public bool Dedicated; public string Difficulty; + public bool Crates = true; } public Session(string[] mods) diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs index f060b8ccf6..a5d7f966ad 100755 --- a/OpenRA.Game/Network/SyncReport.cs +++ b/OpenRA.Game/Network/SyncReport.cs @@ -36,6 +36,7 @@ namespace OpenRA.Network { report.Frame = orderManager.NetFrameNumber; report.SyncedRandom = orderManager.world.SharedRandom.Last; + report.TotalCount = orderManager.world.SharedRandom.TotalCount; report.Traits.Clear(); foreach (var a in orderManager.world.ActorsWithTrait()) { @@ -58,7 +59,7 @@ namespace OpenRA.Network if (r.Frame == frame) { Log.Write("sync", "Sync for net frame {0} -------------", r.Frame); - Log.Write("sync", "SharedRandom: "+r.SyncedRandom); + Log.Write("sync", "SharedRandom: {0} (#{1})", r.SyncedRandom, r.TotalCount); Log.Write("sync", "Synced Traits:"); foreach (var a in r.Traits) Log.Write("sync", "\t {0} {1} {2} {3} ({4})".F( @@ -77,6 +78,7 @@ namespace OpenRA.Network { public int Frame; public int SyncedRandom; + public int TotalCount; public List Traits = new List(); } diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 8f0c4a6bf5..cdd06bb41e 100755 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -119,6 +119,7 @@ namespace OpenRA.Network var info = new Session.Client() { Name = Game.Settings.Player.Name, + PreferredColorRamp = Game.Settings.Player.ColorRamp, ColorRamp = Game.Settings.Player.ColorRamp, Country = "random", SpawnPoint = 0, diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 54eef011f2..478b12085a 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -374,6 +374,8 @@ namespace OpenRA.Server return; if (pr.LockColor) c.ColorRamp = pr.ColorRamp; + else + c.ColorRamp = c.PreferredColorRamp; if (pr.LockRace) c.Country = pr.Race; if (pr.LockSpawn) diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index 446fd6b3cf..85bdbc79ad 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -76,8 +76,7 @@ namespace OpenRA.Traits case "DevShroud": { DisableShroud ^= true; - if (self.World.LocalPlayer == self.Owner) - self.World.RenderedShroud.Disabled = DisableShroud; + self.Owner.Shroud.Disabled = DisableShroud; break; } case "DevPathDebug": @@ -87,8 +86,7 @@ namespace OpenRA.Traits } case "DevGiveExploration": { - if (self.World.LocalPlayer == self.Owner) - self.World.LocalPlayer.Shroud.ExploreAll(self.World); + self.Owner.Shroud.ExploreAll(self.World); break; } case "DevUnlimitedPower": diff --git a/OpenRA.Game/Traits/Render/RenderSimple.cs b/OpenRA.Game/Traits/Render/RenderSimple.cs index 1b2d4ff6c7..34ec41c879 100755 --- a/OpenRA.Game/Traits/Render/RenderSimple.cs +++ b/OpenRA.Game/Traits/Render/RenderSimple.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenRA.Graphics; namespace OpenRA.Traits @@ -23,16 +24,16 @@ namespace OpenRA.Traits public virtual object Create(ActorInitializer init) { return new RenderSimple(init.self); } - public virtual IEnumerable RenderPreview(ActorInfo building, Player owner) + public virtual IEnumerable RenderPreview(ActorInfo building, PaletteReference pr) { var anim = new Animation(RenderSimple.GetImage(building), () => 0); anim.PlayRepeating("idle"); - yield return new Renderable(anim.Image, 0.5f * anim.Image.size * (1 - Scale), - Palette ?? (owner != null ? PlayerPalette + owner.InternalName : null), 0, Scale); + + yield return new Renderable(anim.Image, 0.5f * anim.Image.size * (1 - Scale), pr, 0, Scale); } } - public class RenderSimple : IRender, ITick + public class RenderSimple : IRender, IAutoSelectionSize, ITick, INotifyOwnerChanged { public Dictionary anims = new Dictionary(); @@ -55,7 +56,6 @@ namespace OpenRA.Traits return Info.Image ?? actor.Name; } - string cachedImage = null; public string GetImage(Actor self) { if (cachedImage != null) @@ -65,6 +65,9 @@ namespace OpenRA.Traits } RenderSimpleInfo Info; + string cachedImage = null; + bool initializePalette = true; + protected PaletteReference palette; public RenderSimple(Actor self, Func baseFacing) { @@ -77,20 +80,40 @@ namespace OpenRA.Traits anim.PlayRepeating("idle"); } - public string Palette(Player p) { return Info.Palette ?? Info.PlayerPalette + p.InternalName; } - - public virtual IEnumerable Render(Actor self) + protected virtual string PaletteName(Actor self) { + return Info.Palette ?? Info.PlayerPalette + self.Owner.InternalName; + } + + protected void UpdatePalette() { initializePalette = true; } + public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { UpdatePalette(); } + + public virtual IEnumerable Render(Actor self, WorldRenderer wr) + { + if (initializePalette) + { + palette = wr.Palette(PaletteName(self)); + initializePalette = false; + } + foreach (var a in anims.Values) if (a.DisableFunc == null || !a.DisableFunc()) { - Renderable ret = a.Image(self, Palette(self.Owner)); + Renderable ret = a.Image(self, palette); if (Info.Scale != 1f) ret = ret.WithScale(Info.Scale).WithPos(ret.Pos + 0.5f * ret.Sprite.size * (1 - Info.Scale)); yield return ret; } } + public int2 SelectionSize(Actor self) + { + return anims.Values.Where(b => (b.DisableFunc == null || !b.DisableFunc()) + && b.Animation.CurrentSequence != null) + .Select(a => (a.Animation.Image.size*Info.Scale).ToInt2()) + .FirstOrDefault(); + } + public virtual void Tick(Actor self) { foreach (var a in anims.Values) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 2380f474b9..4182ebf6a4 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -34,7 +34,8 @@ namespace OpenRA.Traits } public interface ITick { void Tick(Actor self); } - public interface IRender { IEnumerable Render(Actor self); } + public interface IRender { IEnumerable Render(Actor self, WorldRenderer wr); } + public interface IAutoSelectionSize { int2 SelectionSize(Actor self); } public interface IIssueOrder { @@ -62,6 +63,7 @@ namespace OpenRA.Traits public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); } public interface INotifyBuildComplete { void BuildingComplete(Actor self); } public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); } + public interface INotifyOwnerChanged { void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner); } public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } public interface INotifyOtherCaptured { void OnActorCaptured(Actor self, Actor captured, Actor captor, Player oldOwner, Player newOwner); } public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); } @@ -113,7 +115,7 @@ namespace OpenRA.Traits } public interface INotifyAttack { void Attacking(Actor self, Target target); } - public interface IRenderModifier { IEnumerable ModifyRender(Actor self, IEnumerable r); } + public interface IRenderModifier { IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r); } public interface IDamageModifier { float GetDamageModifier(Actor attacker, WarheadInfo warhead); } public interface ISpeedModifier { decimal GetSpeedModifier(); } public interface IFirepowerModifier { float GetFirepowerModifier(); } @@ -154,12 +156,12 @@ namespace OpenRA.Traits { public readonly Sprite Sprite; public readonly float2 Pos; - public readonly string Palette; + public readonly PaletteReference Palette; public readonly int Z; public readonly int ZOffset; public float Scale; - public Renderable(Sprite sprite, float2 pos, string palette, int z, int zOffset, float scale) + public Renderable(Sprite sprite, float2 pos, PaletteReference palette, int z, int zOffset, float scale) { Sprite = sprite; Pos = pos; @@ -169,14 +171,14 @@ namespace OpenRA.Traits Scale = scale; /* default */ } - public Renderable(Sprite sprite, float2 pos, string palette, int z) + public Renderable(Sprite sprite, float2 pos, PaletteReference palette, int z) : this(sprite, pos, palette, z, 0, 1f) { } - public Renderable(Sprite sprite, float2 pos, string palette, int z, float scale) + public Renderable(Sprite sprite, float2 pos, PaletteReference palette, int z, float scale) : this(sprite, pos, palette, z, 0, scale) { } public Renderable WithScale(float newScale) { return new Renderable(Sprite, Pos, Palette, Z, ZOffset, newScale); } - public Renderable WithPalette(string newPalette) { return new Renderable(Sprite, Pos, newPalette, Z, ZOffset, Scale); } + public Renderable WithPalette(PaletteReference newPalette) { return new Renderable(Sprite, Pos, newPalette, Z, ZOffset, Scale); } public Renderable WithZOffset(int newOffset) { return new Renderable(Sprite, Pos, Palette, Z, newOffset, Scale); } public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, Z, ZOffset, Scale); } } @@ -208,7 +210,7 @@ namespace OpenRA.Traits public interface IPostRenderSelection { void RenderAfterWorld(WorldRenderer wr); } public interface IPreRenderSelection { void RenderBeforeWorld(WorldRenderer wr, Actor self); } - public interface IRenderAsTerrain { IEnumerable RenderAsTerrain(Actor self); } + public interface IRenderAsTerrain { IEnumerable RenderAsTerrain(WorldRenderer wr, Actor self); } public interface ITargetable { diff --git a/OpenRA.Game/Traits/World/PlayerColorPalette.cs b/OpenRA.Game/Traits/World/PlayerColorPalette.cs index bb3547aaea..0b35c05ddc 100644 --- a/OpenRA.Game/Traits/World/PlayerColorPalette.cs +++ b/OpenRA.Game/Traits/World/PlayerColorPalette.cs @@ -18,6 +18,7 @@ namespace OpenRA.Traits public readonly string BasePalette = null; public readonly string BaseName = "player"; public readonly int[] RemapIndex = {}; + public readonly bool AllowModifiers = true; public object Create( ActorInitializer init ) { return new PlayerColorPalette( init.self.Owner, this ); } } @@ -36,9 +37,9 @@ namespace OpenRA.Traits public void InitPalette( WorldRenderer wr ) { var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName ); - var newpal = new Palette(wr.GetPalette(info.BasePalette), + var newpal = new Palette(wr.Palette(info.BasePalette).Palette, new PlayerColorRemap(info.RemapIndex, owner.ColorRamp)); - wr.AddPalette(paletteName, newpal); + wr.AddPalette(paletteName, newpal, info.AllowModifiers); } } } diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index 5c1c35ffcf..a9ab4f2bea 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -33,7 +33,7 @@ namespace OpenRA.Traits { hasSetupPalettes = true; foreach (var rt in world.WorldActor.TraitsImplementing()) - rt.info.PaletteIndex = wr.GetPaletteIndex(rt.info.Palette); + rt.info.PaletteRef = wr.Palette(rt.info.Palette); } var clip = Game.viewport.WorldBounds(world); @@ -47,7 +47,7 @@ namespace OpenRA.Traits if (c.image != null) c.image[c.density].DrawAt( new CPos(x, y).ToPPos().ToFloat2(), - c.type.info.PaletteIndex); + c.type.info.PaletteRef.Index); } } diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index c181fdcbcf..62167b1eda 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -26,7 +26,7 @@ namespace OpenRA.Traits public readonly bool AllowUnderActors = false; public Sprite[][] Sprites; - public int PaletteIndex; + public PaletteReference PaletteRef; public PipType PipColor = PipType.Yellow; diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 751f80c8fb..6392caef4c 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -137,6 +137,9 @@ namespace OpenRA.Traits if (a.Owner.World.LocalPlayer == null || a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally) return; + if (v == null) + return; + foreach (var p in v.vis) foreach (var q in FindVisibleTiles(a.World, p, range)) foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y]; diff --git a/OpenRA.Game/Widgets/LineGraphWidget.cs b/OpenRA.Game/Widgets/LineGraphWidget.cs index 91846d240f..37e5c94192 100644 --- a/OpenRA.Game/Widgets/LineGraphWidget.cs +++ b/OpenRA.Game/Widgets/LineGraphWidget.cs @@ -101,7 +101,7 @@ namespace OpenRA.Widgets var xAxisSize = GetXAxisSize(); var yAxisSize = GetYAxisSize(); - var maxValue = GetSeries().Select(p => p.Points).SelectMany(d => d).Max(); + var maxValue = GetSeries().Select(p => p.Points).SelectMany(d => d).Concat(new[] { 0f }).Max(); var scale = 200 / Math.Max(5000, (float)Math.Ceiling(maxValue / 1000) * 1000); var xStep = width / xAxisSize; diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index ec5ce9559c..3fb087a324 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -127,7 +127,7 @@ namespace OpenRA public static float Gauss1D(this Thirdparty.Random r, int samples) { - return Exts.MakeArray(samples, _ => (float)r.NextDouble() * 2 - 1f) + return Exts.MakeArray(samples, _ => r.NextFloat() * 2 - 1f) .Sum() / samples; } diff --git a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs index df198b1430..a351b80128 100644 --- a/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs +++ b/OpenRA.Mods.Cnc/CncMenuPaletteEffect.cs @@ -61,8 +61,6 @@ namespace OpenRA.Mods.Cnc } } - static Set excludePalettes = new Set("cursor", "chrome", "colorpicker", "shroud", "fog"); - public void AdjustPalette(Dictionary palettes) { if (to == EffectType.None && remainingFrames == 0) @@ -70,9 +68,6 @@ namespace OpenRA.Mods.Cnc foreach (var pal in palettes) { - if (excludePalettes.Contains(pal.Key)) - continue; - for (var x = 0; x < 256; x++) { var orig = pal.Value.GetColor(x); diff --git a/OpenRA.Mods.Cnc/Effects/IonCannon.cs b/OpenRA.Mods.Cnc/Effects/IonCannon.cs index 9d7543d9b9..df9ae17f00 100644 --- a/OpenRA.Mods.Cnc/Effects/IonCannon.cs +++ b/OpenRA.Mods.Cnc/Effects/IonCannon.cs @@ -32,11 +32,11 @@ namespace OpenRA.Mods.Cnc.Effects public void Tick(World world) { anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { yield return new Renderable(anim.Image, target.CenterLocation.ToFloat2() - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize), - "effect", (int)target.CenterLocation.Y); + wr.Palette("effect"), (int)target.CenterLocation.Y); } void Finish( World world ) diff --git a/OpenRA.Mods.Cnc/RenderCargo.cs b/OpenRA.Mods.Cnc/RenderCargo.cs index 9e5101f41b..86b96d7e0b 100644 --- a/OpenRA.Mods.Cnc/RenderCargo.cs +++ b/OpenRA.Mods.Cnc/RenderCargo.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Mods.RA; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.Cnc @@ -39,7 +40,7 @@ namespace OpenRA.Mods.Cnc Info = info; } - public IEnumerable ModifyRender(Actor self, IEnumerable r) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { foreach (var c in cargo.Passengers) { @@ -55,7 +56,7 @@ namespace OpenRA.Mods.Cnc Info.PassengerTypes.Contains(p.Trait().info.CargoType)) : cargo.Passengers; - return r.Concat(visiblePassengers.SelectMany(a => a.Render()) + return r.Concat(visiblePassengers.SelectMany(a => a.Render(wr)) .Select(a => a.WithPos(a.Pos - new float2(0, Info.RelativeAltitude)) .WithZOffset(a.ZOffset + Info.RelativeAltitude))); } diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs index b83e0216d4..7d2776a00d 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs @@ -10,6 +10,7 @@ using System; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; using OpenRA.Widgets; @@ -20,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Widget menu; [ObjectCreator.UseCtor] - public CncIngameMenuLogic(Widget widget, World world, Action onExit) + public CncIngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer) { var resumeDisabled = false; menu = widget.Get("INGAME_MENU"); @@ -72,6 +73,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs() { { "world", world }, + { "worldRenderer", worldRenderer }, { "onExit", () => hideButtons = false }, }); }; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs index dabf7b3cdc..64d2152b7c 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs @@ -85,9 +85,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic settingsMenu.Get("SETTINGS_BUTTON").OnClick = () => { Menu = MenuType.None; - Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs() + Game.OpenWindow("SETTINGS_PANEL", new WidgetArgs() { - { "world", world }, { "onExit", () => Menu = MenuType.Settings }, }); }; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs index c8641f2b58..8d8fb13bc7 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs @@ -6,6 +6,7 @@ * as published by the Free Software Foundation. For more information, * see COPYING. */ + #endregion using System; @@ -17,6 +18,7 @@ using OpenRA.GameRules; using OpenRA.Mods.RA; using OpenRA.Mods.RA.Widgets.Logic; using OpenRA.Widgets; +using OpenRA.Mods.RA.Widgets; namespace OpenRA.Mods.Cnc.Widgets.Logic { @@ -25,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic enum PanelType { General, Input } PanelType Settings = PanelType.General; - ColorPickerPaletteModifier playerPalettePreview; + ColorPreviewManagerWidget colorPreview; World world; [ObjectCreator.UseCtor] @@ -52,8 +54,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var nameTextfield = generalPane.Get("NAME_TEXTFIELD"); nameTextfield.Text = playerSettings.Name; - playerPalettePreview = world.WorldActor.Trait(); - playerPalettePreview.Ramp = playerSettings.ColorRamp; + colorPreview = panel.Get("COLOR_MANAGER"); + colorPreview.Ramp = playerSettings.ColorRamp; var colorDropdown = generalPane.Get("COLOR"); colorDropdown.OnMouseDown = _ => ShowColorPicker(colorDropdown, playerSettings); @@ -153,8 +155,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic bool ShowColorPicker(DropDownButtonWidget color, PlayerSettings s) { - Action onSelect = c => { s.ColorRamp = c; color.RemovePanel(); }; - Action onChange = c => { playerPalettePreview.Ramp = c; }; + Action onSelect = c => {s.ColorRamp = c; color.RemovePanel();}; + Action onChange = c => {colorPreview.Ramp = c;}; var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs() { diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs index 95f31484ba..c9459eba05 100755 --- a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs @@ -266,7 +266,7 @@ namespace OpenRA.Mods.Cnc.Widgets public override bool HandleKeyPress(KeyInput e) { if (e.Event != KeyInputEvent.Down) return false; - if (e.KeyName == "tab") + if (e.KeyName == Game.Settings.Keys.CycleTabsKey) { Sound.PlayNotification(null, "Sounds", "ClickSound", null); SelectNextTab(e.Modifiers.HasModifier(Modifiers.Shift)); diff --git a/OpenRA.Mods.RA/Air/EjectOnDeath.cs b/OpenRA.Mods.RA/Air/EjectOnDeath.cs index 20463555c9..d1ed8c28da 100644 --- a/OpenRA.Mods.RA/Air/EjectOnDeath.cs +++ b/OpenRA.Mods.RA/Air/EjectOnDeath.cs @@ -35,10 +35,8 @@ namespace OpenRA.Mods.RA if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10 && self.Owner.WinState != WinState.Lost) { - self.World.AddFrameEndTask(w => w.Add( - new Parachute(pilot.Owner, - Util.CenterOfCell(self.CenterLocation.ToCPos()), - aircraft.Altitude, pilot))); + self.World.AddFrameEndTask(w => w.Add(new Parachute(pilot, + Util.CenterOfCell(self.CenterLocation.ToCPos()), aircraft.Altitude))); Sound.Play(info.ChuteSound, self.CenterLocation); } diff --git a/OpenRA.Mods.RA/Air/HeliAttack.cs b/OpenRA.Mods.RA/Air/HeliAttack.cs index 34c446d6fb..2bad762b79 100755 --- a/OpenRA.Mods.RA/Air/HeliAttack.cs +++ b/OpenRA.Mods.RA/Air/HeliAttack.cs @@ -38,13 +38,12 @@ namespace OpenRA.Mods.RA.Air } var attack = self.Trait(); - var range = attack.GetMaximumRange() * 0.625f; var dist = target.CenterLocation - self.CenterLocation; var desiredFacing = Util.GetFacing(dist, aircraft.Facing); aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT); - if( !float2.WithinEpsilon( float2.Zero, dist.ToFloat2(), range * Game.CellSize ) ) + if (!Combat.IsInRange(self.CenterLocation, attack.GetMaximumRange(), target)) aircraft.TickMove(PSubPos.PerPx * aircraft.MovementSpeed, desiredFacing); attack.DoAttack( self, target ); diff --git a/OpenRA.Mods.RA/Air/HeliFly.cs b/OpenRA.Mods.RA/Air/HeliFly.cs index a77236df9a..b0962801dd 100755 --- a/OpenRA.Mods.RA/Air/HeliFly.cs +++ b/OpenRA.Mods.RA/Air/HeliFly.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Air } var dist = Dest - aircraft.PxPosition; - if (float2.WithinEpsilon(float2.Zero, dist.ToFloat2(), 2)) + if (Math.Abs(dist.X) < 2 && Math.Abs(dist.Y) < 2) { aircraft.SubPxPosition = Dest.ToPSubPos(); return NextActivity; diff --git a/OpenRA.Mods.RA/Air/ReturnToBase.cs b/OpenRA.Mods.RA/Air/ReturnToBase.cs index e2b4285890..1244371364 100755 --- a/OpenRA.Mods.RA/Air/ReturnToBase.cs +++ b/OpenRA.Mods.RA/Air/ReturnToBase.cs @@ -56,17 +56,17 @@ namespace OpenRA.Mods.RA.Air var altitude = aircraft.Altitude; if (altitude == 0) altitude = self.Info.Traits.Get().CruiseAltitude; - var approachStart = landPos.ToFloat2() - new float2(altitude * speed, 0); + var approachStart = landPos.ToInt2() - new float2(altitude * speed, 0); var turnRadius = (128f / self.Info.Traits.Get().ROT) * speed / (float)Math.PI; /* work out the center points */ var fwd = -float2.FromAngle(aircraft.Facing / 128f * (float)Math.PI); var side = new float2(-fwd.Y, fwd.X); /* rotate */ var sideTowardBase = new[] { side, -side } - .OrderBy(a => float2.Dot(a, self.CenterLocation.ToFloat2() - approachStart)) + .OrderBy(a => float2.Dot(a, self.CenterLocation.ToInt2() - approachStart)) .First(); - var c1 = self.CenterLocation.ToFloat2() + turnRadius * sideTowardBase; + var c1 = self.CenterLocation.ToInt2() + turnRadius * sideTowardBase; var c2 = approachStart + new float2(0, turnRadius * Math.Sign(self.CenterLocation.Y - approachStart.Y)); // above or below start point /* work out tangent points */ diff --git a/OpenRA.Mods.RA/AutoTarget.cs b/OpenRA.Mods.RA/AutoTarget.cs index 4725eeb837..7a3f5d936a 100644 --- a/OpenRA.Mods.RA/AutoTarget.cs +++ b/OpenRA.Mods.RA/AutoTarget.cs @@ -107,7 +107,7 @@ namespace OpenRA.Mods.RA { var info = self.Info.Traits.Get(); nextScanTime = (int)(25 * (info.ScanTimeAverage + - (self.World.SharedRandom.NextDouble() * 2 - 1) * info.ScanTimeSpread)); + (self.World.SharedRandom.NextFloat() * 2 - 1) * info.ScanTimeSpread)); var inRange = self.World.FindUnitsInCircle(self.CenterLocation, (int)(Game.CellSize * range)); diff --git a/OpenRA.Mods.RA/BelowUnits.cs b/OpenRA.Mods.RA/BelowUnits.cs index c6336de911..4795bd7f0c 100644 --- a/OpenRA.Mods.RA/BelowUnits.cs +++ b/OpenRA.Mods.RA/BelowUnits.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -18,7 +19,7 @@ namespace OpenRA.Mods.RA class BelowUnits : IRenderModifier { - public IEnumerable ModifyRender(Actor self, IEnumerable r) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { return r.Select(a => a.WithZOffset((int) -a.Sprite.size.Y)); } diff --git a/OpenRA.Mods.RA/Bridge.cs b/OpenRA.Mods.RA/Bridge.cs index 67d84a569b..b98df7974f 100644 --- a/OpenRA.Mods.RA/Bridge.cs +++ b/OpenRA.Mods.RA/Bridge.cs @@ -135,10 +135,18 @@ namespace OpenRA.Mods.RA return bridges.GetBridge(self.Location + new CVec(offset[0], offset[1])); } - public IEnumerable RenderAsTerrain(Actor self) + bool initializePalettes = true; + PaletteReference terrainPalette; + public IEnumerable RenderAsTerrain(WorldRenderer wr, Actor self) { + if (initializePalettes) + { + terrainPalette = wr.Palette("terrain"); + initializePalettes = false; + } + foreach (var t in TileSprites[currentTemplate]) - yield return new Renderable(t.Value, t.Key.ToPPos().ToFloat2(), "terrain", Game.CellSize * t.Key.Y); + yield return new Renderable(t.Value, t.Key.ToPPos().ToFloat2(), terrainPalette, Game.CellSize * t.Key.Y); } bool IsIntact(Bridge b) diff --git a/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs index 1ddfc42628..67b1095630 100755 --- a/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs @@ -19,6 +19,7 @@ namespace OpenRA.Mods.RA.Buildings public readonly int RepairPercent = 20; public readonly int RepairInterval = 24; public readonly int RepairStep = 7; + public readonly string IndicatorPalettePrefix = "player"; public object Create(ActorInitializer init) { return new RepairableBuilding(init.self, this); } } @@ -51,7 +52,7 @@ namespace OpenRA.Mods.RA.Buildings Sound.PlayNotification(Repairer, "Speech", "Repairing", self.Owner.Country.Race); self.World.AddFrameEndTask( - w => w.Add(new RepairIndicator(self, p))); + w => w.Add(new RepairIndicator(self, Info.IndicatorPalettePrefix, p))); } } } diff --git a/OpenRA.Mods.RA/C4Demolition.cs b/OpenRA.Mods.RA/C4Demolition.cs index 74a444a465..24c2e29483 100644 --- a/OpenRA.Mods.RA/C4Demolition.cs +++ b/OpenRA.Mods.RA/C4Demolition.cs @@ -10,8 +10,8 @@ using System.Collections.Generic; using System.Drawing; +using OpenRA.Effects; using OpenRA.Mods.RA.Activities; -using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Orders; using OpenRA.Traits; @@ -35,12 +35,12 @@ namespace OpenRA.Mods.RA public IEnumerable Orders { - get { yield return new UnitTraitOrderTargeter( "C4", 6, "c4", true, false ); } + get { yield return new UnitTraitOrderTargeter("C4", 6, "c4", true, false); } } public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued ) { - if( order.OrderID == "C4" ) + if (order.OrderID == "C4") return new Order("C4", self, queued) { TargetActor = target.Actor }; return null; @@ -65,4 +65,7 @@ namespace OpenRA.Mods.RA return (order.OrderString == "C4") ? "Attack" : null; } } + + class C4DemolishableInfo : TraitInfo { } + class C4Demolishable { } } diff --git a/OpenRA.Mods.RA/CarpetBomb.cs b/OpenRA.Mods.RA/CarpetBomb.cs index 1e9473f972..a6162d66c7 100644 --- a/OpenRA.Mods.RA/CarpetBomb.cs +++ b/OpenRA.Mods.RA/CarpetBomb.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -8,6 +8,7 @@ */ #endregion +using System.Linq; using OpenRA.GameRules; using OpenRA.Traits; @@ -56,7 +57,7 @@ namespace OpenRA.Mods.RA self.World.Add(args.weapon.Projectile.Create(args)); - if (args.weapon.Report != null) + if (args.weapon.Report != null && args.weapon.Report.Any()) Sound.Play(args.weapon.Report.Random(self.World.SharedRandom) + ".aud", self.CenterLocation); } } diff --git a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs index 242f112c8e..419875c151 100644 --- a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs +++ b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs @@ -32,8 +32,6 @@ namespace OpenRA.Mods.RA if (remainingFrames > 0) remainingFrames--; } - - static List excludePalettes = new List{"cursor", "chrome", "colorpicker", "shroud", "fog"}; public void AdjustPalette(Dictionary palettes) { @@ -44,9 +42,6 @@ namespace OpenRA.Mods.RA foreach (var pal in palettes) { - if (excludePalettes.Contains(pal.Key)) - continue; - for (var x = 0; x < 256; x++) { var orig = pal.Value.GetColor(x); diff --git a/OpenRA.Mods.RA/Cloak.cs b/OpenRA.Mods.RA/Cloak.cs index e4924828d3..5a9e320db1 100644 --- a/OpenRA.Mods.RA/Cloak.cs +++ b/OpenRA.Mods.RA/Cloak.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -67,13 +68,13 @@ namespace OpenRA.Mods.RA static readonly Renderable[] Nothing = { }; - public IEnumerable ModifyRender(Actor self, IEnumerable rs) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { if (remainingTime > 0) - return rs; + return r; if (Cloaked && IsVisible(self)) - return rs.Select(a => a.WithPalette(info.Palette)); + return r.Select(a => a.WithPalette(wr.Palette(info.Palette))); else return Nothing; } diff --git a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs b/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs deleted file mode 100644 index ba343c9d53..0000000000 --- a/OpenRA.Mods.RA/ColorPickerPaletteModifier.cs +++ /dev/null @@ -1,47 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System.Collections.Generic; -using System.Linq; -using OpenRA.FileFormats; -using OpenRA.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - public class ColorPickerPaletteModifierInfo : ITraitInfo - { - public string PlayerPalette = "player"; - public object Create( ActorInitializer init ) { return new ColorPickerPaletteModifier( this ); } - } - - public class ColorPickerPaletteModifier : IPalette, IPaletteModifier - { - ColorPickerPaletteModifierInfo Info; - int[] index; - public ColorRamp Ramp; - - public ColorPickerPaletteModifier(ColorPickerPaletteModifierInfo info) { Info = info; } - - public void InitPalette( WorldRenderer wr ) - { - var info = Rules.Info["player"].Traits.WithInterface() - .First(p => p.BaseName == Info.PlayerPalette); - index = info.RemapIndex; - wr.AddPalette("colorpicker", wr.GetPalette(info.BasePalette)); - } - - public void AdjustPalette(Dictionary palettes) - { - palettes["colorpicker"] = new Palette(palettes["colorpicker"], - new PlayerColorRemap(index, Ramp)); - } - } -} diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index f880f01a12..b21034c93b 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -153,7 +153,7 @@ namespace OpenRA.Mods.RA facing = 0 }; - if (args.weapon.Report != null) + if (args.weapon.Report != null && args.weapon.Report.Any()) Sound.Play(args.weapon.Report.Random(attacker.World.SharedRandom) + ".aud", pos); DoImpacts(args); @@ -208,18 +208,18 @@ namespace OpenRA.Mods.RA return false; } - static float2 GetRecoil(Actor self, float recoil) + static PVecFloat GetRecoil(Actor self, float recoil) { if (!self.HasTrait()) - return float2.Zero; + return PVecFloat.Zero; var facing = self.Trait().turretFacing; var localRecoil = new float2(0, recoil); // vector in turret-space. - return Util.RotateVectorByFacing(localRecoil, facing, .7f); + return (PVecFloat)Util.RotateVectorByFacing(localRecoil, facing, .7f); } - public static PVecInt GetTurretPosition(Actor self, IFacing facing, Turret turret) + public static PVecFloat GetTurretPosition(Actor self, IFacing facing, Turret turret) { if (facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */ @@ -228,23 +228,23 @@ namespace OpenRA.Mods.RA var bodyFacing = facing.Facing; var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs); - return (PVecInt) ((PVecFloat)(Util.RotateVectorByFacing(turret.UnitSpacePosition.ToFloat2(), quantizedFacing, .7f) - + GetRecoil(self, turret.Recoil)) - + turret.ScreenSpacePosition); + return (PVecFloat)Util.RotateVectorByFacing(turret.UnitSpacePosition.ToFloat2(), quantizedFacing, .7f) + + GetRecoil(self, turret.Recoil) + + (PVecFloat)turret.ScreenSpacePosition.ToFloat2(); } - static PVecInt GetUnitspaceBarrelOffset(Actor self, IFacing facing, Turret turret, Barrel barrel) + static PVecFloat GetUnitspaceBarrelOffset(Actor self, IFacing facing, Turret turret, Barrel barrel) { var turreted = self.TraitOrDefault(); if (turreted == null && facing == null) - return PVecInt.Zero; + return PVecFloat.Zero; var turretFacing = turreted != null ? turreted.turretFacing : facing.Facing; - return (PVecInt)(PVecFloat)Util.RotateVectorByFacing(barrel.TurretSpaceOffset.ToFloat2(), turretFacing, .7f); + return (PVecFloat)Util.RotateVectorByFacing(barrel.TurretSpaceOffset.ToFloat2(), turretFacing, .7f); } // gets the screen-space position of a barrel. - public static PVecInt GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel) + public static PVecFloat GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel) { return GetTurretPosition(self, facing, turret) + barrel.ScreenSpaceOffset + GetUnitspaceBarrelOffset(self, facing, turret, barrel); diff --git a/OpenRA.Mods.RA/CrateDrop.cs b/OpenRA.Mods.RA/CrateDrop.cs index 2e2d362d1d..7be813ba3c 100644 --- a/OpenRA.Mods.RA/CrateDrop.cs +++ b/OpenRA.Mods.RA/CrateDrop.cs @@ -40,6 +40,8 @@ namespace OpenRA.Mods.RA public void Tick(Actor self) { + if (!self.World.LobbyInfo.GlobalSettings.Crates) return; + if (--ticks <= 0) { ticks = Info.SpawnInterval * 25; // todo: randomize @@ -76,7 +78,7 @@ namespace OpenRA.Mods.RA void SpawnCrate(Actor self) { - var inWater = self.World.SharedRandom.NextDouble() < Info.WaterChance; + var inWater = self.World.SharedRandom.NextFloat() < Info.WaterChance; var pp = ChooseDropCell(self, inWater, 100); if (pp == null) return; diff --git a/OpenRA.Mods.RA/CrateSpawner.cs b/OpenRA.Mods.RA/CrateSpawner.cs index 9b58c66ade..164aa2ec16 100644 --- a/OpenRA.Mods.RA/CrateSpawner.cs +++ b/OpenRA.Mods.RA/CrateSpawner.cs @@ -34,6 +34,8 @@ namespace OpenRA.Mods.RA public void Tick(Actor self) { + if (!self.World.LobbyInfo.GlobalSettings.Crates) return; + if (--ticks <= 0) { var info = self.Info.Traits.Get(); @@ -52,7 +54,7 @@ namespace OpenRA.Mods.RA void SpawnCrate(Actor self, CrateSpawnerInfo info) { var threshold = 100; - var inWater = self.World.SharedRandom.NextDouble() < info.WaterChance; + var inWater = self.World.SharedRandom.NextFloat() < info.WaterChance; for (var n = 0; n < threshold; n++ ) { diff --git a/OpenRA.Mods.RA/CrushableInfantry.cs b/OpenRA.Mods.RA/CrushableInfantry.cs index 907e3148cb..3b625c056f 100644 --- a/OpenRA.Mods.RA/CrushableInfantry.cs +++ b/OpenRA.Mods.RA/CrushableInfantry.cs @@ -13,10 +13,11 @@ using System.Linq; using OpenRA.Traits; using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Move; +using OpenRA.Mods.RA.Render; namespace OpenRA.Mods.RA { - class CrushableInfantryInfo : ITraitInfo, Requires + class CrushableInfantryInfo : ITraitInfo, Requires, Requires { public readonly string CrushSound = "squish2.aud"; public readonly string CorpseSequence = "die-crushed"; @@ -29,11 +30,13 @@ namespace OpenRA.Mods.RA { readonly Actor self; readonly CrushableInfantryInfo Info; + readonly RenderInfantry ri; public CrushableInfantry(Actor self, CrushableInfantryInfo info) { this.self = self; this.Info = info; + ri = self.Trait(); } public void WarnCrush(Actor crusher) @@ -45,12 +48,7 @@ namespace OpenRA.Mods.RA public void OnCrush(Actor crusher) { Sound.Play(Info.CrushSound, crusher.CenterLocation); - self.World.AddFrameEndTask(w => - { - if (!self.Destroyed) - w.Add(new Corpse(self, Info.CorpseSequence)); - }); - + ri.SpawnCorpse(self, Info.CorpseSequence); self.Kill(crusher); } diff --git a/OpenRA.Mods.RA/Effects/Bullet.cs b/OpenRA.Mods.RA/Effects/Bullet.cs index dffa8b47bd..19a1b87a26 100755 --- a/OpenRA.Mods.RA/Effects/Bullet.cs +++ b/OpenRA.Mods.RA/Effects/Bullet.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Effects if (info.Inaccuracy > 0) { - var factor = ((Args.dest - Args.src).Length / (float)Game.CellSize) / args.weapon.Range; + var factor = ((Args.dest - Args.src).Length / Game.CellSize) / (float)args.weapon.Range; Args.dest += (PVecInt) (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); } @@ -144,7 +144,7 @@ namespace OpenRA.Mods.RA.Effects const float height = .1f; - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (anim != null) { @@ -158,15 +158,15 @@ namespace OpenRA.Mods.RA.Effects if (Info.High || Info.Angle > 0) { if (Info.Shadow) - yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y); + yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, wr.Palette("shadow"), (int)pos.Y); var highPos = pos - new float2(0, GetAltitude()); - yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, "effect", (int)pos.Y); + yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, wr.Palette("effect"), (int)pos.Y); } else yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, - Args.weapon.Underwater ? "shadow" : "effect", (int)pos.Y); + wr.Palette(Args.weapon.Underwater ? "shadow" : "effect"), (int)pos.Y); } } diff --git a/OpenRA.Mods.RA/Effects/CashTick.cs b/OpenRA.Mods.RA/Effects/CashTick.cs index 8c2195da9a..976885945b 100644 --- a/OpenRA.Mods.RA/Effects/CashTick.cs +++ b/OpenRA.Mods.RA/Effects/CashTick.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Effects pos -= new PVecInt(0, velocity); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { font.DrawTextWithContrast(s, Game.viewport.Zoom*(pos.ToFloat2() - Game.viewport.Location) - offset, color, Color.Black,1); yield break; diff --git a/OpenRA.Mods.RA/Effects/Contrail.cs b/OpenRA.Mods.RA/Effects/Contrail.cs index 170da8bdc3..1fa6602b5c 100755 --- a/OpenRA.Mods.RA/Effects/Contrail.cs +++ b/OpenRA.Mods.RA/Effects/Contrail.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA public void Tick(Actor self) { - history.Tick(self.CenterLocation - new PVecInt(0, move.Altitude) - Combat.GetTurretPosition(self, facing, contrailTurret)); + history.Tick(self.CenterLocation - new PVecInt(0, move.Altitude) - (PVecInt)Combat.GetTurretPosition(self, facing, contrailTurret).ToInt2()); } public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(self); } diff --git a/OpenRA.Mods.RA/Effects/Corpse.cs b/OpenRA.Mods.RA/Effects/Corpse.cs index 7a536b9ab8..383cc5dd26 100644 --- a/OpenRA.Mods.RA/Effects/Corpse.cs +++ b/OpenRA.Mods.RA/Effects/Corpse.cs @@ -19,24 +19,21 @@ namespace OpenRA.Mods.RA.Effects { readonly Animation anim; readonly float2 pos; - readonly string palette; + readonly string paletteName; - public Corpse(Actor fromActor, string sequence) + public Corpse(World world, float2 pos, string image, string sequence, string paletteName) { - var rs = fromActor.Trait(); - palette = rs.Palette(fromActor.Owner); - anim = new Animation(rs.GetImage(fromActor)); - anim.PlayThen(sequence, - () => fromActor.World.AddFrameEndTask(w => w.Remove(this))); - - pos = fromActor.CenterLocation.ToFloat2(); + this.pos = pos; + this.paletteName = paletteName; + anim = new Animation(image); + anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); } - public void Tick( World world ) { anim.Tick(); } + public void Tick(World world) { anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { - yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, palette, (int)pos.Y); + yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, wr.Palette(paletteName), (int)pos.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/CrateEffect.cs b/OpenRA.Mods.RA/Effects/CrateEffect.cs index 7f0e7ab083..61b70dd326 100644 --- a/OpenRA.Mods.RA/Effects/CrateEffect.cs +++ b/OpenRA.Mods.RA/Effects/CrateEffect.cs @@ -39,11 +39,12 @@ namespace OpenRA.Mods.RA.Effects anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (a.IsInWorld) yield return new Renderable(anim.Image, - a.CenterLocation.ToFloat2() - .5f * anim.Image.size + offset, "effect", (int)a.CenterLocation.Y); + a.CenterLocation.ToFloat2() - .5f * anim.Image.size + offset, + wr.Palette("effect"), (int)a.CenterLocation.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/Explosion.cs b/OpenRA.Mods.RA/Effects/Explosion.cs index 646999ae2f..942abb9a0a 100644 --- a/OpenRA.Mods.RA/Effects/Explosion.cs +++ b/OpenRA.Mods.RA/Effects/Explosion.cs @@ -32,11 +32,11 @@ namespace OpenRA.Mods.RA.Effects public void Tick( World world ) { anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { yield return new Renderable(anim.Image, pos.ToFloat2() - .5f * anim.Image.size - new int2(0,altitude), - "effect", (int)pos.Y - altitude); + wr.Palette("effect"), (int)pos.Y - altitude); } public Player Owner { get { return null; } } diff --git a/OpenRA.Mods.RA/Effects/GpsDot.cs b/OpenRA.Mods.RA/Effects/GpsDot.cs index 21f1413628..7b63f440dc 100644 --- a/OpenRA.Mods.RA/Effects/GpsDot.cs +++ b/OpenRA.Mods.RA/Effects/GpsDot.cs @@ -15,65 +15,76 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Effects { - class GpsDotInfo : ITraitInfo, Requires + class GpsDotInfo : ITraitInfo { public readonly string String = "Infantry"; + public readonly string IndicatorPalettePrefix = "player"; + public object Create(ActorInitializer init) { - return new GpsDot(init, String); + return new GpsDot(init.self, this); } } class GpsDot : IEffect { Actor self; - GpsWatcher watcher; - RenderSimple rs; - bool show = false; + GpsDotInfo info; Animation anim; - public GpsDot(ActorInitializer init, string s) - { - anim = new Animation("gpsdot"); - anim.PlayRepeating(s); + GpsWatcher watcher; + HiddenUnderFog huf; + Spy spy; + bool show = false; + + public GpsDot(Actor self, GpsDotInfo info) + { + this.self = self; + this.info = info; + anim = new Animation("gpsdot"); + anim.PlayRepeating(info.String); - self = init.self; - rs = self.Trait(); self.World.AddFrameEndTask(w => w.Add(this)); - if(self.World.LocalPlayer != null) + if (self.World.LocalPlayer != null) watcher = self.World.LocalPlayer.PlayerActor.Trait(); } + bool firstTick = true; public void Tick(World world) { - show = false; - if (self.Destroyed) world.AddFrameEndTask(w => w.Remove(this)); - if (world.LocalPlayer == null) + if (world.LocalPlayer == null || !self.IsInWorld || self.Destroyed) return; - if ( - self.IsInWorld - && (watcher.Granted || watcher.GrantedAllies) - && !self.Trait().IsVisible(self.World.RenderedShroud, self) // WRONG - && (!self.HasTrait() || !self.Trait().Cloaked) - && (!self.HasTrait() || !self.Trait().Disguised) - ) + // Can be granted at runtime via a crate, so can't cache + var cloak = self.TraitOrDefault(); + + if (firstTick) { - show = true; + huf = self.TraitOrDefault(); + spy = self.TraitOrDefault(); + firstTick = false; } + + var hasGps = (watcher != null && (watcher.Granted || watcher.GrantedAllies)); + var hasDot = (huf != null && !huf.IsVisible(self.World.RenderedShroud, self)); // WRONG (why?) + var dotHidden = (cloak != null && cloak.Cloaked) || (spy != null && spy.Disguised); + + show = hasGps && hasDot && !dotHidden; } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { - if (show && !self.Destroyed) - { - var p = self.CenterLocation; - yield return new Renderable(anim.Image, p.ToFloat2() - 0.5f * anim.Image.size, rs.Palette(self.Owner), p.Y) - .WithScale(1.5f); - } + if (!show || self.Destroyed) + yield break; + + var p = self.CenterLocation; + var palette = wr.Palette(info.IndicatorPalettePrefix+self.Owner.InternalName); + yield return new Renderable(anim.Image, p.ToFloat2() - 0.5f * anim.Image.size, palette, p.Y) + .WithScale(1.5f); + } } } diff --git a/OpenRA.Mods.RA/Effects/GpsSatellite.cs b/OpenRA.Mods.RA/Effects/GpsSatellite.cs index 30d0d63df3..be28c34cc5 100644 --- a/OpenRA.Mods.RA/Effects/GpsSatellite.cs +++ b/OpenRA.Mods.RA/Effects/GpsSatellite.cs @@ -36,9 +36,9 @@ namespace OpenRA.Mods.RA.Effects world.AddFrameEndTask(w => w.Remove(this)); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { - yield return new Renderable(anim.Image,offset, "effect", (int)offset.Y); + yield return new Renderable(anim.Image,offset, wr.Palette("effect"), (int)offset.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/GravityBomb.cs b/OpenRA.Mods.RA/Effects/GravityBomb.cs index 36a142c7ab..090c776995 100755 --- a/OpenRA.Mods.RA/Effects/GravityBomb.cs +++ b/OpenRA.Mods.RA/Effects/GravityBomb.cs @@ -51,10 +51,10 @@ namespace OpenRA.Mods.RA.Effects anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { - yield return new Renderable(anim.Image, - Args.dest.ToInt2() - new int2(0, altitude) - .5f * anim.Image.size, "effect", Args.dest.Y); + var pos = Args.dest.ToInt2() - new int2(0, altitude) - .5f * anim.Image.size; + yield return new Renderable(anim.Image, pos, wr.Palette("effect"), Args.dest.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/InvulnEffect.cs b/OpenRA.Mods.RA/Effects/InvulnEffect.cs index 1e17098892..d16dd233a9 100644 --- a/OpenRA.Mods.RA/Effects/InvulnEffect.cs +++ b/OpenRA.Mods.RA/Effects/InvulnEffect.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using OpenRA.Effects; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Effects @@ -31,13 +32,13 @@ namespace OpenRA.Mods.RA.Effects world.AddFrameEndTask(w => w.Remove(this)); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (a.Destroyed) // Tick will clean up yield break; - foreach (var r in a.Render()) - yield return r.WithPalette("invuln"); + foreach (var r in a.Render(wr)) + yield return r.WithPalette(wr.Palette("invuln")); } } } diff --git a/OpenRA.Mods.RA/Effects/LaserZap.cs b/OpenRA.Mods.RA/Effects/LaserZap.cs index bba07c0386..de0589ebd1 100755 --- a/OpenRA.Mods.RA/Effects/LaserZap.cs +++ b/OpenRA.Mods.RA/Effects/LaserZap.cs @@ -74,11 +74,11 @@ namespace OpenRA.Mods.RA.Effects world.AddFrameEndTask(w => w.Remove(this)); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (explosion != null) - yield return new Renderable(explosion.Image, - args.dest.ToFloat2() - .5f * explosion.Image.size, "effect", (int)args.dest.Y); + yield return new Renderable(explosion.Image, args.dest.ToFloat2() - .5f * explosion.Image.size, + wr.Palette("effect"), (int)args.dest.Y); if (ticks >= info.BeamDuration) yield break; diff --git a/OpenRA.Mods.RA/Effects/Missile.cs b/OpenRA.Mods.RA/Effects/Missile.cs index f6e84ae683..d273a087a9 100755 --- a/OpenRA.Mods.RA/Effects/Missile.cs +++ b/OpenRA.Mods.RA/Effects/Missile.cs @@ -152,11 +152,11 @@ namespace OpenRA.Mods.RA.Effects Combat.DoImpacts(Args); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (Args.firedBy.World.RenderedShroud.IsVisible(PxPosition.ToCPos())) yield return new Renderable(anim.Image, PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude), - Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y); + wr.Palette(Args.weapon.Underwater ? "shadow" : "effect"), PxPosition.Y); if (Trail != null) Trail.Render(Args.firedBy); diff --git a/OpenRA.Mods.RA/Effects/NukeLaunch.cs b/OpenRA.Mods.RA/Effects/NukeLaunch.cs index 251370991f..8b52557bca 100755 --- a/OpenRA.Mods.RA/Effects/NukeLaunch.cs +++ b/OpenRA.Mods.RA/Effects/NukeLaunch.cs @@ -77,10 +77,10 @@ namespace OpenRA.Mods.RA.Effects a.Trait.Enable(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { yield return new Renderable(anim.Image, pos.ToFloat2() - 0.5f * anim.Image.size - new float2(0, altitude), - "effect", (int)pos.Y); + wr.Palette("effect"), (int)pos.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index eede52a569..daf2e9d92e 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -9,6 +9,7 @@ #endregion using System.Collections.Generic; +using System.Linq; using OpenRA.Effects; using OpenRA.Graphics; using OpenRA.Traits; @@ -17,8 +18,6 @@ namespace OpenRA.Mods.RA.Effects { public class Parachute : IEffect { - readonly Animation anim; - readonly string palette; readonly Animation paraAnim; readonly PPos location; @@ -28,29 +27,19 @@ namespace OpenRA.Mods.RA.Effects float altitude; const float fallRate = .3f; - public Parachute(Player owner, PPos location, int altitude, Actor cargo) + public Parachute(Actor cargo, PPos location, int altitude) { this.location = location; this.altitude = altitude; this.cargo = cargo; - var rs = cargo.Trait(); - var image = rs.anim.Name; - palette = rs.Palette(owner); - - anim = new Animation(image); - if (anim.HasSequence("idle")) - anim.PlayFetchIndex("idle", () => 0); - else - anim.PlayFetchIndex("stand", () => 0); - anim.Tick(); - var pai = cargo.Info.Traits.GetOrDefault(); - paraAnim = new Animation(pai != null ? pai.ParachuteSprite : "parach"); paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle")); if (pai != null) offset = pai.Offset; + + cargo.Trait().SetPxPosition(cargo, location); } public void Tick(World world) @@ -73,12 +62,23 @@ namespace OpenRA.Mods.RA.Effects }); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { + var rc = cargo.Render(wr).Select(a => a.WithPos(a.Pos - new float2(0, altitude)) + .WithZOffset(a.ZOffset + (int)altitude)); + + // Don't render anything if the cargo is invisible (e.g. under fog) + if (!rc.Any()) + yield break; + + foreach (var c in rc) + { + yield return c.WithPos(location.ToFloat2() - .5f * c.Sprite.size).WithPalette(wr.Palette("shadow")).WithZOffset(0); + yield return c.WithZOffset(2); + } + var pos = location.ToFloat2() - new float2(0, altitude); - yield return new Renderable(anim.Image, location.ToFloat2() - .5f * anim.Image.size, "shadow", 0); - yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, palette, 2); - yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size + offset, palette, 3); + yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size + offset, rc.First().Palette, 3); } } } diff --git a/OpenRA.Mods.RA/Effects/PowerdownIndicator.cs b/OpenRA.Mods.RA/Effects/PowerdownIndicator.cs index 96b568c3d3..1605d9dfcd 100644 --- a/OpenRA.Mods.RA/Effects/PowerdownIndicator.cs +++ b/OpenRA.Mods.RA/Effects/PowerdownIndicator.cs @@ -34,11 +34,11 @@ namespace OpenRA.Mods.RA.Effects anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (!a.Destroyed && (a.World.LocalPlayer == null || a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally)) - yield return new Renderable(anim.Image, - a.CenterLocation.ToFloat2() - .5f * anim.Image.size, "chrome", (int)a.CenterLocation.Y); + yield return new Renderable(anim.Image, a.CenterLocation.ToFloat2() - .5f * anim.Image.size, + wr.Palette("chrome"), (int)a.CenterLocation.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/RallyPoint.cs b/OpenRA.Mods.RA/Effects/RallyPoint.cs index bedd9a904e..555d597bd6 100755 --- a/OpenRA.Mods.RA/Effects/RallyPoint.cs +++ b/OpenRA.Mods.RA/Effects/RallyPoint.cs @@ -20,13 +20,15 @@ namespace OpenRA.Mods.RA.Effects { readonly Actor building; readonly RA.RallyPoint rp; + readonly string palettePrefix; public Animation flag = new Animation("rallypoint"); public Animation circles = new Animation("rallypoint"); - public RallyPoint(Actor building) + public RallyPoint(Actor building, string palettePrefix) { this.building = building; rp = building.Trait(); + this.palettePrefix = palettePrefix; flag.PlayRepeating("flag"); circles.Play("circles"); } @@ -46,13 +48,13 @@ namespace OpenRA.Mods.RA.Effects world.AddFrameEndTask(w => w.Remove(this)); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (building.IsInWorld && building.Owner == building.World.LocalPlayer && building.World.Selection.Actors.Contains(building)) { var pos = Traits.Util.CenterOfCell(rp.rallyPoint); - var palette = building.Trait().Palette(building.Owner); + var palette = wr.Palette(palettePrefix+building.Owner.InternalName); yield return new Renderable(circles.Image, pos.ToFloat2() - .5f * circles.Image.size, diff --git a/OpenRA.Mods.RA/Effects/RepairIndicator.cs b/OpenRA.Mods.RA/Effects/RepairIndicator.cs index e710e92534..302e07f991 100755 --- a/OpenRA.Mods.RA/Effects/RepairIndicator.cs +++ b/OpenRA.Mods.RA/Effects/RepairIndicator.cs @@ -20,34 +20,35 @@ namespace OpenRA.Mods.RA.Effects { Actor building; Player player; + string palettePrefix; Animation anim = new Animation("allyrepair"); + RepairableBuilding rb; - public RepairIndicator(Actor building, Player player) + public RepairIndicator(Actor building, string palettePrefix, Player player) { this.building = building; this.player = player; + this.palettePrefix = palettePrefix; + rb = building.Trait(); anim.PlayRepeating("repair"); } public void Tick(World world) { - if (!building.IsInWorld || - building.IsDead() || - building.Trait().Repairer == null || - building.Trait().Repairer != player) + if (!building.IsInWorld || building.IsDead() || + rb.Repairer == null || rb.Repairer != player) world.AddFrameEndTask(w => w.Remove(this)); anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { if (!building.Destroyed) { - var palette = building.Trait().Palette(player); - yield return new Renderable(anim.Image, - building.CenterLocation.ToFloat2() - .5f * anim.Image.size, palette, (int)building.CenterLocation.Y); + building.CenterLocation.ToFloat2() - .5f * anim.Image.size, + wr.Palette(palettePrefix+player.InternalName), (int)building.CenterLocation.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/SatelliteLaunch.cs b/OpenRA.Mods.RA/Effects/SatelliteLaunch.cs index 1934e6f3e0..047f27e5ba 100644 --- a/OpenRA.Mods.RA/Effects/SatelliteLaunch.cs +++ b/OpenRA.Mods.RA/Effects/SatelliteLaunch.cs @@ -40,9 +40,9 @@ namespace OpenRA.Mods.RA.Effects } } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { - yield return new Renderable(doors.Image, pos, "effect", (int)doorOffset.Y); + yield return new Renderable(doors.Image, pos, wr.Palette("effect"), (int)doorOffset.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/Smoke.cs b/OpenRA.Mods.RA/Effects/Smoke.cs index e966e9b355..f82f963296 100644 --- a/OpenRA.Mods.RA/Effects/Smoke.cs +++ b/OpenRA.Mods.RA/Effects/Smoke.cs @@ -33,9 +33,10 @@ namespace OpenRA.Mods.RA.Effects anim.Tick(); } - public IEnumerable Render() + public IEnumerable Render(WorldRenderer wr) { - yield return new Renderable(anim.Image, pos.ToFloat2() - .5f * anim.Image.size, "effect", (int)pos.Y); + yield return new Renderable(anim.Image, pos.ToFloat2() - .5f * anim.Image.size, + wr.Palette("effect"), (int)pos.Y); } } } diff --git a/OpenRA.Mods.RA/Effects/TeslaZap.cs b/OpenRA.Mods.RA/Effects/TeslaZap.cs index 4ef516e5d0..3d9a25c801 100755 --- a/OpenRA.Mods.RA/Effects/TeslaZap.cs +++ b/OpenRA.Mods.RA/Effects/TeslaZap.cs @@ -29,27 +29,35 @@ namespace OpenRA.Mods.RA.Effects class TeslaZap : IEffect { readonly ProjectileArgs Args; + readonly TeslaZapInfo Info; + IEnumerable renderables; int timeUntilRemove = 2; // # of frames bool doneDamage = false; - - readonly List renderables = new List(); + bool initialized = false; public TeslaZap(TeslaZapInfo info, ProjectileArgs args) { Args = args; - var bright = SequenceProvider.GetSequence(info.Image, "bright"); - var dim = SequenceProvider.GetSequence(info.Image, "dim"); - - for( var n = 0; n < info.DimZaps; n++ ) - renderables.AddRange(DrawZapWandering(args.src, args.dest, dim)); - for( var n = 0; n < info.BrightZaps; n++ ) - renderables.AddRange(DrawZapWandering(args.src, args.dest, bright)); + Info = info; } - public void Tick( World world ) + public IEnumerable GenerateRenderables(WorldRenderer wr) { - if( timeUntilRemove <= 0 ) - world.AddFrameEndTask( w => w.Remove( this ) ); + var bright = SequenceProvider.GetSequence(Info.Image, "bright"); + var dim = SequenceProvider.GetSequence(Info.Image, "dim"); + + for (var n = 0; n < Info.DimZaps; n++) + foreach (var z in DrawZapWandering(wr, Args.src, Args.dest, dim)) + yield return z; + for (var n = 0; n < Info.BrightZaps; n++) + foreach (var z in DrawZapWandering(wr, Args.src, Args.dest, bright)) + yield return z; + } + + public void Tick(World world) + { + if (timeUntilRemove <= 0) + world.AddFrameEndTask(w => w.Remove(this)); --timeUntilRemove; if (!doneDamage) @@ -62,9 +70,18 @@ namespace OpenRA.Mods.RA.Effects } } - public IEnumerable Render() { return renderables; } + public IEnumerable Render(WorldRenderer wr) + { + if (!initialized) + { + renderables = GenerateRenderables(wr); + initialized = true; + } - static IEnumerable DrawZapWandering(PPos from, PPos to, Sequence s) + return renderables; + } + + static IEnumerable DrawZapWandering(WorldRenderer wr, PPos from, PPos to, Sequence s) { var z = float2.Zero; /* hack */ var dist = to - from; @@ -76,22 +93,22 @@ namespace OpenRA.Mods.RA.Effects var p1 = from.ToFloat2() + (1 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm; var p2 = from.ToFloat2() + (2 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm; - renderables.AddRange(DrawZap(from.ToFloat2(), p1, s, out p1)); - renderables.AddRange(DrawZap(p1, p2, s, out p2)); - renderables.AddRange(DrawZap(p2, to.ToFloat2(), s, out z)); + renderables.AddRange(DrawZap(wr, from.ToFloat2(), p1, s, out p1)); + renderables.AddRange(DrawZap(wr, p1, p2, s, out p2)); + renderables.AddRange(DrawZap(wr, p2, to.ToFloat2(), s, out z)); } else { var p1 = from.ToFloat2() + (1 / 2f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm; - renderables.AddRange(DrawZap(from.ToFloat2(), p1, s, out p1)); - renderables.AddRange(DrawZap(p1, to.ToFloat2(), s, out z)); + renderables.AddRange(DrawZap(wr, from.ToFloat2(), p1, s, out p1)); + renderables.AddRange(DrawZap(wr, p1, to.ToFloat2(), s, out z)); } return renderables; } - static IEnumerable DrawZap(float2 from, float2 to, Sequence s, out float2 p) + static IEnumerable DrawZap(WorldRenderer wr, float2 from, float2 to, Sequence s, out float2 p) { var dist = to - from; var q = new float2(-dist.Y, dist.X); @@ -104,7 +121,8 @@ namespace OpenRA.Mods.RA.Effects var step = steps.Where(t => (to - (z + new float2(t[0],t[1]))).LengthSquared < (to - z).LengthSquared ) .OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First(); - rs.Add(new Renderable(s.GetSprite(step[4]), z + new float2(step[2], step[3]), "effect", (int)from.Y)); + rs.Add(new Renderable(s.GetSprite(step[4]), z + new float2(step[2], step[3]), + wr.Palette("effect"), (int)from.Y)); z += new float2(step[0], step[1]); if( rs.Count >= 1000 ) break; diff --git a/OpenRA.Mods.RA/FogPalette.cs b/OpenRA.Mods.RA/FogPalette.cs new file mode 100644 index 0000000000..642bb4e684 --- /dev/null +++ b/OpenRA.Mods.RA/FogPalette.cs @@ -0,0 +1,44 @@ +#region Copyright & License Information +/* + * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System.Drawing; +using OpenRA.FileFormats; +using OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class FogPaletteInfo : ITraitInfo + { + public readonly string Name = "fog"; + public object Create(ActorInitializer init) { return new FogPalette(this); } + } + + class FogPalette : IPalette + { + readonly FogPaletteInfo info; + + public FogPalette(FogPaletteInfo info) { this.info = info; } + + public void InitPalette(WorldRenderer wr) + { + var c = new[] { + Color.Transparent, Color.Green, + Color.Blue, Color.Yellow, + Color.FromArgb(128,0,0,0), + Color.FromArgb(128,0,0,0), + Color.FromArgb(128,0,0,0), + Color.FromArgb(64,0,0,0) + }; + + wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (uint)c[i % 8].ToArgb())), false); + } + } +} diff --git a/OpenRA.Mods.RA/FreeActor.cs b/OpenRA.Mods.RA/FreeActor.cs index 1ed405c92b..ba96eb087b 100644 --- a/OpenRA.Mods.RA/FreeActor.cs +++ b/OpenRA.Mods.RA/FreeActor.cs @@ -21,20 +21,22 @@ namespace OpenRA.Mods.RA public readonly int2 SpawnOffset = int2.Zero; public readonly int Facing = 0; - public object Create( ActorInitializer init ) { return new FreeActor(init.self, this); } + public object Create( ActorInitializer init ) { return new FreeActor(init, this); } } public class FreeActor { - public FreeActor(Actor self, FreeActorInfo info) + public FreeActor(ActorInitializer init, FreeActorInfo info) { - self.World.AddFrameEndTask( + if (init.Contains() && !init.Get().value) return; + + init.self.World.AddFrameEndTask( w => { var a = w.CreateActor(info.Actor, new TypeDictionary { - new LocationInit( self.Location + (CVec)info.SpawnOffset ), - new OwnerInit( self.Owner ), + new LocationInit( init.self.Location + (CVec)info.SpawnOffset ), + new OwnerInit( init.self.Owner ), new FacingInit( info.Facing ), }); @@ -43,4 +45,13 @@ namespace OpenRA.Mods.RA }); } } + + public class FreeActorInit : IActorInit + { + [FieldFromYamlKey] + public readonly bool value = true; + public FreeActorInit() { } + public FreeActorInit(bool init) { value = init; } + public bool Value(World world) { return value; } + } } diff --git a/OpenRA.Mods.RA/GainsExperience.cs b/OpenRA.Mods.RA/GainsExperience.cs index a267df8ab9..022c78c208 100644 --- a/OpenRA.Mods.RA/GainsExperience.cs +++ b/OpenRA.Mods.RA/GainsExperience.cs @@ -97,23 +97,23 @@ namespace OpenRA.Mods.RA return Level > 0 ? Info.SpeedModifier[Level - 1] : 1m; } - public IEnumerable ModifyRender(Actor self, IEnumerable rs) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { if (self.Owner == self.World.LocalPlayer && Level > 0) - return InnerModifyRender(self, rs); + return InnerModifyRender(self, wr, r); else - return rs; + return r; } - IEnumerable InnerModifyRender(Actor self, IEnumerable rs) + IEnumerable InnerModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { - foreach (var r in rs) - yield return r; + foreach (var rs in r) + yield return rs; RankAnim.Tick(); // HACK var bounds = self.Bounds.Value; - yield return new Renderable(RankAnim.Image, - new float2(bounds.Right - 6, bounds.Bottom - 8), "effect", self.CenterLocation.Y); + yield return new Renderable(RankAnim.Image, new float2(bounds.Right - 6, bounds.Bottom - 8), + wr.Palette("effect"), self.CenterLocation.Y); } } diff --git a/OpenRA.Mods.RA/InvisibleToEnemy.cs b/OpenRA.Mods.RA/InvisibleToEnemy.cs index e3ff497308..248f7d7cd9 100644 --- a/OpenRA.Mods.RA/InvisibleToEnemy.cs +++ b/OpenRA.Mods.RA/InvisibleToEnemy.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Drawing; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -32,7 +33,7 @@ namespace OpenRA.Mods.RA static readonly Renderable[] Nothing = { }; - public IEnumerable ModifyRender(Actor self, IEnumerable r) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { return IsVisible(self.Owner.Shroud, self) ? r : Nothing; } diff --git a/OpenRA.Mods.RA/LightPaletteRotator.cs b/OpenRA.Mods.RA/LightPaletteRotator.cs index d3e827b540..ec2e166a3f 100644 --- a/OpenRA.Mods.RA/LightPaletteRotator.cs +++ b/OpenRA.Mods.RA/LightPaletteRotator.cs @@ -24,15 +24,10 @@ namespace OpenRA.Mods.RA t += .5f; } - static readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "terrain" }; - public void AdjustPalette(Dictionary palettes) { foreach (var pal in palettes) { - if (ExcludePalettes.Contains(pal.Key)) - continue; - var rotate = (int)t % 18; if (rotate > 9) rotate = 18 - rotate; diff --git a/OpenRA.Mods.RA/Minelayer.cs b/OpenRA.Mods.RA/Minelayer.cs index 7b76ec7f44..8890d335c4 100644 --- a/OpenRA.Mods.RA/Minelayer.cs +++ b/OpenRA.Mods.RA/Minelayer.cs @@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA var p = end - start; var q = new float2(p.Y, -p.X); q = (start != end) ? (1 / q.Length) * q : new float2(1, 0); - var c = -float2.Dot(q, start.ToFloat2()); + var c = -float2.Dot(q, start.ToInt2()); /* return all points such that |ax + by + c| < depth */ diff --git a/OpenRA.Mods.RA/Missions/Allies02Script.cs b/OpenRA.Mods.RA/Missions/Allies02Script.cs index e728df1822..a74df08466 100644 --- a/OpenRA.Mods.RA/Missions/Allies02Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies02Script.cs @@ -57,6 +57,7 @@ namespace OpenRA.Mods.RA.Missions Actor sam2; Actor sam3; Actor sam4; + Actor[] sams; Actor tanya; Actor einstein; Actor engineer; @@ -74,8 +75,6 @@ namespace OpenRA.Mods.RA.Missions Actor parabombPoint1; Actor parabombPoint2; Actor sovietRallyPoint; - Actor flamersEntryPoint; - Actor tanksEntryPoint; Actor townPoint; Actor sovietTownAttackPoint1; Actor sovietTownAttackPoint2; @@ -103,7 +102,7 @@ namespace OpenRA.Mods.RA.Missions static readonly string[] SovietVehicles1 = { "3tnk" }; static readonly string[] SovietVehicles2 = { "3tnk", "v2rl" }; const int SovietVehiclesUpgradeTicks = 1500 * 4; - const int SovietGroupSize = 20; + const int SovietGroupSize = 5; const int ReinforcementsTicks = 1500 * 12; static readonly string[] Reinforcements = @@ -120,18 +119,11 @@ namespace OpenRA.Mods.RA.Missions const int ParabombTicks = 750; - const int FlamersTicks = 1500 * 2; - static readonly string[] Flamers = { "e4", "e4", "e4", "e4", "e4" }; - const string ApcName = "apc"; - const int ParatroopersTicks = 1500 * 5; static readonly string[] Badger1Passengers = { "e1", "e1", "e1", "e2", "3tnk" }; static readonly string[] Badger2Passengers = { "e1", "e1", "e1", "e2", "e2" }; static readonly string[] Badger3Passengers = { "e1", "e1", "e1", "e2", "e2" }; - const int TanksTicks = 1500 * 11; - static readonly string[] Tanks = { "3tnk", "3tnk", "3tnk", "3tnk", "3tnk", "3tnk", "3tnk", "3tnk" }; - const string SignalFlareName = "flare"; const string YakName = "yak"; @@ -180,12 +172,6 @@ namespace OpenRA.Mods.RA.Missions if (allies1 != allies2) { - if (world.FrameNumber == TanksTicks) - RushSovietUnits(); - - if (world.FrameNumber == FlamersTicks) - RushSovietFlamers(); - if (yak == null || (yak != null && !yak.IsDead() && (yak.GetCurrentActivity() is FlyCircle || yak.IsIdle))) { var alliedUnitsNearYakPoint = world.FindAliveCombatantActorsInCircle(yakAttackPoint.CenterLocation, 10) @@ -218,22 +204,19 @@ namespace OpenRA.Mods.RA.Missions } if (objectives[DestroySamSitesID].Status == ObjectiveStatus.InProgress) { - if ((sam1.Destroyed || sam1.Owner != soviets) - && (sam2.Destroyed || sam2.Owner != soviets) - && (sam3.Destroyed || sam3.Owner != soviets) - && (sam4.Destroyed || sam4.Owner != soviets)) + if (sams.All(s => s.IsDead() || s.Owner != soviets)) { objectives[DestroySamSitesID].Status = ObjectiveStatus.Completed; objectives[ExtractEinsteinID].Status = ObjectiveStatus.InProgress; OnObjectivesUpdated(true); - SpawnSignalFlare(); + world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies1), new LocationInit(extractionLZ.Location) }); Sound.Play("flaren1.aud"); ExtractEinsteinAtLZ(); } } if (objectives[ExtractEinsteinID].Status == ObjectiveStatus.InProgress && einsteinChinook != null) { - if (einsteinChinook.Destroyed) + if (einsteinChinook.IsDead()) { objectives[ExtractEinsteinID].Status = ObjectiveStatus.Failed; objectives[MaintainPresenceID].Status = ObjectiveStatus.Failed; @@ -253,22 +236,19 @@ namespace OpenRA.Mods.RA.Missions } } - if (tanya.Destroyed) + if (tanya.IsDead()) MissionFailed("Tanya was killed."); - else if (einstein.Destroyed) + else if (einstein.IsDead()) MissionFailed("Einstein was killed."); - world.AddFrameEndTask(w => + else if (!world.Actors.Any(a => (a.Owner == allies || a.Owner == allies2) && !a.IsDead() + && (a.HasTrait() && !a.HasTrait()) || a.HasTrait())) { - if (!world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20) - .Any(a => a.HasTrait() && !a.HasTrait() && (a.Owner == allies || a.Owner == allies2))) - { - objectives[MaintainPresenceID].Status = ObjectiveStatus.Failed; - OnObjectivesUpdated(true); - MissionFailed("The Allied reinforcements have been defeated."); - } - }); + objectives[MaintainPresenceID].Status = ObjectiveStatus.Failed; + OnObjectivesUpdated(true); + MissionFailed("The Allied reinforcements have been defeated."); + } } void UpdateDeaths() @@ -308,10 +288,10 @@ namespace OpenRA.Mods.RA.Missions void BuildSovietUnits() { - if (!sovietBarracks.Destroyed) + if (!sovietBarracks.IsDead()) BuildSovietUnit(InfantryQueueName, SovietInfantry.Random(world.SharedRandom)); - if (!sovietWarFactory.Destroyed) + if (!sovietWarFactory.IsDead()) { var vehicles = world.FrameNumber >= SovietVehiclesUpgradeTicks ? SovietVehicles2 : SovietVehicles1; BuildSovietUnit(VehicleQueueName, vehicles.Random(world.SharedRandom)); @@ -320,44 +300,39 @@ namespace OpenRA.Mods.RA.Missions void ManageSovietUnits() { - var idleSovietUnitsAtRP = world.FindAliveCombatantActorsInCircle(sovietRallyPoint.CenterLocation, 3) - .Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait()); - - if (idleSovietUnitsAtRP.Count() >= SovietGroupSize) + var units = world.FindAliveCombatantActorsInCircle(sovietRallyPoint.CenterLocation, 10) + .Where(u => u.IsIdle && u.HasTrait() && u.HasTrait() && u.Owner == soviets) + .Except(world.WorldActor.Trait().Actors.Values); + if (units.Count() >= SovietGroupSize) { - var firstUnit = idleSovietUnitsAtRP.FirstOrDefault(); - if (firstUnit != null) + foreach (var unit in units) + MissionUtils.AttackNearestLandActor(true, unit, allies2); + } + + var scatteredUnits = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && u.IsIdle + && u.HasTrait() && u.HasTrait() && u.Owner == soviets) + .Except(world.WorldActor.Trait().Actors.Values) + .Except(units); + + foreach (var unit in scatteredUnits) + MissionUtils.AttackNearestLandActor(true, unit, allies2); + } + + void SetupAlliedBase() + { + foreach (var actor in world.Actors.Where(a => a.Owner == allies && a != allies.PlayerActor)) + { + actor.ChangeOwner(allies2); + if (actor.Info.Name == "pbox") { - var closestAlliedBuilding = ClosestAlliedBuilding(firstUnit, 40); - if (closestAlliedBuilding != null) - foreach (var unit in idleSovietUnitsAtRP) - { - unit.Trait().Nudge(unit, unit, true); - unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3))); - } + actor.AddTrait(new TransformedAction(s => s.Trait().Load(s, world.CreateActor(false, "e1", allies2, null, null)))); + actor.QueueActivity(new Transform(actor, "hbox.e1") { SkipMakeAnims = true }); } + if (actor.Info.Name == "proc") + actor.QueueActivity(new Transform(actor, "proc") { SkipMakeAnims = true }); + foreach (var c in actor.TraitsImplementing()) + c.OnCapture(actor, actor, allies, allies2); } - - var idleSovietUnits = world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20) - .Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait()); - - foreach (var unit in idleSovietUnits) - { - var closestAlliedBuilding = ClosestAlliedBuilding(unit, 40); - - if (closestAlliedBuilding != null) - unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3))); - } - } - - Actor ClosestAlliedBuilding(Actor actor, int range) - { - return MissionUtils.ClosestPlayerBuilding(world, allies2, actor.CenterLocation, range); - } - - IEnumerable ClosestAlliedBuildings(Actor actor, int range) - { - return MissionUtils.ClosestPlayerBuildings(world, allies2, actor.CenterLocation, range); } void InitializeSovietFactories() @@ -365,7 +340,7 @@ namespace OpenRA.Mods.RA.Missions var sbrp = sovietBarracks.Trait(); var swrp = sovietWarFactory.Trait(); sbrp.rallyPoint = swrp.rallyPoint = sovietRallyPoint.Location; - sbrp.nearEnough = swrp.nearEnough = 3; + sbrp.nearEnough = swrp.nearEnough = 6; sovietBarracks.Trait().SetPrimaryProducer(sovietBarracks, true); sovietWarFactory.Trait().SetPrimaryProducer(sovietWarFactory, true); } @@ -378,11 +353,6 @@ namespace OpenRA.Mods.RA.Missions queue.ResolveOrder(queue.self, Order.StartProduction(queue.self, unit, 1)); } - void SpawnSignalFlare() - { - world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies1), new LocationInit(extractionLZ.Location) }); - } - void StartReinforcementsTimer() { Sound.Play("timergo1.aud"); @@ -409,38 +379,6 @@ namespace OpenRA.Mods.RA.Missions .QueueActivity(new Move.Move(allies2BasePoint.Location)); } - void RushSovietUnits() - { - var closestAlliedBuildings = ClosestAlliedBuildings(badgerDropPoint1, 40); - if (!closestAlliedBuildings.Any()) return; - - foreach (var tank in Tanks) - { - var unit = world.CreateActor(tank, new TypeDictionary - { - new OwnerInit(soviets), - new LocationInit(tanksEntryPoint.Location) - }); - foreach (var building in closestAlliedBuildings) - unit.QueueActivity(new Attack(Target.FromActor(building), 3)); - } - } - - void RushSovietFlamers() - { - var closestAlliedBuilding = ClosestAlliedBuilding(badgerDropPoint1, 40); - if (closestAlliedBuilding == null) return; - - var apc = world.CreateActor(ApcName, new TypeDictionary { new OwnerInit(soviets), new LocationInit(flamersEntryPoint.Location) }); - foreach (var flamer in Flamers) - { - var unit = world.CreateActor(false, flamer, new TypeDictionary { new OwnerInit(soviets) }); - apc.Trait().Load(apc, unit); - } - apc.QueueActivity(new MoveAdjacentTo(Target.FromActor(closestAlliedBuilding))); - apc.QueueActivity(new UnloadCargo(true)); - } - void ExtractEinsteinAtLZ() { einsteinChinook = MissionUtils.ExtractUnitWithChinook( @@ -461,7 +399,7 @@ namespace OpenRA.Mods.RA.Missions void TransferTownUnitsToAllies() { foreach (var unit in world.FindAliveNonCombatantActorsInCircle(townPoint.CenterLocation, AlliedTownTransferRange) - .Where(a => a.HasTrait())) + .Where(a => a.HasTrait())) unit.ChangeOwner(allies1); } @@ -492,11 +430,14 @@ namespace OpenRA.Mods.RA.Missions allies = w.Players.Single(p => p.InternalName == "Allies"); soviets = w.Players.Single(p => p.InternalName == "Soviets"); + soviets.PlayerActor.Trait().Cash = 1000; + var actors = w.WorldActor.Trait().Actors; sam1 = actors["SAM1"]; sam2 = actors["SAM2"]; sam3 = actors["SAM3"]; sam4 = actors["SAM4"]; + sams = new[] { sam1, sam2, sam3, sam4 }; tanya = actors["Tanya"]; einstein = actors["Einstein"]; engineer = actors["Engineer"]; @@ -515,17 +456,15 @@ namespace OpenRA.Mods.RA.Missions sovietBarracks = actors["SovietBarracks"]; sovietWarFactory = actors["SovietWarFactory"]; sovietRallyPoint = actors["SovietRallyPoint"]; - flamersEntryPoint = actors["FlamersEntryPoint"]; - tanksEntryPoint = actors["TanksEntryPoint"]; townPoint = actors["TownPoint"]; sovietTownAttackPoint1 = actors["SovietTownAttackPoint1"]; sovietTownAttackPoint2 = actors["SovietTownAttackPoint2"]; yakEntryPoint = actors["YakEntryPoint"]; yakAttackPoint = actors["YakAttackPoint"]; - SetupAlliedBase(actors); + SetupAlliedBase(); - var shroud = w.WorldActor.Trait(); + var shroud = allies1.Shroud; shroud.Explore(w, sam1.Location, 2); shroud.Explore(w, sam2.Location, 2); shroud.Explore(w, sam3.Location, 2); @@ -539,20 +478,5 @@ namespace OpenRA.Mods.RA.Missions MissionUtils.PlayMissionMusic(); } - - void SetupAlliedBase(Dictionary actors) - { - world.AddFrameEndTask(w => - { - foreach (var actor in actors.Where(a => a.Value.Owner == allies)) - actor.Value.ChangeOwner(allies2); - - world.CreateActor("proc", new TypeDictionary - { - new LocationInit(actors["Allies2ProcPoint"].Location), - new OwnerInit(allies2) - }); - }); - } } } diff --git a/OpenRA.Mods.RA/Missions/Allies04Script.cs b/OpenRA.Mods.RA/Missions/Allies04Script.cs index d04525e0aa..39f4c92f0b 100644 --- a/OpenRA.Mods.RA/Missions/Allies04Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies04Script.cs @@ -10,12 +10,14 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using OpenRA.FileFormats; using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Render; +using OpenRA.Graphics; using OpenRA.Traits; using OpenRA.Widgets; @@ -488,19 +490,21 @@ namespace OpenRA.Mods.RA.Missions public override object Create(ActorInitializer init) { return new Allies04RenderHijacked(init.self, this); } } - class Allies04RenderHijacked : RenderUnit, IRenderModifier + class Allies04RenderHijacked : RenderUnit { Allies04Hijackable hijackable; + Allies04RenderHijackedInfo info; public Allies04RenderHijacked(Actor self, Allies04RenderHijackedInfo info) : base(self) { + this.info = info; hijackable = self.Trait(); } - public IEnumerable ModifyRender(Actor self, IEnumerable r) + protected override string PaletteName(Actor self) { - return r.Select(a => a.WithPalette(Palette(hijackable.OldOwner))); + return info.Palette ?? info.PlayerPalette + hijackable.OldOwner.InternalName; } } @@ -533,4 +537,27 @@ namespace OpenRA.Mods.RA.Missions } class Allies04TransformOnLabInfiltrate { } + + class Allies04HazyPaletteEffectInfo : TraitInfo { } + + class Allies04HazyPaletteEffect : IPaletteModifier + { + static readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "fog", "shroud" }; + + public void AdjustPalette(Dictionary palettes) + { + foreach (var pal in palettes) + { + if (ExcludePalettes.Contains(pal.Key)) + continue; + + for (var x = 0; x < 256; x++) + { + var from = pal.Value.GetColor(x); + var to = Color.FromArgb(from.A, Color.FromKnownColor(KnownColor.DarkOrange)); + pal.Value.SetColor(x, Exts.ColorLerp(0.15f, from, to)); + } + } + } + } } diff --git a/OpenRA.Mods.RA/Missions/MissionUtils.cs b/OpenRA.Mods.RA/Missions/MissionUtils.cs index 12557b98bd..885d2b810f 100644 --- a/OpenRA.Mods.RA/Missions/MissionUtils.cs +++ b/OpenRA.Mods.RA/Missions/MissionUtils.cs @@ -109,30 +109,6 @@ namespace OpenRA.Mods.RA.Missions return units.Any() && units.All(a => a.Owner == player); } - public static Actor ClosestPlayerUnit(World world, Player player, PPos location, int range) - { - return ClosestPlayerUnits(world, player, location, range).FirstOrDefault(); - } - - public static IEnumerable ClosestPlayerUnits(World world, Player player, PPos location, int range) - { - return world.FindAliveCombatantActorsInCircle(location, range) - .Where(a => a.Owner == player && a.HasTrait()) - .OrderBy(a => (location - a.CenterLocation).LengthSquared); - } - - public static Actor ClosestPlayerBuilding(World world, Player player, PPos location, int range) - { - return ClosestPlayerBuildings(world, player, location, range).FirstOrDefault(); - } - - public static IEnumerable ClosestPlayerBuildings(World world, Player player, PPos location, int range) - { - return world.FindAliveCombatantActorsInCircle(location, range) - .Where(a => a.Owner == player && a.HasTrait() && !a.HasTrait()) - .OrderBy(a => (location - a.CenterLocation).LengthSquared); - } - public static IEnumerable FindQueues(World world, Player player, string category) { return world.ActorsWithTrait() @@ -231,7 +207,7 @@ namespace OpenRA.Mods.RA.Missions public static void AttackNearestLandActor(bool queued, Actor self, Player enemyPlayer) { var enemies = self.World.Actors.Where(u => u.AppearsHostileTo(self) && u.Owner == enemyPlayer - && ((u.HasTrait() && !u.HasTrait()) || u.HasTrait()) && u.IsInWorld && !u.IsDead()); + && ((u.HasTrait() && !u.HasTrait()) || (u.HasTrait() && !u.HasTrait())) && u.IsInWorld && !u.IsDead()); var enemy = enemies.OrderBy(u => (self.CenterLocation - u.CenterLocation).LengthSquared).FirstOrDefault(); if (enemy != null) diff --git a/OpenRA.Mods.RA/Missions/MonsterTankMadnessScript.cs b/OpenRA.Mods.RA/Missions/MonsterTankMadnessScript.cs index b4f6344786..7570160b19 100644 --- a/OpenRA.Mods.RA/Missions/MonsterTankMadnessScript.cs +++ b/OpenRA.Mods.RA/Missions/MonsterTankMadnessScript.cs @@ -8,13 +8,13 @@ */ #endregion +using System; +using System.Collections.Generic; +using System.Linq; using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Move; using OpenRA.Traits; -using System; -using System.Collections.Generic; -using System.Linq; namespace OpenRA.Mods.RA.Missions { @@ -137,11 +137,10 @@ namespace OpenRA.Mods.RA.Missions if (baseTransferredTick == -1) { - var actorsInBase = world.FindUnits(alliedBaseTopLeft.CenterLocation, alliedBaseBottomRight.CenterLocation).Where(a => !a.IsDead() && a.IsInWorld); + var actorsInBase = world.FindUnits(alliedBaseTopLeft.CenterLocation, alliedBaseBottomRight.CenterLocation).Where(a => a != a.Owner.PlayerActor); if (actorsInBase.Any(a => a.Owner == greece)) { - foreach (var actor in actorsInBase) - TransferActorToAllies(actor); + SetupAlliedBase(actorsInBase); baseTransferredTick = world.FrameNumber; objectives[FindOutpostID].Status = ObjectiveStatus.Completed; OnObjectivesUpdated(true); @@ -234,20 +233,22 @@ namespace OpenRA.Mods.RA.Missions } } - void TransferActorToAllies(Actor actor) + void SetupAlliedBase(IEnumerable actors) { - // hack hack hack - actor.ChangeOwner(greece); - if (actor.Info.Name == "pbox") + foreach (var actor in actors) { - actor.AddTrait(new TransformedAction(s => s.Trait().Load(s, world.CreateActor(false, "e1", greece, null, null)))); - actor.QueueActivity(new Transform(actor, "hbox.e1") { SkipMakeAnims = true }); + // hack hack hack + actor.ChangeOwner(greece); + if (actor.Info.Name == "pbox") + { + actor.AddTrait(new TransformedAction(s => s.Trait().Load(s, world.CreateActor(false, "e1", greece, null, null)))); + actor.QueueActivity(new Transform(actor, "hbox.e1") { SkipMakeAnims = true }); + } + else if (actor.Info.Name == "proc") + actor.QueueActivity(new Transform(actor, "proc") { SkipMakeAnims = true }); + foreach (var c in actor.TraitsImplementing()) + c.OnCapture(actor, actor, neutral, greece); } - else if (actor.Info.Name == "proc.nofreeactor") - actor.QueueActivity(new Transform(actor, "proc") { SkipMakeAnims = true }); - var building = actor.TraitOrDefault(); - if (building != null) - building.OnCapture(actor, actor, neutral, greece); } void EvacuateCivilians() diff --git a/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs b/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs index 9354c46672..c4f823be48 100644 --- a/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs +++ b/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -24,7 +25,7 @@ namespace OpenRA.Mods.RA } Renderable[] cache = { }; - public IEnumerable ModifyRender(Actor self, IEnumerable r) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { if (IsVisible(self.World.RenderedShroud, self)) cache = r.ToArray(); diff --git a/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs b/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs index 865cf7effb..cba548f4e4 100644 --- a/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs +++ b/OpenRA.Mods.RA/Modifiers/HiddenUnderFog.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -24,7 +25,7 @@ namespace OpenRA.Mods.RA } static Renderable[] Nothing = { }; - public IEnumerable ModifyRender(Actor self, IEnumerable r) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { return IsVisible(self.World.RenderedShroud, self) ? r : Nothing; } diff --git a/OpenRA.Mods.RA/NukePaletteEffect.cs b/OpenRA.Mods.RA/NukePaletteEffect.cs index 3e463fdd11..21215ee546 100644 --- a/OpenRA.Mods.RA/NukePaletteEffect.cs +++ b/OpenRA.Mods.RA/NukePaletteEffect.cs @@ -32,8 +32,6 @@ namespace OpenRA.Mods.RA if (remainingFrames > 0) remainingFrames--; } - - static List excludePalettes = new List{ "cursor", "chrome", "colorpicker", "shroud", "fog" }; public void AdjustPalette(Dictionary palettes) { @@ -44,9 +42,6 @@ namespace OpenRA.Mods.RA foreach (var pal in palettes) { - if (excludePalettes.Contains(pal.Key)) - continue; - for (var x = 0; x < 256; x++) { var orig = pal.Value.GetColor(x); diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index baed6d3c4d..353821fbd6 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -169,7 +169,6 @@ - @@ -408,6 +407,8 @@ + + diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs index 8864ae20ae..d630adba81 100755 --- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs @@ -21,9 +21,10 @@ namespace OpenRA.Mods.RA.Orders { readonly Actor Producer; readonly string Building; - readonly IEnumerable Preview; readonly BuildingInfo BuildingInfo; + IEnumerable preview; Sprite buildOk, buildBlocked; + bool initialized = false; public PlaceBuildingOrderGenerator(Actor producer, string name) { @@ -31,9 +32,6 @@ namespace OpenRA.Mods.RA.Orders Building = name; BuildingInfo = Rules.Info[Building].Traits.Get(); - Preview = Rules.Info[Building].Traits.Get() - .RenderPreview(Rules.Info[Building], producer.Owner); - buildOk = SequenceProvider.GetSequence("overlay", "build-valid").GetSprite(0); buildBlocked = SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0); } @@ -43,7 +41,7 @@ namespace OpenRA.Mods.RA.Orders if (mi.Button == MouseButton.Right) world.CancelInputMode(); - var ret = InnerOrder( world, xy, mi ).ToList(); + var ret = InnerOrder(world, xy, mi).ToList(); if (ret.Count > 0) world.CancelInputMode(); @@ -54,26 +52,26 @@ namespace OpenRA.Mods.RA.Orders { if (mi.Button == MouseButton.Left) { - var topLeft = xy - FootprintUtils.AdjustForBuildingSize( BuildingInfo ); - if (!world.CanPlaceBuilding( Building, BuildingInfo, topLeft, null) + var topLeft = xy - FootprintUtils.AdjustForBuildingSize(BuildingInfo); + if (!world.CanPlaceBuilding(Building, BuildingInfo, topLeft, null) || !BuildingInfo.IsCloseEnoughToBase(world, Producer.Owner, Building, topLeft)) { Sound.PlayNotification(Producer.Owner, "Speech", "BuildingCannotPlaceAudio", Producer.Owner.Country.Race); yield break; } - var isLineBuild = Rules.Info[ Building ].Traits.Contains(); + var isLineBuild = Rules.Info[Building].Traits.Contains(); yield return new Order(isLineBuild ? "LineBuild" : "PlaceBuilding", Producer.Owner.PlayerActor, false) { TargetLocation = topLeft, TargetString = Building }; } } - public void Tick( World world ) {} - public void RenderAfterWorld( WorldRenderer wr, World world ) {} - public void RenderBeforeWorld( WorldRenderer wr, World world ) + public void Tick(World world) {} + public void RenderAfterWorld(WorldRenderer wr, World world) {} + public void RenderBeforeWorld(WorldRenderer wr, World world) { var position = Game.viewport.ViewToWorld(Viewport.LastMousePos); - var topLeft = position - FootprintUtils.AdjustForBuildingSize( BuildingInfo ); + var topLeft = position - FootprintUtils.AdjustForBuildingSize(BuildingInfo); var actorInfo = Rules.Info[Building]; foreach (var dec in actorInfo.Traits.WithInterface()) @@ -84,24 +82,34 @@ namespace OpenRA.Mods.RA.Orders // Assumes a 1x1 footprint; weird things will happen for other footprints if (Rules.Info[Building].Traits.Contains()) { - foreach( var t in BuildingUtils.GetLineBuildCells( world, topLeft, Building, BuildingInfo ) ) - cells.Add( t, BuildingInfo.IsCloseEnoughToBase( world, world.LocalPlayer, Building, t ) ); + foreach (var t in BuildingUtils.GetLineBuildCells(world, topLeft, Building, BuildingInfo)) + cells.Add(t, BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, t)); } else { - foreach (var r in Preview) + if (!initialized) + { + var rbi = Rules.Info[Building].Traits.Get(); + var palette = rbi.Palette ?? (Producer.Owner != null ? + rbi.PlayerPalette + Producer.Owner.InternalName : null); + + preview = rbi.RenderPreview(Rules.Info[Building], wr.Palette(palette)); + initialized = true; + } + + foreach (var r in preview) r.Sprite.DrawAt(topLeft.ToPPos().ToFloat2() + r.Pos, - wr.GetPaletteIndex(r.Palette), + r.Palette.Index, r.Scale*r.Sprite.size); var res = world.WorldActor.Trait(); var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft); foreach (var t in FootprintUtils.Tiles(Building, BuildingInfo, topLeft)) - cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null ); + cells.Add(t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null); } - foreach( var c in cells ) - ( c.Value ? buildOk : buildBlocked ).DrawAt(wr, c.Key.ToPPos().ToFloat2(), "terrain" ); + foreach (var c in cells) + (c.Value ? buildOk : buildBlocked).DrawAt(wr, c.Key.ToPPos().ToFloat2(), "terrain"); } public string GetCursor(World world, CPos xy, MouseInput mi) { return "default"; } diff --git a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs index f98af6175c..8c045aef07 100644 --- a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs +++ b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs @@ -17,6 +17,7 @@ namespace OpenRA.Mods.RA { public readonly string Name = null; public readonly int[] ShadowIndex = { }; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PaletteFromCurrentTileset(init.world, this); } } @@ -32,9 +33,9 @@ namespace OpenRA.Mods.RA this.info = info; } - public void InitPalette( OpenRA.Graphics.WorldRenderer wr ) + public void InitPalette(OpenRA.Graphics.WorldRenderer wr) { - wr.AddPalette( info.Name, new Palette( FileSystem.Open( world.TileSet.Palette ), info.ShadowIndex ) ); + wr.AddPalette(info.Name, new Palette(FileSystem.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/PaletteFromFile.cs b/OpenRA.Mods.RA/PaletteFromFile.cs index 94706ea61e..6a60aa8d67 100644 --- a/OpenRA.Mods.RA/PaletteFromFile.cs +++ b/OpenRA.Mods.RA/PaletteFromFile.cs @@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA public readonly string Tileset = null; public readonly string Filename = null; public readonly int[] ShadowIndex = { }; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PaletteFromFile(init.world, this); } } @@ -34,10 +35,10 @@ namespace OpenRA.Mods.RA this.info = info; } - public void InitPalette( WorldRenderer wr ) + public void InitPalette(WorldRenderer wr) { - if( info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant() ) - wr.AddPalette( info.Name, new Palette( FileSystem.Open( info.Filename ), info.ShadowIndex ) ); + if (info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant()) + wr.AddPalette(info.Name, new Palette(FileSystem.Open(info.Filename), info.ShadowIndex), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/PaletteFromRGBA.cs b/OpenRA.Mods.RA/PaletteFromRGBA.cs index 95ebef6905..4f8a33c14f 100644 --- a/OpenRA.Mods.RA/PaletteFromRGBA.cs +++ b/OpenRA.Mods.RA/PaletteFromRGBA.cs @@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA public readonly int G = 0; public readonly int B = 0; public readonly int A = 255; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PaletteFromRGBA(init.world, this); } } @@ -37,28 +38,14 @@ namespace OpenRA.Mods.RA this.info = info; } - public void InitPalette( WorldRenderer wr ) + public void InitPalette(WorldRenderer wr) { - if (info.Tileset == null || info.Tileset.ToLowerInvariant() == world.Map.Tileset.ToLowerInvariant()) - { - // TODO: This shouldn't rely on a base palette - var pal = wr.GetPalette("terrain"); - wr.AddPalette(info.Name, new Palette(pal, new SingleColorRemap(Color.FromArgb(info.A, info.R, info.G, info.B)))); - } - } - } + // Enable palette only for a specific tileset + if (info.Tileset != null && info.Tileset.ToLowerInvariant() != world.Map.Tileset.ToLowerInvariant()) + return; - class SingleColorRemap : IPaletteRemap - { - Color c; - public SingleColorRemap(Color c) - { - this.c = c; - } - - public Color GetRemappedColor(Color original, int index) - { - return original.A > 0 ? c : original; + var c = (uint)((info.A << 24) | (info.R << 16) | (info.G << 8) | info.B); + wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (i == 0) ? 0 : c)), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/ParaDrop.cs b/OpenRA.Mods.RA/ParaDrop.cs index 1759c12cab..07788b529a 100644 --- a/OpenRA.Mods.RA/ParaDrop.cs +++ b/OpenRA.Mods.RA/ParaDrop.cs @@ -55,11 +55,9 @@ namespace OpenRA.Mods.RA var aircraft = self.Trait(); self.World.AddFrameEndTask(w => w.Add( - new Parachute( - self.Owner, + new Parachute(a, Util.CenterOfCell(self.CenterLocation.ToCPos()), - aircraft.Altitude, a - ) + aircraft.Altitude) )); Sound.Play(info.ChuteSound, self.CenterLocation); diff --git a/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs b/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs index 2315236f30..a28fac7522 100644 --- a/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs +++ b/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs @@ -17,6 +17,7 @@ namespace OpenRA.Mods.RA { public readonly string Name = null; public readonly int[] ShadowIndex = { }; + public readonly bool AllowModifiers = true; public object Create(ActorInitializer init) { return new PlayerPaletteFromCurrentTileset(init.world, this); } } @@ -35,7 +36,7 @@ namespace OpenRA.Mods.RA public void InitPalette (OpenRA.Graphics.WorldRenderer wr) { string Filename = world.TileSet.PlayerPalette == null ? world.TileSet.Palette : world.TileSet.PlayerPalette; - wr.AddPalette(info.Name, new Palette(FileSystem.Open(Filename), info.ShadowIndex)); + wr.AddPalette(info.Name, new Palette(FileSystem.Open(Filename), info.ShadowIndex), info.AllowModifiers); } } } diff --git a/OpenRA.Mods.RA/RallyPoint.cs b/OpenRA.Mods.RA/RallyPoint.cs index ba1c410200..7286f0eb1a 100755 --- a/OpenRA.Mods.RA/RallyPoint.cs +++ b/OpenRA.Mods.RA/RallyPoint.cs @@ -14,11 +14,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class RallyPointInfo : ITraitInfo, Requires + public class RallyPointInfo : ITraitInfo { public readonly int[] RallyPoint = { 1, 3 }; + public readonly string IndicatorPalettePrefix = "player"; - public object Create(ActorInitializer init) { return new RallyPoint(init.self); } + public object Create(ActorInitializer init) { return new RallyPoint(init.self, this); } } public class RallyPoint : IIssueOrder, IResolveOrder, ISync @@ -26,11 +27,10 @@ namespace OpenRA.Mods.RA [Sync] public CPos rallyPoint; public int nearEnough = 1; - public RallyPoint(Actor self) + public RallyPoint(Actor self, RallyPointInfo info) { - var info = self.Info.Traits.Get(); rallyPoint = self.Location + new CVec(info.RallyPoint[0], info.RallyPoint[1]); - self.World.AddFrameEndTask(w => w.Add(new Effects.RallyPoint(self))); + self.World.AddFrameEndTask(w => w.Add(new Effects.RallyPoint(self, info.IndicatorPalettePrefix))); } public IEnumerable Orders diff --git a/OpenRA.Mods.RA/Render/RenderBuilding.cs b/OpenRA.Mods.RA/Render/RenderBuilding.cs index 1977b314d1..ce7711bd7c 100755 --- a/OpenRA.Mods.RA/Render/RenderBuilding.cs +++ b/OpenRA.Mods.RA/Render/RenderBuilding.cs @@ -25,9 +25,9 @@ namespace OpenRA.Mods.RA.Render public readonly float2 Origin = float2.Zero; public override object Create(ActorInitializer init) { return new RenderBuilding(init, this);} - public override IEnumerable RenderPreview(ActorInfo building, Player owner) + public override IEnumerable RenderPreview(ActorInfo building, PaletteReference pr) { - return base.RenderPreview(building, owner) + return base.RenderPreview(building, pr) .Select(a => a.WithPos(a.Pos + building.Traits.Get().Origin)); } } @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Render self.QueueActivity(new CallFunc(() => Complete(self))); } - public IEnumerable ModifyRender(Actor self, IEnumerable r) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { var disabled = self.IsDisabled(); foreach (var a in r) @@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Render var ret = a.WithPos(a.Pos - Info.Origin); yield return ret; if (disabled) - yield return ret.WithPalette("disabled").WithZOffset(1); + yield return ret.WithPalette(wr.Palette("disabled")).WithZOffset(1); } } diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs b/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs index 83a1d1e738..aba2eb45cb 100755 --- a/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs @@ -20,21 +20,22 @@ namespace OpenRA.Mods.RA.Render public override object Create(ActorInitializer init) { return new RenderBuildingWarFactory( init, this ); } /* get around unverifiability */ - IEnumerable BaseBuildingPreview(ActorInfo building, Player owner) + IEnumerable BaseBuildingPreview(ActorInfo building, PaletteReference pr) { - return base.RenderPreview(building, owner); + return base.RenderPreview(building, pr); } - public override IEnumerable RenderPreview(ActorInfo building, Player owner) + public override IEnumerable RenderPreview(ActorInfo building, PaletteReference pr) { - var p = BaseBuildingPreview(building, owner); + var p = BaseBuildingPreview(building, pr); foreach (var r in p) yield return r; var anim = new Animation(RenderSimple.GetImage(building), () => 0); anim.PlayRepeating("idle-top"); var rb = building.Traits.Get(); - yield return new Renderable(anim.Image, rb.Origin + 0.5f*anim.Image.size*(1 - Scale), p.First().Palette, 0, Scale); + yield return new Renderable(anim.Image, rb.Origin + 0.5f*anim.Image.size*(1 - Scale), + pr, 0, Scale); } } diff --git a/OpenRA.Mods.RA/Render/RenderEditorOnly.cs b/OpenRA.Mods.RA/Render/RenderEditorOnly.cs index 9339f58d4c..4f2825fb8a 100644 --- a/OpenRA.Mods.RA/Render/RenderEditorOnly.cs +++ b/OpenRA.Mods.RA/Render/RenderEditorOnly.cs @@ -9,6 +9,7 @@ #endregion using System.Collections.Generic; +using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Render @@ -23,6 +24,6 @@ namespace OpenRA.Mods.RA.Render public RenderEditorOnly(Actor self) : base(self, () => 0) { } static readonly Renderable[] Nothing = { }; - public override IEnumerable Render(Actor self) { return Nothing; } + public override IEnumerable Render(Actor self, WorldRenderer wr) { return Nothing; } } } diff --git a/OpenRA.Mods.RA/Render/RenderInfantry.cs b/OpenRA.Mods.RA/Render/RenderInfantry.cs index bba5c0a611..a0d7df1b9b 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantry.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantry.cs @@ -124,10 +124,16 @@ namespace OpenRA.Mods.RA.Render return; Sound.PlayVoice("Die", self, self.Owner.Country.Race); + SpawnCorpse(self, "die{0}".F(e.Warhead.InfDeath)); + } + + public void SpawnCorpse(Actor self, string sequence) + { self.World.AddFrameEndTask(w => { if (!self.Destroyed) - w.Add(new Corpse(self, "die{0}".F(e.Warhead.InfDeath))); + w.Add(new Corpse(w, self.CenterLocation.ToFloat2(), GetImage(self), + sequence, Info.PlayerPalette+self.Owner.InternalName)); }); } } diff --git a/OpenRA.Mods.RA/Render/RenderSpy.cs b/OpenRA.Mods.RA/Render/RenderSpy.cs index 80a571ae08..966401cd68 100755 --- a/OpenRA.Mods.RA/Render/RenderSpy.cs +++ b/OpenRA.Mods.RA/Render/RenderSpy.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; using OpenRA.Mods.RA.Orders; @@ -20,20 +21,23 @@ namespace OpenRA.Mods.RA.Render public override object Create(ActorInitializer init) { return new RenderSpy(init.self, this); } } - class RenderSpy : RenderInfantryProne, IRenderModifier + class RenderSpy : RenderInfantryProne { + RenderSpyInfo info; string disguisedAsSprite; Spy spy; public RenderSpy(Actor self, RenderSpyInfo info) : base(self, info) { + this.info = info; spy = self.Trait(); disguisedAsSprite = spy.disguisedAsSprite; } - public IEnumerable ModifyRender(Actor self, IEnumerable r) + protected override string PaletteName(Actor self) { - return spy.disguisedAsPlayer != null ? r.Select(a => a.WithPalette(Palette(spy.disguisedAsPlayer))) : r; + var player = spy.disguisedAsPlayer != null ? spy.disguisedAsPlayer : self.Owner; + return info.Palette ?? info.PlayerPalette + player.InternalName; } public override void Tick(Actor self) @@ -45,6 +49,7 @@ namespace OpenRA.Mods.RA.Render anim.ChangeImage(disguisedAsSprite, "stand"); else anim.ChangeImage(GetImage(self), "stand"); + UpdatePalette(); } base.Tick(self); } diff --git a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs index aead118204..084b48156f 100644 --- a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs @@ -57,11 +57,11 @@ namespace OpenRA.Mods.RA.Render mf.Animation.PlayThen("muzzle", () => isShowing = false); } - public IEnumerable Render(Actor self) + public IEnumerable Render(Actor self, WorldRenderer wr) { foreach (var a in muzzleFlashes.Values) if (a.DisableFunc == null || !a.DisableFunc()) - yield return a.Image(self, "effect"); + yield return a.Image(self, wr.Palette("effect")); } public void Tick(Actor self) diff --git a/OpenRA.Mods.RA/Render/WithShadow.cs b/OpenRA.Mods.RA/Render/WithShadow.cs index 1419dd0d8a..76ddf84515 100644 --- a/OpenRA.Mods.RA/Render/WithShadow.cs +++ b/OpenRA.Mods.RA/Render/WithShadow.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenRA.Graphics; using OpenRA.Traits; using OpenRA.Mods.RA.Air; using OpenRA.Mods.RA.Move; @@ -21,7 +22,7 @@ namespace OpenRA.Mods.RA.Render class WithShadow : IRenderModifier { - public IEnumerable ModifyRender(Actor self, IEnumerable r) + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { var move = self.Trait(); @@ -29,7 +30,7 @@ namespace OpenRA.Mods.RA.Render var visualOffset = ((move is Helicopter || move is Mobile) && move.Altitude > 0) ? Math.Abs((self.ActorID + Game.LocalTick) / 5 % 4 - 1) - 1 : 0; - var shadowSprites = r.Select(a => a.WithPalette("shadow")); + var shadowSprites = r.Select(a => a.WithPalette(wr.Palette("shadow"))); var flyingSprites = (move.Altitude <= 0) ? r : r.Select(a => a.WithPos(a.Pos - new float2(0, move.Altitude + visualOffset)).WithZOffset(move.Altitude + a.ZOffset)); diff --git a/OpenRA.Mods.RA/RenderRangeCircle.cs b/OpenRA.Mods.RA/RenderRangeCircle.cs index 10e9192681..d1b6642d39 100644 --- a/OpenRA.Mods.RA/RenderRangeCircle.cs +++ b/OpenRA.Mods.RA/RenderRangeCircle.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA wr.DrawRangeCircle( Color.FromArgb(128, Color.Yellow), - self.CenterLocation.ToFloat2(), (int)self.Trait().GetMaximumRange()); + self.CenterLocation.ToFloat2(), self.Trait().GetMaximumRange()); } } } diff --git a/OpenRA.Mods.RA/RenderShroudCircle.cs b/OpenRA.Mods.RA/RenderShroudCircle.cs index 7ed26059a2..02c9a90bde 100644 --- a/OpenRA.Mods.RA/RenderShroudCircle.cs +++ b/OpenRA.Mods.RA/RenderShroudCircle.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA wr.DrawRangeCircle( Color.FromArgb(128, Color.Cyan), - self.CenterLocation.ToFloat2(), (int)self.Info.Traits.Get().Range); + self.CenterLocation.ToFloat2(), self.Info.Traits.Get().Range); } } } diff --git a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs index 3d645c162e..1530fcb925 100644 --- a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs @@ -230,7 +230,7 @@ namespace OpenRA.Mods.RA.Server var hue = (byte)server.Random.Next(255); var sat = (byte)server.Random.Next(255); var lum = (byte)server.Random.Next(51,255); - bot.ColorRamp = new ColorRamp(hue, sat, lum, 10); + bot.ColorRamp = bot.PreferredColorRamp = new ColorRamp(hue, sat, lum, 10); server.lobbyInfo.Clients.Add(bot); } @@ -318,6 +318,19 @@ namespace OpenRA.Mods.RA.Server server.SyncLobbyInfo(); return true; }}, + { "crates", + s => + { + if (!client.IsAdmin) + { + server.SendChatTo(conn, "Only the host can set that option"); + return true; + } + + bool.TryParse(s, out server.lobbyInfo.GlobalSettings.Crates); + server.SyncLobbyInfo(); + return true; + }}, { "difficulty", s => { @@ -459,7 +472,7 @@ namespace OpenRA.Mods.RA.Server return true; var ci = parts[1].Split(',').Select(cc => int.Parse(cc)).ToArray(); - targetClient.ColorRamp = new ColorRamp((byte)ci[0], (byte)ci[1], (byte)ci[2], (byte)ci[3]); + targetClient.ColorRamp = targetClient.PreferredColorRamp = new ColorRamp((byte)ci[0], (byte)ci[1], (byte)ci[2], (byte)ci[3]); server.SyncLobbyInfo(); return true; }} diff --git a/OpenRA.Mods.RA/ShroudPalette.cs b/OpenRA.Mods.RA/ShroudPalette.cs index f8015a979a..5437a1987f 100644 --- a/OpenRA.Mods.RA/ShroudPalette.cs +++ b/OpenRA.Mods.RA/ShroudPalette.cs @@ -18,8 +18,6 @@ namespace OpenRA.Mods.RA class ShroudPaletteInfo : ITraitInfo { public readonly string Name = "shroud"; - public readonly bool IsFog = false; - public object Create(ActorInitializer init) { return new ShroudPalette(this); } } @@ -27,38 +25,20 @@ namespace OpenRA.Mods.RA { readonly ShroudPaletteInfo info; - public ShroudPalette( ShroudPaletteInfo info ) { this.info = info; } + public ShroudPalette(ShroudPaletteInfo info) { this.info = info; } - public void InitPalette( WorldRenderer wr ) + public void InitPalette(WorldRenderer wr) { - var pal = wr.GetPalette( "terrain" ); - wr.AddPalette( info.Name, new Palette( pal, new ShroudPaletteRemap( info.IsFog ) ) ); - } - } + var c = new[] { + Color.Transparent, Color.Green, + Color.Blue, Color.Yellow, + Color.Black, + Color.FromArgb(128,0,0,0), + Color.Transparent, + Color.Transparent + }; - class ShroudPaletteRemap : IPaletteRemap - { - bool isFog; - - public ShroudPaletteRemap(bool isFog) { this.isFog = isFog; } - public Color GetRemappedColor(Color original, int index) - { - if (isFog) - return new[] { - Color.Transparent, Color.Green, - Color.Blue, Color.Yellow, - Color.FromArgb(128,0,0,0), - Color.FromArgb(128,0,0,0), - Color.FromArgb(128,0,0,0), - Color.FromArgb(64,0,0,0)}[index % 8]; - else - return new[] { - Color.Transparent, Color.Green, - Color.Blue, Color.Yellow, - Color.Black, - Color.FromArgb(128,0,0,0), - Color.Transparent, - Color.Transparent}[index % 8]; + wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (uint)c[i % 8].ToArgb())), false); } } } diff --git a/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs b/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs index df6ac6f6bb..70419e5d24 100644 --- a/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs +++ b/OpenRA.Mods.RA/SmokeTrailWhenDamaged.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA { var facing = self.Trait(); var altitude = new PVecInt(0, move.Altitude); - position = (self.CenterLocation - Combat.GetTurretPosition(self, facing, smokeTurret)); + position = (self.CenterLocation - (PVecInt)Combat.GetTurretPosition(self, facing, smokeTurret).ToInt2()); if (self.World.RenderedShroud.IsVisible(position.ToCPos())) self.World.AddFrameEndTask( diff --git a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs index 2700551d8f..b4459b961b 100755 --- a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs @@ -243,9 +243,9 @@ namespace OpenRA.Mods.RA { if (manager.self.Owner.Shroud.IsTargetable(unit)) { var targetCell = unit.Location + (xy - sourceLocation); - foreach (var r in unit.Render()) + foreach (var r in unit.Render(wr)) r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location).ToFloat2() + Traits.Util.CenterOfCell(targetCell).ToFloat2(), - wr.GetPaletteIndex(r.Palette), + r.Palette.Index, r.Scale*r.Sprite.size); } } diff --git a/OpenRA.Mods.RA/WaterPaletteRotation.cs b/OpenRA.Mods.RA/WaterPaletteRotation.cs index 9a3aedf454..a8a24127c1 100644 --- a/OpenRA.Mods.RA/WaterPaletteRotation.cs +++ b/OpenRA.Mods.RA/WaterPaletteRotation.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA { class WaterPaletteRotationInfo : ITraitInfo { - public readonly string[] ExcludePalettes = { "cursor", "chrome", "colorpicker", "player" }; + public readonly string[] ExcludePalettes = {}; public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.world, this); } } diff --git a/OpenRA.Mods.RA/Weapon.cs b/OpenRA.Mods.RA/Weapon.cs index ecee503ad6..606df63f75 100644 --- a/OpenRA.Mods.RA/Weapon.cs +++ b/OpenRA.Mods.RA/Weapon.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.RA firedBy = self, target = target, - src = (self.CenterLocation + Combat.GetBarrelPosition(self, facing, Turret, barrel)), + src = (self.CenterLocation + (PVecInt)Combat.GetBarrelPosition(self, facing, Turret, barrel).ToInt2()), srcAltitude = move != null ? move.Altitude : 0, dest = target.CenterLocation, destAltitude = destMove != null ? destMove.Altitude : 0, @@ -148,7 +148,7 @@ namespace OpenRA.Mods.RA if (projectile != null) self.World.Add(projectile); - if (args.weapon.Report != null) + if (args.weapon.Report != null && args.weapon.Report.Any()) Sound.Play(args.weapon.Report.Random(self.World.SharedRandom) + ".aud", self.CenterLocation); } }); diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs index f0cdaa6517..0ec408ecf6 100755 --- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs @@ -145,7 +145,7 @@ namespace OpenRA.Mods.RA.Widgets public override bool HandleKeyPress(KeyInput e) { if (e.Event == KeyInputEvent.Up) return false; - if (e.KeyName == "tab") + if (e.KeyName == Game.Settings.Keys.CycleTabsKey) { TabChange(e.Modifiers.HasModifier(Modifiers.Shift)); return true; diff --git a/OpenRA.Mods.RA/Widgets/ColorPreviewManagerWidget.cs b/OpenRA.Mods.RA/Widgets/ColorPreviewManagerWidget.cs new file mode 100755 index 0000000000..78562d1236 --- /dev/null +++ b/OpenRA.Mods.RA/Widgets/ColorPreviewManagerWidget.cs @@ -0,0 +1,54 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ + +#endregion + +using System; +using System.Linq; +using OpenRA.FileFormats; +using OpenRA.Graphics; +using OpenRA.Traits; +using OpenRA.Widgets; + +namespace OpenRA.Mods.RA.Widgets +{ + public class ColorPreviewManagerWidget : Widget + { + public readonly string Palette = "colorpicker"; + public readonly int[] RemapIndices = {}; + public ColorRamp Ramp; + + ColorRamp cachedRamp; + WorldRenderer worldRenderer; + Palette preview; + + [ObjectCreator.UseCtor] + public ColorPreviewManagerWidget(WorldRenderer worldRenderer) + : base() + { + this.worldRenderer = worldRenderer; + } + + public override void Initialize(WidgetArgs args) + { + base.Initialize(args); + preview = worldRenderer.Palette(Palette).Palette; + } + + public override void Tick() + { + if (cachedRamp == Ramp) + return; + + preview.ApplyRemap(new PlayerColorRemap(RemapIndices, Ramp)); + cachedRamp = Ramp; + } + } +} + diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index 3029766a98..70428ef9f3 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic string MapUid; Map Map; - ColorPickerPaletteModifier PlayerPalettePreview; + ColorPreviewManagerWidget colorPreview; readonly Action OnGameStart; readonly Action onExit; @@ -96,8 +96,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic Game.ConnectionStateChanged += ConnectionStateChanged; UpdateCurrentMap(); - PlayerPalettePreview = world.WorldActor.Trait(); - PlayerPalettePreview.Ramp = Game.Settings.Player.ColorRamp; Players = lobby.Get("PLAYERS"); EditablePlayerTemplate = Players.Get("TEMPLATE_EDITABLE_PLAYER"); NonEditablePlayerTemplate = Players.Get("TEMPLATE_NONEDITABLE_PLAYER"); @@ -105,6 +103,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic EditableSpectatorTemplate = Players.Get("TEMPLATE_EDITABLE_SPECTATOR"); NonEditableSpectatorTemplate = Players.Get("TEMPLATE_NONEDITABLE_SPECTATOR"); NewSpectatorTemplate = Players.Get("TEMPLATE_NEW_SPECTATOR"); + colorPreview = lobby.Get("COLOR_MANAGER"); + colorPreview.Ramp = Game.Settings.Player.ColorRamp; var mapPreview = lobby.Get("MAP_PREVIEW"); mapPreview.IsVisible = () => Map != null; @@ -169,6 +169,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); + var crates = lobby.GetOrNull("CRATES_CHECKBOX"); + if (crates != null) + { + crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates; + crates.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null + || orderManager.LocalClient.IsReady; // maybe disable the checkbox if a map forcefully removes CrateDrop? + crates.OnClick = () => orderManager.IssueOrder(Order.Command( + "crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates))); + } + var difficulty = lobby.GetOrNull("DIFFICULTY_DROPDOWNBUTTON"); if (difficulty != null) { @@ -354,7 +364,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var color = template.Get("COLOR"); color.IsDisabled = () => slot.LockColor || ready; - color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, client, orderManager, PlayerPalettePreview); + color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, client, orderManager, colorPreview); var colorBlock = color.Get("COLORBLOCK"); colorBlock.GetColor = () => client.ColorRamp.GetColor(0); @@ -434,7 +444,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var color = template.Get("COLOR"); color.IsDisabled = () => ready; - color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, PlayerPalettePreview); + color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, colorPreview); var colorBlock = color.Get("COLORBLOCK"); colorBlock.GetColor = () => c.ColorRamp.GetColor(0); diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs index fd0ab270f2..c04e295525 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs @@ -121,7 +121,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic } public static void ShowColorDropDown(DropDownButtonWidget color, Session.Client client, - OrderManager orderManager, ColorPickerPaletteModifier preview) + OrderManager orderManager, ColorPreviewManagerWidget preview) { Action onSelect = c => { @@ -183,9 +183,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic var client = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == spawnPoint); if (client != null) { - var rect = new Rectangle(position.X, position.Y, Game.Renderer.Fonts["Regular"].Measure(client.Name).X + 15, 25); - WidgetUtils.DrawPanel("dialog4", rect); - Game.Renderer.Fonts["Regular"].DrawText(client.Name, position + new int2(5, 5), Color.White); + Game.Renderer.Fonts["Bold"].DrawTextWithContrast(client.Name, position + new int2(5, 5), Color.White, Color.Black, 1); } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs index 0cd5eb5d78..5b7ca6436f 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs @@ -156,7 +156,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic players.Select(p => new LineGraphSeries( p.PlayerName, p.ColorRamp.GetColor(0), - p.PlayerActor.Trait().EarnedSamples.Select(s => (float)s) + (p.PlayerActor.TraitOrDefault() ?? new PlayerStatistics(p.PlayerActor)).EarnedSamples.Select(s => (float)s) )); playerStatsPanel.AddChild(template); @@ -187,10 +187,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic AddPlayerFlagAndName(template, player); - var stats = player.PlayerActor.Trait(); + var stats = player.PlayerActor.TraitOrDefault(); + if (stats == null) return template; template.Get("CONTROL").GetText = () => MapControl(stats.MapControl); - template.Get("KILLS_COST").GetText = () => "$" + stats.KillsCost.ToString(); - template.Get("DEATHS_COST").GetText = () => "$" + stats.DeathsCost.ToString(); + template.Get("KILLS_COST").GetText = () => "$" + stats.KillsCost; + template.Get("DEATHS_COST").GetText = () => "$" + stats.DeathsCost; template.Get("UNITS_KILLED").GetText = () => stats.UnitsKilled.ToString(); template.Get("UNITS_DEAD").GetText = () => stats.UnitsDead.ToString(); template.Get("BUILDINGS_KILLED").GetText = () => stats.BuildingsKilled.ToString(); @@ -220,7 +221,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic AddPlayerFlagAndName(template, player); var res = player.PlayerActor.Trait(); - var stats = player.PlayerActor.Trait(); + var stats = player.PlayerActor.TraitOrDefault(); + if (stats == null) return template; template.Get("CASH").GetText = () => "$" + (res.DisplayCash + res.DisplayOre); template.Get("EARNED_MIN").GetText = () => AverageEarnedPerMinute(res.Earned); @@ -258,7 +260,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic template.Get("KILLS").GetText = () => player.Kills.ToString(); template.Get("DEATHS").GetText = () => player.Deaths.ToString(); - var stats = player.PlayerActor.Trait(); + var stats = player.PlayerActor.TraitOrDefault(); + if (stats == null) return template; template.Get("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount); return template; diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs index d6b4b847f4..5846ddd6ce 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs @@ -30,6 +30,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic tabs.Get("GENERAL").OnClick = () => FlipToTab("GENERAL_PANE"); tabs.Get("AUDIO").OnClick = () => FlipToTab("AUDIO_PANE"); tabs.Get("DISPLAY").OnClick = () => FlipToTab("DISPLAY_PANE"); + tabs.Get("KEYS").OnClick = () => FlipToTab("KEYS_PANE"); tabs.Get("DEBUG").OnClick = () => FlipToTab("DEBUG_PANE"); FlipToTab("GENERAL_PANE"); @@ -120,6 +121,60 @@ namespace OpenRA.Mods.RA.Widgets.Logic Game.viewport.Zoom = gs.PixelDouble ? 2 : 1; }; + // Keys + var keys = bg.Get("KEYS_PANE"); + var keyConfig = Game.Settings.Keys; + + var specialHotkeyList = keys.Get("SPECIALHOTKEY_LIST"); + var specialHotkeyTemplate = specialHotkeyList.Get("SPECIALHOTKEY_TEMPLATE"); + + var pauseKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(pauseKey, "Pause the game:", () => keyConfig.PauseKey, k => keyConfig.PauseKey = k); + specialHotkeyList.AddChild(pauseKey); + + var viewportToBase = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(viewportToBase, "Move Viewport to Base:", () => keyConfig.CycleBaseKey, k => keyConfig.CycleBaseKey = k); + specialHotkeyList.AddChild(viewportToBase); + + var lastEventKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(lastEventKey, "Move Viewport to Last Event:", () => keyConfig.GotoLastEventKey, k => keyConfig.GotoLastEventKey = k); + specialHotkeyList.AddChild(lastEventKey); + + var sellKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(sellKey, "Switch to Sell-Cursor:", () => keyConfig.SellKey, k => keyConfig.SellKey = k); + specialHotkeyList.AddChild(sellKey); + + var powerDownKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(powerDownKey, "Switch to Power-Down-Cursor:", () => keyConfig.PowerDownKey, k => keyConfig.PowerDownKey = k); + specialHotkeyList.AddChild(powerDownKey); + + var repairKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(repairKey, "Switch to Repair-Cursor:", () => keyConfig.RepairKey, k => keyConfig.RepairKey = k); + specialHotkeyList.AddChild(repairKey); + + var unitCommandHotkeyList = keys.Get("UNITCOMMANDHOTKEY_LIST"); + var unitCommandHotkeyTemplate = unitCommandHotkeyList.Get("UNITCOMMANDHOTKEY_TEMPLATE"); + + var attackKey = ScrollItemWidget.Setup(unitCommandHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(attackKey, "Attack Move:", () => keyConfig.AttackMoveKey, k => keyConfig.AttackMoveKey = k); + unitCommandHotkeyList.AddChild(attackKey); + + var stopKey = ScrollItemWidget.Setup(unitCommandHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(stopKey, "Stop:", () => keyConfig.StopKey, k => keyConfig.StopKey = k); + unitCommandHotkeyList.AddChild(stopKey); + + var scatterKey = ScrollItemWidget.Setup(unitCommandHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(scatterKey, "Scatter:", () => keyConfig.ScatterKey, k => keyConfig.ScatterKey = k); + unitCommandHotkeyList.AddChild(scatterKey); + + var stanceCycleKey = ScrollItemWidget.Setup(unitCommandHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(stanceCycleKey, "Cycle Stance:", () => keyConfig.StanceCycleKey, k => keyConfig.StanceCycleKey = k); + unitCommandHotkeyList.AddChild(stanceCycleKey); + + var deployKey = ScrollItemWidget.Setup(unitCommandHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(deployKey, "Deploy:", () => keyConfig.DeployKey, k => keyConfig.DeployKey = k); + unitCommandHotkeyList.AddChild(deployKey); + // Debug var debug = bg.Get("DEBUG_PANE"); @@ -199,6 +254,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic return true; } + void SetupKeyBinding(ScrollItemWidget keyWidget, string description, Func getValue, Action setValue) + { + keyWidget.Get("FUNCTION").GetText = () => description; + + var textBox = keyWidget.Get("HOTKEY"); + + textBox.Text = getValue(); + + textBox.OnLoseFocus = () => + { + textBox.Text.Trim(); + if (textBox.Text.Length == 0) + textBox.Text = getValue(); + else + setValue(textBox.Text); + }; + + textBox.OnEnterKey = () => { textBox.LoseFocus(); return true; }; + } + public static bool ShowRendererDropdown(DropDownButtonWidget dropdown, GraphicSettings s) { var options = new Dictionary() diff --git a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs index 3c1262e4a6..b40b9f6890 100644 --- a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs @@ -16,6 +16,7 @@ using OpenRA.Graphics; using OpenRA.Network; using OpenRA.Orders; using OpenRA.Widgets; +using OpenRA.Mods.RA.Orders; namespace OpenRA.Mods.RA.Widgets { @@ -23,14 +24,6 @@ namespace OpenRA.Mods.RA.Widgets { public World World { get { return OrderManager.world; } } - public string AttackMoveKey = "a"; - public string StopKey = "s"; - public string ScatterKey = "x"; - public string DeployKey = "f"; - public string StanceCycleKey = "z"; - public string BaseCycleKey = "backspace"; - public string GotoLastEventKey = "space"; - public readonly OrderManager OrderManager; [ObjectCreator.UseCtor] @@ -51,28 +44,37 @@ namespace OpenRA.Mods.RA.Widgets { if (e.Modifiers == Modifiers.None && e.Event == KeyInputEvent.Down) { - if (e.KeyName == BaseCycleKey) + if (e.KeyName == Game.Settings.Keys.CycleBaseKey) return CycleBases(); - if (e.KeyName == GotoLastEventKey) + if (e.KeyName == Game.Settings.Keys.GotoLastEventKey) return GotoLastEvent(); - if (!World.Selection.Actors.Any()) + if (e.KeyName == Game.Settings.Keys.SellKey) + return PerformSwitchToSellMode(); + + if (e.KeyName == Game.Settings.Keys.PowerDownKey) + return PerformSwitchToPowerDownMode(); + + if (e.KeyName == Game.Settings.Keys.RepairKey) + return PerformSwitchToRepairMode(); + + if (!World.Selection.Actors.Any()) // Put all functions, that are no unit-functions, before this line! return false; - if (e.KeyName == AttackMoveKey) + if (e.KeyName == Game.Settings.Keys.AttackMoveKey) return PerformAttackMove(); - if (e.KeyName == StopKey) + if (e.KeyName == Game.Settings.Keys.StopKey) return PerformStop(); - if (e.KeyName == ScatterKey) + if (e.KeyName == Game.Settings.Keys.ScatterKey) return PerformScatter(); - if (e.KeyName == DeployKey) + if (e.KeyName == Game.Settings.Keys.DeployKey) return PerformDeploy(); - if (e.KeyName == StanceCycleKey) + if (e.KeyName == Game.Settings.Keys.StanceCycleKey) return PerformStanceCycle(); } @@ -115,10 +117,11 @@ namespace OpenRA.Mods.RA.Widgets bool PerformDeploy() { - /* hack: three orders here -- ReturnToBase, DeployTransform, Unload. */ + /* hack: multiple orders here */ PerformKeyboardOrderOnSelection(a => new Order("ReturnToBase", a, false)); PerformKeyboardOrderOnSelection(a => new Order("DeployTransform", a, false)); PerformKeyboardOrderOnSelection(a => new Order("Unload", a, false)); + PerformKeyboardOrderOnSelection(a => new Order("DemoDeploy", a, false)); return true; } @@ -184,5 +187,23 @@ namespace OpenRA.Mods.RA.Widgets Game.viewport.Center(eventNotifier.lastAttackLocation.ToFloat2()); return true; } + + bool PerformSwitchToSellMode() + { + World.ToggleInputMode(); + return true; + } + + bool PerformSwitchToPowerDownMode() + { + World.ToggleInputMode(); + return true; + } + + bool PerformSwitchToRepairMode() + { + World.ToggleInputMode(); + return true; + } } } diff --git a/cg/chrome-line.fx b/cg/chrome-line.fx deleted file mode 100644 index ede4851f47..0000000000 --- a/cg/chrome-line.fx +++ /dev/null @@ -1,55 +0,0 @@ -// OpenRA gui lines shader -// Author: C. Forbes -//-------------------------------------------------------- - -float2 r1, r2; // matrix elements - -struct VertexIn { - float4 Position: POSITION; - float4 Color: TEXCOORD0; -}; - -struct VertexOut { - float4 Position: POSITION; - float4 Color: COLOR0; -}; - -VertexOut Simple_vp(VertexIn v) { - VertexOut o; - float2 p = v.Position.xy * r1 + r2; - o.Position = float4(p.x,p.y,0,1); - o.Color = v.Color; - return o; -} - -float4 Simple_fp(VertexOut f) : COLOR0 { - return f.Color; -} - -technique high_quality { - pass p0 { - BlendEnable = true; - DepthTestEnable = false; - //CullMode = None; - //FillMode = Wireframe; - VertexProgram = compile latest Simple_vp(); - FragmentProgram = compile latest Simple_fp(); - - BlendEquation = FuncAdd; - BlendFunc = int2( SrcAlpha, OneMinusSrcAlpha ); - } -} - -technique high_quality_cg21 { - pass p0 { - BlendEnable = true; - DepthTestEnable = false; - //CullMode = None; - //FillMode = Wireframe; - VertexProgram = compile arbvp1 Simple_vp(); - FragmentProgram = compile arbfp1 Simple_fp(); - - BlendEquation = FuncAdd; - BlendFunc = int2( SrcAlpha, OneMinusSrcAlpha ); - } -} \ No newline at end of file diff --git a/cg/chrome-shp.fx b/cg/chrome-shp.fx deleted file mode 100644 index 750d8c9a6c..0000000000 --- a/cg/chrome-shp.fx +++ /dev/null @@ -1,80 +0,0 @@ -// OpenRA test shader -// Author: C. Forbes -//-------------------------------------------------------- - -float2 Scroll; -float2 r1, r2; // matrix elements - -sampler2D DiffuseTexture = sampler_state { - MinFilter = Nearest; - MagFilter = Nearest; - WrapS = Repeat; - WrapT = Repeat; -}; - -sampler2D Palette = sampler_state { - MinFilter = Nearest; - MagFilter = Nearest; - WrapS = Repeat; - WrapT = Repeat; -}; - -struct VertexIn { - float4 Position: POSITION; - float4 Tex0: TEXCOORD0; -}; - -struct VertexOut { - float4 Position: POSITION; - float3 Tex0: TEXCOORD0; - float4 ChannelMask: TEXCOORD1; -}; - -float4 DecodeChannelMask( float x ) -{ - if (x > 0) - return (x > 0.5f) ? float4(1,0,0,0) : float4(0,1,0,0); - else - return (x <-0.5f) ? float4(0,0,0,1) : float4(0,0,1,0); -} - -VertexOut Simple_vp(VertexIn v) { - VertexOut o; - float2 p = v.Position.xy * r1 + r2; - o.Position = float4(p.x,p.y,0,1); - o.Tex0 = float3(v.Tex0.x, v.Tex0.y, v.Tex0.z); - o.ChannelMask = DecodeChannelMask( v.Tex0.w ); - return o; -} - -float4 Palette_fp(VertexOut f) : COLOR0 { - float4 x = tex2D(DiffuseTexture, f.Tex0.xy); - float2 p = float2( dot(x, f.ChannelMask), f.Tex0.z ); - return tex2D(Palette, p); -} - -technique low_quality { - pass p0 { - BlendEnable = true; - DepthTestEnable = false; - CullFaceEnable = false; - VertexProgram = compile latest Simple_vp(); - FragmentProgram = compile latest Palette_fp(); - - BlendEquation = FuncAdd; - BlendFunc = int2( SrcAlpha, OneMinusSrcAlpha ); - } -} - -technique low_quality_cg21 { - pass p0 { - BlendEnable = true; - DepthTestEnable = false; - CullFaceEnable = false; - VertexProgram = compile arbvp1 Simple_vp(); - FragmentProgram = compile arbfp1 Palette_fp(); - - BlendEquation = FuncAdd; - BlendFunc = int2( SrcAlpha, OneMinusSrcAlpha ); - } -} diff --git a/cg/world-line.fx b/cg/line.fx similarity index 100% rename from cg/world-line.fx rename to cg/line.fx diff --git a/cg/chrome-rgba.fx b/cg/rgba.fx similarity index 100% rename from cg/chrome-rgba.fx rename to cg/rgba.fx diff --git a/cg/world-shp.fx b/cg/shp.fx similarity index 100% rename from cg/world-shp.fx rename to cg/shp.fx diff --git a/glsl/chrome-line.vert b/glsl/chrome-line.vert deleted file mode 100644 index 8c1d357cc0..0000000000 --- a/glsl/chrome-line.vert +++ /dev/null @@ -1,7 +0,0 @@ -uniform vec2 r1, r2; // matrix elements -void main() -{ - vec2 p = gl_Vertex.xy*r1 + r2; - gl_Position = vec4(p.x,p.y,0,1); - gl_FrontColor = gl_MultiTexCoord0; -} diff --git a/glsl/chrome-shp.vert b/glsl/chrome-shp.vert deleted file mode 100644 index 8541b53f1e..0000000000 --- a/glsl/chrome-shp.vert +++ /dev/null @@ -1,17 +0,0 @@ -uniform vec2 r1,r2; // matrix elements - -vec4 DecodeChannelMask( float x ) -{ - if (x > 0.0) - return (x > 0.5) ? vec4(1,0,0,0) : vec4(0,1,0,0); - else - return (x < -0.5) ? vec4(0,0,0,1) : vec4(0,0,1,0); -} - -void main() -{ - vec2 p = gl_Vertex.xy*r1 + r2; - gl_Position = vec4(p.x,p.y,0,1); - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_TexCoord[1] = DecodeChannelMask(gl_MultiTexCoord0.w); -} diff --git a/glsl/chrome-line.frag b/glsl/line.frag similarity index 100% rename from glsl/chrome-line.frag rename to glsl/line.frag diff --git a/glsl/world-line.vert b/glsl/line.vert similarity index 100% rename from glsl/world-line.vert rename to glsl/line.vert diff --git a/glsl/chrome-rgba.frag b/glsl/rgba.frag similarity index 100% rename from glsl/chrome-rgba.frag rename to glsl/rgba.frag diff --git a/glsl/chrome-rgba.vert b/glsl/rgba.vert similarity index 100% rename from glsl/chrome-rgba.vert rename to glsl/rgba.vert diff --git a/glsl/chrome-shp.frag b/glsl/shp.frag similarity index 100% rename from glsl/chrome-shp.frag rename to glsl/shp.frag diff --git a/glsl/world-shp.vert b/glsl/shp.vert similarity index 100% rename from glsl/world-shp.vert rename to glsl/shp.vert diff --git a/glsl/world-line.frag b/glsl/world-line.frag deleted file mode 100644 index 3f45d895ff..0000000000 --- a/glsl/world-line.frag +++ /dev/null @@ -1,4 +0,0 @@ -void main() -{ - gl_FragColor = gl_Color; -} \ No newline at end of file diff --git a/glsl/world-shp.frag b/glsl/world-shp.frag deleted file mode 100644 index dbabad7184..0000000000 --- a/glsl/world-shp.frag +++ /dev/null @@ -1,8 +0,0 @@ -uniform sampler2D DiffuseTexture, Palette; - -void main() -{ - vec4 x = texture2D(DiffuseTexture, gl_TexCoord[0].st); - vec2 p = vec2( dot(x, gl_TexCoord[1]), gl_TexCoord[0].p ); - gl_FragColor = texture2D(Palette,p); -} \ No newline at end of file diff --git a/mods/cnc/chrome/lobby.yaml b/mods/cnc/chrome/lobby.yaml index ae731e3584..ff2cb1bb77 100644 --- a/mods/cnc/chrome/lobby.yaml +++ b/mods/cnc/chrome/lobby.yaml @@ -5,6 +5,8 @@ Container@SERVER_LOBBY: Width:740 Height:535 Children: + ColorPreviewManager@COLOR_MANAGER: + RemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 Label@TITLE: Width:740 Y:0-25 diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 7b97795882..64c6adda52 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -5,6 +5,8 @@ Container@SETTINGS_PANEL: Width:740 Height:535 Children: + ColorPreviewManager@COLOR_MANAGER: + RemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 Label@TITLE: Width:740 Y:0-25 diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 074c33a2ec..d45403031f 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -26,6 +26,7 @@ Packages: ~movies-nod.mix ~movies.mix ~scores.mix + ~scores2.mix ~transit.mix Rules: diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index d92fb812af..45425a7fad 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -249,6 +249,7 @@ Sellable: Capturable: CapturableBar: + C4Demolishable: ^CivBuilding: Inherits: ^Building @@ -336,6 +337,7 @@ RelativeToTopLeft: yes AutoTargetIgnore: Sellable: + C4Demolishable: ^Tree: Tooltip: diff --git a/mods/cnc/rules/infantry.yaml b/mods/cnc/rules/infantry.yaml index 45366b0abb..779e4ab6ab 100644 --- a/mods/cnc/rules/infantry.yaml +++ b/mods/cnc/rules/infantry.yaml @@ -19,6 +19,8 @@ E1: PrimaryWeapon: M16 RenderInfantryProne: IdleAnimations: idle1,idle2,idle3,idle4 + DetectCloaked: + Range: 2 E2: Inherits: ^Infantry @@ -46,7 +48,10 @@ E2: IdleAnimations: idle1,idle2 Explodes: Weapon: GrenadierExplode + EmptyWeapon: GrenadierExplode Chance: 50 + DetectCloaked: + Range: 2 E3: Inherits: ^Infantry @@ -71,6 +76,8 @@ E3: FireDelay: 5 RenderInfantryProne: IdleAnimations: idle1,idle2 + DetectCloaked: + Range: 2 E4: Inherits: ^Infantry @@ -97,6 +104,8 @@ E4: WithMuzzleFlash: RenderInfantryProne: IdleAnimations: idle1,idle2 + DetectCloaked: + Range: 2 E5: Inherits: ^Infantry @@ -129,6 +138,8 @@ E5: -PoisonedByTiberium: RenderInfantryProne: IdleAnimations: idle1,idle2 + DetectCloaked: + Range: 2 E6: Inherits: ^Infantry @@ -192,6 +203,8 @@ RMBO: IdleAnimations: idle1,idle2,idle3 AnnounceOnBuild: AnnounceOnKill: + DetectCloaked: + Range: 2 PVICE: Inherits:VICE @@ -210,4 +223,4 @@ PVICE: Selectable: Voice: DinoVoice ActorLostNotification: - Notification: unitlost.aud \ No newline at end of file + Notification: unitlost.aud diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index e6e0f254f5..8077a05040 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -123,8 +123,6 @@ PROC: Bounds: 73,72 CustomSellValue: Value: 300 - CustomBuildTimeValue: - Value: 80 FreeActor: Actor: HARV InitialActivity: FindResources @@ -259,7 +257,7 @@ AFLD: Footprint: xxxx xxxx Dimensions: 4,2 Health: - HP: 1750 + HP: 1500 RevealsShroud: Range: 7 Bib: @@ -372,7 +370,7 @@ HQ: Footprint: x_ xx Dimensions: 2,2 Health: - HP: 1000 + HP: 750 RevealsShroud: Range: 10 Bib: @@ -382,7 +380,7 @@ HQ: Range: 8 AirstrikePower: Image: bombicnh - ChargeTime: 240 + ChargeTime: 180 Description: Air Strike LongDesc: Deploy an aerial napalm strike.\nBurns buildings and infantry along a line. EndChargeSound: airredy1.aud @@ -594,6 +592,7 @@ OBLI: Turreted: ROT:255 AutoTarget: + -AutoTargetIgnore: -RenderBuilding: RenderRangeCircle: -EmitInfantryOnSell: diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 07b00d814b..bff230f4ab 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -80,6 +80,11 @@ World: Name: effect Filename: temperat.pal ShadowIndex: 4 + PaletteFromFile@colorpicker: + Name: colorpicker + Filename: temperat.pal + ShadowIndex: 4 + AllowModifiers: false PaletteFromRGBA@shadow: Name: shadow R: 0 @@ -104,11 +109,8 @@ World: G: 0 B: 0 A: 180 - ColorPickerPaletteModifier: - ShroudPalette@shroud: - ShroudPalette@fog: - IsFog: yes - Name: fog + ShroudPalette: + FogPalette: Country@gdi: Name: GDI Race: gdi diff --git a/mods/cnc/sequences/misc.yaml b/mods/cnc/sequences/misc.yaml index 272df55451..fbb4ebf640 100644 --- a/mods/cnc/sequences/misc.yaml +++ b/mods/cnc/sequences/misc.yaml @@ -85,16 +85,49 @@ explosion: 8: art-exp1 Start: 0 Length: * - building: fball1 - Start: 0 - Length: * 6: atomsfx Start: 0 Length: * 6w: atomsfx Start: 0 Length: * - chemball: chemball + piff: piff + Start: 0 + Length: * + piffs: piffpiff + Start: 0 + Length: * + chemball: chemball #same size as small_napalm, but bright green. + Start: 0 + Length: * + small_napalm: napalm1 #not used by much. currently used for flamethrower. + Start: 0 + Length: * + med_napalm: napalm2 #explosion for bomblets + Start: 0 + Length: * + big_napalm: napalm3 #huge; not used. (SSM used this explosion in C&C Gold?) + Start: 0 + Length: * + small_frag: veh-hit3 #the most common weapon-hit explosion. For rockets, tank shells, etc. + Start: 0 + Length: * + med_frag: frag1 #fragmentation-style; quite large. (MLRS used this explosion in C&C Gold?) + Start: 0 + Length: * + big_frag: frag3 #Same as med_frag, except fire hangs around longer. + Start: 0 + Length: * + small_poof: veh-hit2 #for Grenades; tower missiles; boat missiles; APC AA gun. + Start: 0 + Length: * + poof: art-exp1 #For UnitExplode (artillery); artillery shell hit; GrenadierExplode, + Start: 0 + Length: * + small_building: veh-hit1 #like "building' explosion, but much smaller. (Used for heli-explosion in C&C Gold?) + Start: 0 + Length: * + building: fball1 #Large explosion, for when a building explodes. Start: 0 Length: * diff --git a/mods/cnc/sequences/structures.yaml b/mods/cnc/sequences/structures.yaml index d815088349..651805546d 100644 --- a/mods/cnc/sequences/structures.yaml +++ b/mods/cnc/sequences/structures.yaml @@ -5,11 +5,11 @@ fact: idle: Start: 0 Length: 4 - Tick: 80 + Tick: 100 damaged-idle: Start: 24 Length: 4 - Tick: 80 + Tick: 100 damaged-build: Start: 28 Length: 20 @@ -23,14 +23,14 @@ nuke: idle: Start: 0 Length: 4 - Tick: 400 + Tick: 1000 damaged-idle: Start: 4 Length: 4 - Tick: 400 + Tick: 1000 dead: Start: 8 - Tick: 400 + Tick: 1000 make: nukemake Start: 0 Length: * @@ -39,11 +39,11 @@ proc: idle: Start: 0 Length: 6 - Tick: 60 + Tick: 120 damaged-idle: Start: 30 Length: 6 - Tick: 60 + Tick: 120 dead: Start: 60 make: procmake @@ -84,11 +84,14 @@ pyle: idle: Start: 0 Length: 10 + Tick: 100 damaged-idle: Start: 10 Length: 10 + Tick: 100 dead: Start: 20 + Tick: 100 make: pylemake Start: 0 Length: * @@ -139,11 +142,11 @@ hq: idle: Start: 0 Length: 16 - Tick: 200 + Tick: 100 damaged-idle: Start: 16 Length: 16 - Tick: 200 + Tick: 100 dead: Start: 32 make: hqmake @@ -154,11 +157,11 @@ nuk2: idle: Start: 0 Length: 4 - Tick: 400 + Tick: 1000 damaged-idle: Start: 4 Length: 4 - Tick: 400 + Tick: 1000 dead: Start: 8 make: nuk2make @@ -173,9 +176,11 @@ hpad: active: Start: 1 Length: 6 + Tick: 100 damaged-active: Start: 8 Length: 6 + Tick: 100 dead: Start: 14 make: hpadmake @@ -203,11 +208,11 @@ eye: idle: Start: 0 Length: 16 - Tick: 200 + Tick: 100 damaged-idle: Start: 16 Length: 16 - Tick: 200 + Tick: 100 dead: Start: 32 make: eyemake diff --git a/mods/d2k/chrome/lobby.yaml b/mods/d2k/chrome/lobby.yaml index 65d6c6fcee..3e96577e50 100644 --- a/mods/d2k/chrome/lobby.yaml +++ b/mods/d2k/chrome/lobby.yaml @@ -5,6 +5,8 @@ Background@SERVER_LOBBY: Width:800 Height:600 Children: + ColorPreviewManager@COLOR_MANAGER: + RemapIndices: 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240 Label@TITLE: X:0 Y:17 diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 59861909bb..17715b1708 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -256,4 +256,5 @@ ProximityCaptor: Types:Building Sellable: - GivesBounty: \ No newline at end of file + GivesBounty: + C4Demolishable: \ No newline at end of file diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index e22bd4e6c4..8376d71d8f 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -269,6 +269,11 @@ World: Name: effect Filename: temperat.pal ShadowIndex: 4 + PaletteFromFile@colorpicker: + Name: colorpicker + Filename: d2k.pal + ShadowIndex: 4 + AllowModifiers: false PaletteFromRGBA@shadow: Name: shadow R: 0 @@ -299,11 +304,8 @@ World: G: 0 B: 0 A: 180 - ColorPickerPaletteModifier: - ShroudPalette@shroud: - ShroudPalette@fog: - IsFog: yes - Name: fog + ShroudPalette: + FogPalette: Country@Atreides: Name: Atreides Race: atreides diff --git a/mods/ra/chrome/lobby.yaml b/mods/ra/chrome/lobby.yaml index 60ab28fe8e..a4a9978196 100644 --- a/mods/ra/chrome/lobby.yaml +++ b/mods/ra/chrome/lobby.yaml @@ -5,6 +5,8 @@ Background@SERVER_LOBBY: Width:800 Height:600 Children: + ColorPreviewManager@COLOR_MANAGER: + RemapIndices: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 Label@TITLE: X:0 Y:17 @@ -432,9 +434,15 @@ Background@SERVER_LOBBY: Width: 80 Height: 20 Text: Allow Cheats + Checkbox@CRATES_CHECKBOX: + X: PARENT_RIGHT-154 + Y: PARENT_BOTTOM-154 + Width: 80 + Height: 20 + Text: Crates Button@DISCONNECT_BUTTON: X:PARENT_RIGHT-154 - Y:PARENT_BOTTOM-129 + Y:PARENT_BOTTOM-99 Width:120 Height:25 Text:Disconnect diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 22e831761f..b9113b01c9 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -2,13 +2,13 @@ Background@SETTINGS_MENU: Logic:SettingsMenuLogic X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM- HEIGHT)/2 - Width: 450 - Height: 350 + Width: 540 + Height: 400 Children: Label@SETTINGS_LABEL_TITLE: X:0 Y:20 - Width:450 + Width:540 Height:25 Text:Settings Align:Center @@ -48,11 +48,18 @@ Background@SETTINGS_MENU: Height:25 Text:Display Font:Bold - Button@DEBUG: + Button@KEYS: X:315 Y:0 Width:90 Height:25 + Text:Keys + Font:Bold + Button@DEBUG: + X:405 + Y:0 + Width:90 + Height:25 Text:Debug Font:Bold Container@GENERAL_PANE: @@ -228,6 +235,67 @@ Background@SETTINGS_MENU: Height:20 Font:Regular Text:Enable Pixel Doubling + Container@KEYS_PANE: + X:37 + Y:100 + Width:PARENT_RIGHT - 37 + Height:PARENT_BOTTOM - 100 + Visible: false + Children: + Label@KEYS_SPECIALHOTKEYSHEADLINE: + X:0 + Y:0 + Text: Special Hotkeys: + Font:Bold + ScrollPanel@SPECIALHOTKEY_LIST: + X:0 + Y:20 + Width:449 + Height:85 + Children: + ScrollItem@SPECIALHOTKEY_TEMPLATE: + Width:PARENT_RIGHT-27 + Height:25 + X:2 + Y:0 + Visible:false + Children: + Label@FUNCTION: + X:10 + Width:200 + Height:25 + TextField@HOTKEY: + X:250 + Width:139 + Height:25 + MaxLength:16 + Label@KEYS_UNITCOMMANDSHEADLINE: + X:0 + Y:130 + Text: Hotkeys for Unit Commands: + Font:Bold + ScrollPanel@UNITCOMMANDHOTKEY_LIST: + X:0 + Y:150 + Width:449 + Height:85 + Children: + ScrollItem@UNITCOMMANDHOTKEY_TEMPLATE: + Width:PARENT_RIGHT-27 + Height:25 + X:2 + Y:0 + Visible:false + Children: + Label@FUNCTION: + X:10 + Width:200 + Height:25 + TextField@HOTKEY: + X:250 + Width:139 + Height:25 + MaxLength:16 Container@DEBUG_PANE: X:37 Y:100 diff --git a/mods/ra/maps/allies-01/map.yaml b/mods/ra/maps/allies-01/map.yaml index d30a9406bf..3c66ce8b5c 100644 --- a/mods/ra/maps/allies-01/map.yaml +++ b/mods/ra/maps/allies-01/map.yaml @@ -359,7 +359,7 @@ Rules: Range: 0 E7: AutoTarget: - InitialStance: ReturnFire + InitialStance: Defend Passenger: Weight: 0 EINSTEIN: diff --git a/mods/ra/maps/allies-02/map.yaml b/mods/ra/maps/allies-02/map.yaml index e7733e6e99..8099ac25f9 100644 --- a/mods/ra/maps/allies-02/map.yaml +++ b/mods/ra/maps/allies-02/map.yaml @@ -852,9 +852,6 @@ Actors: Actor301: tc04 Location: 27,33 Owner: Neutral - Actor265: miss - Location: 27,23 - Owner: Soviets Actor402: brik Location: 22,67 Owner: Soviets @@ -1481,9 +1478,10 @@ Actors: Actor290: apwr Location: 52,42 Owner: Soviets - Allies2ProcPoint: waypoint + Actor875: proc Location: 25,95 Owner: Allies + FreeActor: False Actor455: fenc Location: 31,93 Owner: Allies @@ -1517,13 +1515,13 @@ Actors: Actor470: fenc Location: 26,93 Owner: Allies - Actor454: pbox.e1 + Actor454: pbox Location: 32,93 Owner: Allies Actor465: fenc Location: 30,93 Owner: Allies - Actor473: pbox.e1 + Actor473: pbox Location: 40,93 Owner: Allies Actor472: gun @@ -2877,7 +2875,7 @@ Rules: Damage: 0 E7: AutoTarget: - InitialStance: ReturnFire + InitialStance: Defend Passenger: Weight: 0 Buildable: @@ -3006,6 +3004,9 @@ Rules: CTNK: Buildable: Owner: None + MGG: + Buildable: + Owner: None CRATE: GiveCashCrateAction: SelectionShares: 0 diff --git a/mods/ra/maps/allies-04/map.yaml b/mods/ra/maps/allies-04/map.yaml index 9908e043f1..6ad7e412a1 100644 --- a/mods/ra/maps/allies-04/map.yaml +++ b/mods/ra/maps/allies-04/map.yaml @@ -1799,6 +1799,7 @@ Rules: -SpawnMPUnits: -MPStartLocations: Allies04Script: + Allies04HazyPaletteEffect: MissionObjectivesPanel: ObjectivesPanel: MISSION_OBJECTIVES ^Building: diff --git a/mods/ra/maps/monster-tank-madness/map.yaml b/mods/ra/maps/monster-tank-madness/map.yaml index 105a2e9d49..e00da1a10d 100644 --- a/mods/ra/maps/monster-tank-madness/map.yaml +++ b/mods/ra/maps/monster-tank-madness/map.yaml @@ -1754,11 +1754,12 @@ Actors: Owner: BadGuy Health: 1 Facing: 0 - AlliedBaseProc: proc.nofreeactor + AlliedBaseProc: proc Location: 27,25 Owner: Neutral Health: 0.3476563 Facing: 0 + FreeActor: False Actor508: silo Location: 36,18 Owner: Neutral @@ -2609,14 +2610,6 @@ Rules: RenderBuilding: Image: DOME -InfiltrateForExploration: - PROC.NoFreeActor: - Inherits: PROC - -Buildable: - RenderBuilding: - Image: PROC - Tooltip: - Icon: procicon - -FreeActor: V19: AutoTargetIgnore: TRAN: diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml index 6ce0cc9698..3afe7f176c 100644 --- a/mods/ra/rules/civilian.yaml +++ b/mods/ra/rules/civilian.yaml @@ -241,6 +241,9 @@ BARL: Tooltip: Name: Explosive Barrel AutoTargetIgnore: + Armor: + Type: Light + -C4Demolishable: BRL3: Inherits: ^TechBuilding @@ -253,6 +256,9 @@ BRL3: Tooltip: Name: Explosive Barrel AutoTargetIgnore: + Armor: + Type: Light + -C4Demolishable: MISS: Inherits: ^TechBuilding diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 390cdd7ed2..1ace9e750c 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -217,6 +217,7 @@ AcceptsSupplies: GivesBounty: UpdatesPlayerStatistics: + C4Demolishable: ^Wall: AppearsOnRadar: @@ -250,6 +251,7 @@ Types:Wall Sellable: UpdatesPlayerStatistics: + C4Demolishable: ^TechBuilding: Inherits: ^Building diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index d3245ddd48..36fc421ecf 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -224,6 +224,11 @@ World: Name: effect Filename: temperat.pal ShadowIndex: 4 + PaletteFromFile@colorpicker: + Name: colorpicker + Filename: temperat.pal + ShadowIndex: 4 + AllowModifiers: false PaletteFromRGBA@shadow: Name: shadow R: 0 @@ -254,11 +259,8 @@ World: G: 0 B: 0 A: 180 - ColorPickerPaletteModifier: - ShroudPalette@shroud: - ShroudPalette@fog: - IsFog: yes - Name: fog + ShroudPalette: + FogPalette: Country@0: Name: Allies Race: allies @@ -277,6 +279,7 @@ World: PipColor: Yellow AllowedTerrainTypes: Clear,Road AllowUnderActors: false + TerrainType: Ore ResourceType@gem: ResourceType: 2 Palette: player @@ -286,6 +289,7 @@ World: PipColor: Red AllowedTerrainTypes: Clear,Road AllowUnderActors: false + TerrainType: Gems SmudgeLayer@SCORCH: Type:Scorch SmokePercentage:50 diff --git a/mods/ra/tilesets/desert.yaml b/mods/ra/tilesets/desert.yaml index df57060819..1ba9d9a4e8 100644 --- a/mods/ra/tilesets/desert.yaml +++ b/mods/ra/tilesets/desert.yaml @@ -64,6 +64,10 @@ Terrain: Buildable: False AcceptsSmudgeType: Crater, Scorch Color: 148, 128, 96 + TerrainType@Gems: + Type: Gems + AcceptsSmudgeType: Crater, Scorch + Color: 132, 112, 255 Templates: Template@255: diff --git a/mods/ra/tilesets/interior.yaml b/mods/ra/tilesets/interior.yaml index de092f2004..30ddb2b4bb 100644 --- a/mods/ra/tilesets/interior.yaml +++ b/mods/ra/tilesets/interior.yaml @@ -46,6 +46,10 @@ Terrain: Type: Ore AcceptsSmudgeType: Crater, Scorch Color: 148, 128, 96 + TerrainType@Gems: + Type: Gems + AcceptsSmudgeType: Crater, Scorch + Color: 132, 112, 255 Templates: Template@255: diff --git a/mods/ra/tilesets/snow.yaml b/mods/ra/tilesets/snow.yaml index 776964d696..255f14e890 100644 --- a/mods/ra/tilesets/snow.yaml +++ b/mods/ra/tilesets/snow.yaml @@ -47,6 +47,10 @@ Terrain: Type: Ore AcceptsSmudgeType: Crater, Scorch Color: 148, 128, 96 + TerrainType@Gems: + Type: Gems + AcceptsSmudgeType: Crater, Scorch + Color: 132, 112, 255 Templates: Template@255: diff --git a/mods/ra/tilesets/temperat.yaml b/mods/ra/tilesets/temperat.yaml index 4f2c4706c3..17625ef86e 100644 --- a/mods/ra/tilesets/temperat.yaml +++ b/mods/ra/tilesets/temperat.yaml @@ -47,6 +47,10 @@ Terrain: Type: Ore AcceptsSmudgeType: Crater, Scorch Color: 148, 128, 96 + TerrainType@Gems: + Type: Gems + AcceptsSmudgeType: Crater, Scorch + Color: 132, 112, 255 Templates: Template@255: diff --git a/mods/ra/weapons.yaml b/mods/ra/weapons.yaml index b67eec369e..d015aefda3 100644 --- a/mods/ra/weapons.yaml +++ b/mods/ra/weapons.yaml @@ -7,11 +7,11 @@ Colt45: Warhead: Spread: 1 Versus: - Wood: 5% + Wood: 0% Light: 5% Heavy: 5% Cybernetic: 5% - Concrete: 5% + Concrete: 0% Explosion: piff InfDeath: 2 Damage: 50