From f3210755c0c25ee05bba17dc01c203bd297d50dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Fri, 1 Jan 2016 22:07:04 +0100 Subject: [PATCH 1/2] rename WithDockingOverlay to WithDockedOverlay --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- .../{WithDockingOverlay.cs => WithDockedOverlay.cs} | 10 +++++----- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 7 +++++++ mods/d2k/rules/structures.yaml | 2 +- mods/ts/rules/shared-structures.yaml | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) rename OpenRA.Mods.Common/Traits/Render/{WithDockingOverlay.cs => WithDockedOverlay.cs} (86%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 28f9e444aa..97f8d3f8e2 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -433,7 +433,7 @@ - + diff --git a/OpenRA.Mods.Common/Traits/Render/WithDockingOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs similarity index 86% rename from OpenRA.Mods.Common/Traits/Render/WithDockingOverlay.cs rename to OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs index db95eec69f..65d9b730df 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDockingOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Rendered when a harvester is docked.")] - public class WithDockingOverlayInfo : ITraitInfo, Requires, Requires + public class WithDockedOverlayInfo : ITraitInfo, Requires, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "docking-overlay"; @@ -29,17 +29,17 @@ namespace OpenRA.Mods.Common.Traits [Desc("Custom palette is a player palette BaseName")] public readonly bool IsPlayerPalette = false; - public object Create(ActorInitializer init) { return new WithDockingOverlay(init.Self, this); } + public object Create(ActorInitializer init) { return new WithDockedOverlay(init.Self, this); } } - public class WithDockingOverlay : INotifyDocking, INotifyBuildComplete, INotifySold + public class WithDockedOverlay : INotifyDocking, INotifyBuildComplete, INotifySold { - readonly WithDockingOverlayInfo info; + readonly WithDockedOverlayInfo info; readonly AnimationWithOffset anim; bool buildComplete; bool docked; - public WithDockingOverlay(Actor self, WithDockingOverlayInfo info) + public WithDockedOverlay(Actor self, WithDockedOverlayInfo info) { this.info = info; diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 41a8fd8377..1cac280126 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2876,6 +2876,13 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Rename WithDockingOverlay to WithDockedOverlay + if (engineVersion < 20160116) + { + if (node.Key.StartsWith("WithDockingOverlay")) + node.Key = "WithDockedOverlay" + node.Key.Substring(18); + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 1500b3a6ac..f6384d6a35 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -260,7 +260,7 @@ refinery: FactionImages: atreides: refinery.atreides ordos: refinery.ordos - WithDockingOverlay@SMOKE: + WithDockedOverlay@SMOKE: Sequence: smoke Power: Amount: -75 diff --git a/mods/ts/rules/shared-structures.yaml b/mods/ts/rules/shared-structures.yaml index f422326b5b..025cb0da39 100644 --- a/mods/ts/rules/shared-structures.yaml +++ b/mods/ts/rules/shared-structures.yaml @@ -91,7 +91,7 @@ PROC: Sequence: idle-redlights WithIdleOverlay@BIB: Sequence: bib - WithDockingOverlay@flame: + WithDockedOverlay@FLAME: Sequence: flame Palette: effect Power: From 152ff32ded11ce2024dc5fbeea4cb78c87e4a391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Fri, 1 Jan 2016 15:31:58 +0100 Subject: [PATCH 2/2] add the Tiberian Sun harvester unload overlay --- .../Activities/VoxelHarvesterDockSequence.cs | 35 ++++++++++- OpenRA.Mods.TS/OpenRA.Mods.TS.csproj | 1 + .../Traits/Render/WithDockingOverlay.cs | 59 +++++++++++++++++++ mods/ts/rules/shared-structures.yaml | 1 + mods/ts/sequences/structures.yaml | 8 ++- 5 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 OpenRA.Mods.TS/Traits/Render/WithDockingOverlay.cs diff --git a/OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs b/OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs index c586124321..6c718fc8f4 100644 --- a/OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs +++ b/OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs @@ -10,6 +10,7 @@ using OpenRA.Activities; using OpenRA.Mods.Common.Activities; +using OpenRA.Mods.Common.Traits; using OpenRA.Mods.TS.Traits; namespace OpenRA.Mods.TS.Activities @@ -17,24 +18,52 @@ namespace OpenRA.Mods.TS.Activities public class VoxelHarvesterDockSequence : HarvesterDockSequence { readonly WithVoxelUnloadBody body; + readonly WithDockingOverlay spriteOverlay; public VoxelHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength) : base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength) { body = self.Trait(); + spriteOverlay = refinery.TraitOrDefault(); } public override Activity OnStateDock(Actor self) { body.Docked = true; - dockingState = State.Loop; + + if (spriteOverlay != null && !spriteOverlay.Visible) + { + spriteOverlay.Visible = true; + spriteOverlay.WithOffset.Animation.PlayThen(spriteOverlay.Info.Sequence, () => { + dockingState = State.Loop; + spriteOverlay.Visible = false; + }); + } + else + dockingState = State.Loop; + return this; } public override Activity OnStateUndock(Actor self) { - body.Docked = false; - dockingState = State.Complete; + dockingState = State.Wait; + + if (spriteOverlay != null && !spriteOverlay.Visible) + { + spriteOverlay.Visible = true; + spriteOverlay.WithOffset.Animation.PlayBackwardsThen(spriteOverlay.Info.Sequence, () => { + dockingState = State.Complete; + body.Docked = false; + spriteOverlay.Visible = false; + }); + } + else + { + dockingState = State.Complete; + body.Docked = false; + } + return this; } } diff --git a/OpenRA.Mods.TS/OpenRA.Mods.TS.csproj b/OpenRA.Mods.TS/OpenRA.Mods.TS.csproj index 0e35f2499b..26839244af 100644 --- a/OpenRA.Mods.TS/OpenRA.Mods.TS.csproj +++ b/OpenRA.Mods.TS/OpenRA.Mods.TS.csproj @@ -69,6 +69,7 @@ + diff --git a/OpenRA.Mods.TS/Traits/Render/WithDockingOverlay.cs b/OpenRA.Mods.TS/Traits/Render/WithDockingOverlay.cs new file mode 100644 index 0000000000..8a11e4818e --- /dev/null +++ b/OpenRA.Mods.TS/Traits/Render/WithDockingOverlay.cs @@ -0,0 +1,59 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 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 OpenRA.Graphics; +using OpenRA.Mods.Common.Traits; +using OpenRA.Traits; + +namespace OpenRA.Mods.TS.Traits +{ + [Desc("Rendered on the refinery when a voxel harvester is docking and undocking.")] + public class WithDockingOverlayInfo : ITraitInfo, Requires, Requires + { + [Desc("Sequence name to use")] + [SequenceReference] public readonly string Sequence = "unload-overlay"; + + [Desc("Position relative to body")] + public readonly WVec Offset = WVec.Zero; + + [Desc("Custom palette name")] + [PaletteReference("IsPlayerPalette")] public readonly string Palette = null; + + [Desc("Custom palette is a player palette BaseName")] + public readonly bool IsPlayerPalette = false; + + public object Create(ActorInitializer init) { return new WithDockingOverlay(init.Self, this); } + } + + public class WithDockingOverlay + { + public readonly WithDockingOverlayInfo Info; + public readonly AnimationWithOffset WithOffset; + + public bool Visible; + + public WithDockingOverlay(Actor self, WithDockingOverlayInfo info) + { + Info = info; + + var rs = self.Trait(); + var body = self.Trait(); + + var overlay = new Animation(self.World, rs.GetImage(self)); + overlay.Play(info.Sequence); + + WithOffset = new AnimationWithOffset(overlay, + () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), + () => !Visible); + + rs.Add(WithOffset, info.Palette, info.IsPlayerPalette); + } + } +} \ No newline at end of file diff --git a/mods/ts/rules/shared-structures.yaml b/mods/ts/rules/shared-structures.yaml index 025cb0da39..a95b7e5014 100644 --- a/mods/ts/rules/shared-structures.yaml +++ b/mods/ts/rules/shared-structures.yaml @@ -94,6 +94,7 @@ PROC: WithDockedOverlay@FLAME: Sequence: flame Palette: effect + WithDockingOverlay@UNLOAD: Power: Amount: -30 ProvidesPrerequisite@buildingname: diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml index 22bbce2af9..7953c39ac0 100644 --- a/mods/ts/sequences/structures.yaml +++ b/mods/ts/sequences/structures.yaml @@ -1038,7 +1038,6 @@ nahpad: Offset: 0, 0 UseTilesetCode: false -# TODO: unused narefn_a proc.gdi: Defaults: ntrefn Offset: -12, -42 @@ -1057,6 +1056,9 @@ proc.gdi: ShadowStart: 20 flame: ntrefn_b Length: * + unload-overlay: narefn_a + Length: * + ZOffset: 1024 idle-redlights: ntrefn_c Length: 16 Tick: 120 @@ -1078,7 +1080,6 @@ proc.gdi: Offset: 0, 0 UseTilesetCode: false -# TODO: unused narefn_a proc.nod: Defaults: ntrefn Offset: -12, -42 @@ -1097,6 +1098,9 @@ proc.nod: ShadowStart: 20 flame: ntrefn_b Length: * + unload-overlay: narefn_a + Length: * + ZOffset: 1024 idle-redlights: ntrefn_c Length: 16 Tick: 120