From 470ae172719560eefd14a74e2bb9f3fbd8f5a045 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Sun, 30 Nov 2014 13:42:51 +0100 Subject: [PATCH] Move mission objectives and victory conditions to Mods.Common --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 14 ++++++++++---- .../PlayerExtensions.cs | 6 +++--- OpenRA.Mods.Common/Traits/MustBeDestroyed.cs | 18 ++++++++++++++++++ .../Player}/ConquestVictoryConditions.cs | 12 ++++-------- .../Traits}/Player/MissionObjectives.cs | 12 ++++++------ .../Player}/StrategicVictoryConditions.cs | 10 +++++----- .../Widgets/StrategicProgressWidget.cs | 9 +++++---- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 5 ----- .../Properties/MissionObjectiveProperties.cs | 5 +++-- .../Logic/Ingame/GameInfoObjectivesLogic.cs | 4 ++-- .../Widgets/Logic/OrderButtonsChromeLogic.cs | 7 ++++--- 11 files changed, 60 insertions(+), 42 deletions(-) rename OpenRA.Mods.RA/Player/Extensions.cs => OpenRA.Mods.Common/PlayerExtensions.cs (84%) create mode 100644 OpenRA.Mods.Common/Traits/MustBeDestroyed.cs rename {OpenRA.Mods.RA => OpenRA.Mods.Common/Traits/Player}/ConquestVictoryConditions.cs (85%) rename {OpenRA.Mods.RA => OpenRA.Mods.Common/Traits}/Player/MissionObjectives.cs (95%) rename {OpenRA.Mods.RA => OpenRA.Mods.Common/Traits/Player}/StrategicVictoryConditions.cs (93%) rename {OpenRA.Mods.RA => OpenRA.Mods.Common}/Widgets/StrategicProgressWidget.cs (95%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index c2626d0116..1d84308a23 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -85,6 +85,7 @@ + @@ -128,16 +129,20 @@ + + + + @@ -206,16 +211,16 @@ + + - - + - @@ -223,6 +228,7 @@ + @@ -246,4 +252,4 @@ cd "$(SolutionDir)" --> - \ No newline at end of file + diff --git a/OpenRA.Mods.RA/Player/Extensions.cs b/OpenRA.Mods.Common/PlayerExtensions.cs similarity index 84% rename from OpenRA.Mods.RA/Player/Extensions.cs rename to OpenRA.Mods.Common/PlayerExtensions.cs index 840ef08ec7..8ce8152701 100644 --- a/OpenRA.Mods.RA/Player/Extensions.cs +++ b/OpenRA.Mods.Common/PlayerExtensions.cs @@ -9,11 +9,11 @@ #endregion using System.Linq; -using OpenRA.Mods.RA; +using OpenRA.Mods.Common.Traits; -namespace OpenRA +namespace OpenRA.Mods.Common { - public static class Extensions + public static class PlayerExtensions { public static bool HasNoRequiredUnits(this Player player) { diff --git a/OpenRA.Mods.Common/Traits/MustBeDestroyed.cs b/OpenRA.Mods.Common/Traits/MustBeDestroyed.cs new file mode 100644 index 0000000000..fe4a101744 --- /dev/null +++ b/OpenRA.Mods.Common/Traits/MustBeDestroyed.cs @@ -0,0 +1,18 @@ +#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 OpenRA.Traits; + +namespace OpenRA.Mods.Common.Traits +{ + [Desc("Tag trait for things that must be destroyed for a short game to end.")] + public class MustBeDestroyedInfo : TraitInfo { } + public class MustBeDestroyed { } +} diff --git a/OpenRA.Mods.RA/ConquestVictoryConditions.cs b/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs similarity index 85% rename from OpenRA.Mods.RA/ConquestVictoryConditions.cs rename to OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs index bece0d218f..b366091797 100644 --- a/OpenRA.Mods.RA/ConquestVictoryConditions.cs +++ b/OpenRA.Mods.Common/Traits/Player/ConquestVictoryConditions.cs @@ -11,7 +11,7 @@ using System.Linq; using OpenRA.Traits; -namespace OpenRA.Mods.RA +namespace OpenRA.Mods.Common.Traits { public class ConquestVictoryConditionsInfo : ITraitInfo, Requires { @@ -77,12 +77,8 @@ namespace OpenRA.Mods.RA Game.RunAfterDelay(info.NotificationDelay, () => Sound.PlayNotification(player.World.Map.Rules, player, "Speech", "Win", player.Country.Race)); } - public void OnObjectiveAdded(Player player, int id) {} - public void OnObjectiveCompleted(Player player, int id) {} - public void OnObjectiveFailed(Player player, int id) {} + public void OnObjectiveAdded(Player player, int id) { } + public void OnObjectiveCompleted(Player player, int id) { } + public void OnObjectiveFailed(Player player, int id) { } } - - [Desc("Tag trait for things that must be destroyed for a short game to end.")] - public class MustBeDestroyedInfo : TraitInfo { } - public class MustBeDestroyed { } } diff --git a/OpenRA.Mods.RA/Player/MissionObjectives.cs b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs similarity index 95% rename from OpenRA.Mods.RA/Player/MissionObjectives.cs rename to OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs index df24236025..e719f56f11 100644 --- a/OpenRA.Mods.RA/Player/MissionObjectives.cs +++ b/OpenRA.Mods.Common/Traits/Player/MissionObjectives.cs @@ -14,10 +14,10 @@ using System.Linq; using OpenRA.Primitives; using OpenRA.Traits; -namespace OpenRA.Mods.RA +namespace OpenRA.Mods.Common.Traits { - public enum ObjectiveType { Primary, Secondary }; - public enum ObjectiveState { Incomplete, Completed, Failed }; + public enum ObjectiveType { Primary, Secondary } + public enum ObjectiveState { Incomplete, Completed, Failed } public class MissionObjective { @@ -233,9 +233,9 @@ namespace OpenRA.Mods.RA public event Action ObjectiveAdded = player => { player.HasObjectives = true; }; - public void OnObjectiveAdded(Player player, int id) {} - public void OnObjectiveCompleted(Player player, int id) {} - public void OnObjectiveFailed(Player player, int id) {} + public void OnObjectiveAdded(Player player, int id) { } + public void OnObjectiveCompleted(Player player, int id) { } + public void OnObjectiveFailed(Player player, int id) { } public void ResolveOrder(Actor self, Order order) { diff --git a/OpenRA.Mods.RA/StrategicVictoryConditions.cs b/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs similarity index 93% rename from OpenRA.Mods.RA/StrategicVictoryConditions.cs rename to OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs index 8b89bd953c..b8ffb016b3 100644 --- a/OpenRA.Mods.RA/StrategicVictoryConditions.cs +++ b/OpenRA.Mods.Common/Traits/Player/StrategicVictoryConditions.cs @@ -12,7 +12,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Traits; -namespace OpenRA.Mods.RA +namespace OpenRA.Mods.Common.Traits { [Desc("Used to mark a place that needs to be in possession for StrategicVictoryConditions.")] public class StrategicPointInfo : TraitInfo { } @@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA mo.MarkCompleted(player, objectiveID); if (others.Any(p => p.WinState == WinState.Won)) - mo.MarkFailed(player, objectiveID); + mo.MarkFailed(player, objectiveID); // See if any of the conditions are met to increase the count if (Total > 0) @@ -122,8 +122,8 @@ namespace OpenRA.Mods.RA Game.RunAfterDelay(info.NotificationDelay, () => Sound.PlayNotification(player.World.Map.Rules, player, "Speech", "Win", player.Country.Race)); } - public void OnObjectiveAdded(Player player, int id) {} - public void OnObjectiveCompleted(Player player, int id) {} - public void OnObjectiveFailed(Player player, int id) {} + public void OnObjectiveAdded(Player player, int id) { } + public void OnObjectiveCompleted(Player player, int id) { } + public void OnObjectiveFailed(Player player, int id) { } } } diff --git a/OpenRA.Mods.RA/Widgets/StrategicProgressWidget.cs b/OpenRA.Mods.Common/Widgets/StrategicProgressWidget.cs similarity index 95% rename from OpenRA.Mods.RA/Widgets/StrategicProgressWidget.cs rename to OpenRA.Mods.Common/Widgets/StrategicProgressWidget.cs index 8b158daf11..1f601e36a1 100644 --- a/OpenRA.Mods.RA/Widgets/StrategicProgressWidget.cs +++ b/OpenRA.Mods.Common/Widgets/StrategicProgressWidget.cs @@ -11,14 +11,15 @@ using System.Drawing; using System.Linq; using OpenRA.Graphics; +using OpenRA.Mods.Common.Traits; using OpenRA.Widgets; -namespace OpenRA.Mods.RA.Widgets +namespace OpenRA.Mods.Common.Widgets { public class StrategicProgressWidget : Widget { - bool Initialised = false; readonly World world; + bool initialised = false; [ObjectCreator.UseCtor] public StrategicProgressWidget(World world) @@ -29,7 +30,7 @@ namespace OpenRA.Mods.RA.Widgets public override void Draw() { - if (!Initialised) + if (!initialised) Init(); if (!IsVisible()) return; @@ -99,7 +100,7 @@ namespace OpenRA.Mods.RA.Widgets world.ActorsWithTrait().Any(); IsVisible = () => visible; - Initialised = true; + initialised = true; } } } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index a3e68e5b97..62f6595828 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -166,7 +166,6 @@ - @@ -215,7 +214,6 @@ - @@ -251,7 +249,6 @@ - @@ -326,7 +323,6 @@ - @@ -405,7 +401,6 @@ - diff --git a/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs index 772d16bc31..1f08fff824 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs @@ -10,9 +10,10 @@ using System; using Eluant; -using OpenRA.Traits; +using OpenRA.Mods.Common; +using OpenRA.Mods.Common.Traits; using OpenRA.Scripting; -using OpenRA.Mods.RA; +using OpenRA.Traits; namespace OpenRA.Mods.RA.Scripting { diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs index 996e0d4dac..3fb3ee70f4 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/GameInfoObjectivesLogic.cs @@ -11,9 +11,9 @@ using System; using System.Linq; using System.Drawing; -using OpenRA.Widgets; +using OpenRA.Mods.Common.Traits; using OpenRA.Traits; -using OpenRA.Mods.RA; +using OpenRA.Widgets; namespace OpenRA.Mods.RA.Widgets.Logic { diff --git a/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs index 359ec0b4c6..7a1f14a287 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs @@ -10,10 +10,11 @@ using System; using System.Linq; -using OpenRA.Mods.RA.Orders; -using OpenRA.Widgets; -using OpenRA.Traits; +using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Widgets; +using OpenRA.Mods.RA.Orders; +using OpenRA.Traits; +using OpenRA.Widgets; namespace OpenRA.Mods.RA.Widgets.Logic {