From 56470b918ba3ac25b6a10007c7f391c2ff1e402b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 16 Feb 2014 21:57:17 +0100 Subject: [PATCH] use the disabled palette to render husks closes #4631 --- CHANGELOG | 2 ++ OpenRA.Mods.RA/Burns.cs | 1 + OpenRA.Mods.RA/Husk.cs | 8 ++++- OpenRA.Mods.RA/Modifiers/DisabledOverlay.cs | 36 +++++++++++++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + OpenRA.Mods.RA/Render/RenderBuilding.cs | 15 +-------- mods/cnc/rules/defaults.yaml | 1 + mods/cnc/rules/structures.yaml | 15 +++++---- mods/d2k/rules/atreides.yaml | 1 + mods/d2k/rules/defaults.yaml | 1 + mods/d2k/rules/harkonnen.yaml | 1 + mods/d2k/rules/ordos.yaml | 1 + mods/d2k/rules/structures.yaml | 3 ++ mods/ra/rules/defaults.yaml | 1 + mods/ra/rules/structures.yaml | 36 +++++++++++++-------- 15 files changed, 88 insertions(+), 35 deletions(-) create mode 100644 OpenRA.Mods.RA/Modifiers/DisabledOverlay.cs diff --git a/CHANGELOG b/CHANGELOG index 78695bb072..5ebe6adad8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ NEW: Added skirmish mode to RA and D2k to complement TD's skirmish mode. Added an Extras submenu for miscellaneous game extras. Engineers can now regain control over husks. + Husks are now rendered with a black overlay. A player's units, and allied units, now move out of the way when blocking production facilities. Added cheat button to grow map resources. Fixed units staying selected and contributing to control groups when becoming cloaked or hidden in fog. @@ -105,6 +106,7 @@ NEW: Mods that use custom TileSize must specify both width and height. If you spot black tiles in your Dune 2000 ARRAKIS maps, replace them with the remaining sand and rock tiles. Go to Map → Fix Open Areas to randomize them. The TestFile check in mod.yaml has been renamed to TestFiles (plural!) and now supports a comma-separated list of assets that are required to load the game. + DisabledOverlay has been split from RenderBuilding. Use it together with RequiresPower and CanPowerDown for buildings or directly with Husk. Packaging: Removed portable install option from Windows installer as the game left without write access breaks content download and error log generation. Added HTML documentation to the Windows installer. diff --git a/OpenRA.Mods.RA/Burns.cs b/OpenRA.Mods.RA/Burns.cs index 50a0cbd300..bac3079031 100644 --- a/OpenRA.Mods.RA/Burns.cs +++ b/OpenRA.Mods.RA/Burns.cs @@ -32,6 +32,7 @@ namespace OpenRA.Mods.RA Info = info; var anim = new Animation("fire", () => 0); + anim.IsDecoration = true; anim.PlayRepeating(Info.Anim); self.Trait().anims.Add("fire", anim); } diff --git a/OpenRA.Mods.RA/Husk.cs b/OpenRA.Mods.RA/Husk.cs index 1edae2eb39..bacd08e8fe 100644 --- a/OpenRA.Mods.RA/Husk.cs +++ b/OpenRA.Mods.RA/Husk.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; +using OpenRA.Graphics; using OpenRA.Mods.RA.Move; using OpenRA.Traits; @@ -25,7 +26,7 @@ namespace OpenRA.Mods.RA public int GetInitialFacing() { return 128; } } - class Husk : IPositionable, IFacing, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld + class Husk : IPositionable, IFacing, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld, IDisable { readonly HuskInfo info; readonly Actor self; @@ -100,6 +101,11 @@ namespace OpenRA.Mods.RA self.World.ActorMap.RemovePosition(self, this); self.World.ScreenMap.Remove(self); } + + public bool Disabled + { + get { return true; } + } } public class HuskSpeedInit : IActorInit diff --git a/OpenRA.Mods.RA/Modifiers/DisabledOverlay.cs b/OpenRA.Mods.RA/Modifiers/DisabledOverlay.cs new file mode 100644 index 0000000000..04a15fc5e7 --- /dev/null +++ b/OpenRA.Mods.RA/Modifiers/DisabledOverlay.cs @@ -0,0 +1,36 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 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 OpenRA.FileFormats; +using OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + [Desc("Use together with CanPowerDown/RequiresPower on buildings or Husk for vehicles.")] + public class DisabledOverlayInfo : TraitInfo { } + + public class DisabledOverlay : IRenderModifier + { + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) + { + var disabled = self.IsDisabled(); + foreach (var a in r) + { + yield return a; + if (disabled && !a.IsDecoration) + yield return a.WithPalette(wr.Palette("disabled")) + .WithZOffset(a.ZOffset + 1) + .AsDecoration(); + } + } + } +} \ No newline at end of file diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index dfc81f6973..48f622b732 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -495,6 +495,7 @@ + diff --git a/OpenRA.Mods.RA/Render/RenderBuilding.cs b/OpenRA.Mods.RA/Render/RenderBuilding.cs index a1e45b2b74..8a2f476737 100755 --- a/OpenRA.Mods.RA/Render/RenderBuilding.cs +++ b/OpenRA.Mods.RA/Render/RenderBuilding.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Render } } - public class RenderBuilding : RenderSimple, INotifyDamageStateChanged, IRenderModifier + public class RenderBuilding : RenderSimple, INotifyDamageStateChanged { public RenderBuilding(ActorInitializer init, RenderBuildingInfo info) : this(init, info, () => 0) { } @@ -54,19 +54,6 @@ namespace OpenRA.Mods.RA.Render self.QueueActivity(new CallFunc(() => Complete(self))); } - public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) - { - var disabled = self.IsDisabled(); - foreach (var a in r) - { - yield return a; - if (disabled && !a.IsDecoration) - yield return a.WithPalette(wr.Palette("disabled")) - .WithZOffset(a.ZOffset + 1) - .AsDecoration(); - } - } - void Complete(Actor self) { anim.PlayRepeating(NormalizeSequence(self, "idle")); diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index b4a6743e4c..89ef05f923 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -523,6 +523,7 @@ BelowUnits: BodyOrientation: LuaScriptEvents: + DisabledOverlay: ^HelicopterHusk: Inherits: ^Husk diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index e4e5ad7efa..8458c9e4ed 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -343,8 +343,6 @@ HPAD: ProductionBar: HQ: - RequiresPower: - CanPowerDown: Inherits: ^Building Valued: Cost: 1000 @@ -361,6 +359,9 @@ HQ: Power: -40 Footprint: x_ xx Dimensions: 2,2 + RequiresPower: + CanPowerDown: + DisabledOverlay: Health: HP: 750 RevealsShroud: @@ -408,8 +409,6 @@ FIX: RallyPoint: EYE: - RequiresPower: - CanPowerDown: Inherits: ^Building Valued: Cost: 1800 @@ -426,6 +425,9 @@ EYE: Power: -200 Footprint: x_ xx Dimensions: 2,2 + RequiresPower: + CanPowerDown: + DisabledOverlay: Health: HP: 1200 RevealsShroud: @@ -450,8 +452,6 @@ EYE: SupportPowerChargeBar: TMPL: - RequiresPower: - CanPowerDown: Inherits: ^Building Valued: Cost: 2000 @@ -468,6 +468,9 @@ TMPL: Power: -150 Footprint: ___ xxx xxx Dimensions: 3,3 + RequiresPower: + CanPowerDown: + DisabledOverlay: Health: HP: 2000 RevealsShroud: diff --git a/mods/d2k/rules/atreides.yaml b/mods/d2k/rules/atreides.yaml index 59b8b7d146..ff188b7bc8 100644 --- a/mods/d2k/rules/atreides.yaml +++ b/mods/d2k/rules/atreides.yaml @@ -61,6 +61,7 @@ PALACEA: SelectTargetSound: FlareType: CanPowerDown: + DisabledOverlay: RequiresPower: SupportPowerChargeBar: diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 7662ad9118..fef72a5fb7 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -104,6 +104,7 @@ CaptureThreshold: 1.0 TransformOnCapture: ForceHealthPercentage: 25 + DisabledOverlay: ^TowerHusk: Health: diff --git a/mods/d2k/rules/harkonnen.yaml b/mods/d2k/rules/harkonnen.yaml index 507055f77d..8e336e5cfa 100644 --- a/mods/d2k/rules/harkonnen.yaml +++ b/mods/d2k/rules/harkonnen.yaml @@ -99,6 +99,7 @@ PALACEH: DisplayBeacon: True DisplayRadarPing: True CanPowerDown: + DisabledOverlay: RequiresPower: SupportPowerChargeBar: diff --git a/mods/d2k/rules/ordos.yaml b/mods/d2k/rules/ordos.yaml index 49dc0ceef9..59112f1395 100644 --- a/mods/d2k/rules/ordos.yaml +++ b/mods/d2k/rules/ordos.yaml @@ -90,6 +90,7 @@ PALACEO: SelectTargetSound: FlareType: CanPowerDown: + DisabledOverlay: RequiresPower: SupportPowerChargeBar: diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 37436f39f7..eaf3aa40a6 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -263,6 +263,7 @@ Inherits: ^Building RequiresPower: CanPowerDown: + DisabledOverlay: Buildable: Prerequisites: Barracks Queue: Building @@ -335,6 +336,7 @@ PrimaryBuilding: RequiresPower: CanPowerDown: + DisabledOverlay: ProvidesCustomPrerequisite: Prerequisite: Starport @@ -477,6 +479,7 @@ WALL: AutoTarget: RequiresPower: CanPowerDown: + DisabledOverlay: RenderDetectionCircle: DetectCloaked: Range: 6 diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index c604b4913a..0087e23a91 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -438,6 +438,7 @@ CaptureThreshold: 1.0 TransformOnCapture: ForceHealthPercentage: 25 + DisabledOverlay: ^HelicopterHusk: Inherits: ^Husk diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index fd1f039fc0..9a9dd9cd41 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -41,12 +41,11 @@ MSLO: DisplayRadarPing: True CanPowerDown: RequiresPower: + DisabledOverlay: SupportPowerChargeBar: GAP: Inherits: ^Building - RequiresPower: - CanPowerDown: Valued: Cost: 800 Tooltip: @@ -62,6 +61,9 @@ GAP: Power: -60 Footprint: _ x Dimensions: 1,2 + RequiresPower: + CanPowerDown: + DisabledOverlay: Health: HP: 1000 Armor: @@ -188,9 +190,7 @@ SYRD: ProductionBar: IRON: - CanPowerDown: Inherits: ^Building - RequiresPower: Buildable: Queue: Defense BuildPaletteOrder: 120 @@ -207,6 +207,9 @@ IRON: Power: -200 Footprint: xx Dimensions: 2,1 + RequiresPower: + CanPowerDown: + DisabledOverlay: Selectable: Bounds: 50,50,0,-12 Health: @@ -231,8 +234,6 @@ IRON: PDOX: Inherits: ^Building - RequiresPower: - CanPowerDown: Buildable: Queue: Defense BuildPaletteOrder: 120 @@ -249,6 +250,9 @@ PDOX: Power: -200 Footprint: xx xx Dimensions: 2,2 + RequiresPower: + CanPowerDown: + DisabledOverlay: Health: HP: 1000 Armor: @@ -273,8 +277,6 @@ PDOX: TSLA: Inherits: ^Building - RequiresPower: - CanPowerDown: Buildable: Queue: Defense BuildPaletteOrder: 70 @@ -290,6 +292,9 @@ TSLA: Power: -150 Footprint: _ x Dimensions: 1,2 + RequiresPower: + CanPowerDown: + DisabledOverlay: -GivesBuildableArea: Health: HP: 400 @@ -312,8 +317,6 @@ TSLA: AGUN: Inherits: ^Building - RequiresPower: - CanPowerDown: Buildable: Queue: Defense BuildPaletteOrder: 50 @@ -329,6 +332,9 @@ AGUN: Power: -50 Footprint: _ x Dimensions: 1,2 + RequiresPower: + CanPowerDown: + DisabledOverlay: -GivesBuildableArea: Health: HP: 400 @@ -354,8 +360,6 @@ AGUN: DrawLineToTarget: DOME: - RequiresPower: - CanPowerDown: Inherits: ^Building Buildable: Queue: Building @@ -372,6 +376,9 @@ DOME: Power: -40 Footprint: xx xx Dimensions: 2,2 + RequiresPower: + CanPowerDown: + DisabledOverlay: Health: HP: 1000 Armor: @@ -772,6 +779,9 @@ SAM: Power: -40 Footprint: xx Dimensions: 2,1 + RequiresPower: + CanPowerDown: + DisabledOverlay: -GivesBuildableArea: Health: HP: 400 @@ -792,8 +802,6 @@ SAM: -RenderBuilding: RenderRangeCircle: RangeCircleType: aa - RequiresPower: - CanPowerDown: -AcceptsSupplies: DrawLineToTarget: