Move mission objectives and victory conditions to Mods.Common

This commit is contained in:
Oliver Brakmann
2014-11-30 13:42:51 +01:00
parent cb471bb36b
commit 470ae17271
11 changed files with 60 additions and 42 deletions

View File

@@ -85,6 +85,7 @@
<Compile Include="Orders\DeployOrderTargeter.cs" />
<Compile Include="Orders\EnterAlliedActorTargeter.cs" />
<Compile Include="Orders\UnitOrderTargeter.cs" />
<Compile Include="PlayerExtensions.cs" />
<Compile Include="ServerTraits\ColorValidator.cs" />
<Compile Include="ServerTraits\LobbyCommands.cs" />
<Compile Include="ServerTraits\LobbySettingsNotification.cs" />
@@ -128,16 +129,20 @@
<Compile Include="Traits\Modifiers\DisabledOverlay.cs" />
<Compile Include="Traits\Modifiers\HiddenUnderFog.cs" />
<Compile Include="Traits\Modifiers\UpgradeOverlay.cs" />
<Compile Include="Traits\MustBeDestroyed.cs" />
<Compile Include="Traits\PaletteEffects\CloakPaletteEffect.cs" />
<Compile Include="Traits\PaletteEffects\LightPaletteRotator.cs" />
<Compile Include="Traits\PaletteEffects\MenuPaletteEffect.cs" />
<Compile Include="Traits\PaletteEffects\NukePaletteEffect.cs" />
<Compile Include="Traits\PaletteEffects\WaterPaletteRotation.cs" />
<Compile Include="Traits\Player\ActorGroupProxy.cs" />
<Compile Include="Traits\Player\ConquestVictoryConditions.cs" />
<Compile Include="Traits\Player\GlobalUpgradeManager.cs" />
<Compile Include="Traits\Player\MissionObjectives.cs" />
<Compile Include="Traits\Player\PlaceBeacon.cs" />
<Compile Include="Traits\Player\ProvidesCustomPrerequisite.cs" />
<Compile Include="Traits\Player\ProvidesTechPrerequisite.cs" />
<Compile Include="Traits\Player\StrategicVictoryConditions.cs" />
<Compile Include="Traits\Player\TechTree.cs" />
<Compile Include="Traits\Power\AffectedByPowerOutage.cs" />
<Compile Include="Traits\Power\CanPowerDown.cs" />
@@ -206,16 +211,16 @@
<Compile Include="Warheads\HealthPercentageDamageWarhead.cs" />
<Compile Include="Warheads\LeaveSmudgeWarhead.cs" />
<Compile Include="Warheads\SpreadDamageWarhead.cs" />
<Compile Include="Widgets\ColorMixerWidget.cs" />
<Compile Include="Widgets\ColorPreviewManagerWidget.cs" />
<Compile Include="Widgets\ConfirmationDialogs.cs" />
<Compile Include="Widgets\HueSliderWidget.cs" />
<Compile Include="Widgets\LabelWithTooltipWidget.cs" />
<Compile Include="Widgets\LogicKeyListenerWidget.cs" />
<Compile Include="Widgets\Logic\AssetBrowserLogic.cs" />
<Compile Include="Widgets\ColorMixerWidget.cs" />
<Compile Include="Widgets\LogicTickerWidget.cs" />
<Compile Include="Widgets\Logic\AssetBrowserLogic.cs" />
<Compile Include="Widgets\Logic\ButtonTooltipLogic.cs" />
<Compile Include="Widgets\Logic\ColorPickerLogic.cs" />
<Compile Include="Widgets\ColorPreviewManagerWidget.cs" />
<Compile Include="Widgets\Logic\DisconnectWatcherLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\IngameRadarDisplayLogic.cs" />
<Compile Include="Widgets\Logic\Ingame\LoadIngamePlayerOrObserverUILogic.cs" />
@@ -223,6 +228,7 @@
<Compile Include="Widgets\MenuButtonWidget.cs" />
<Compile Include="Widgets\RadarWidget.cs" />
<Compile Include="Widgets\ResourceBarWidget.cs" />
<Compile Include="Widgets\StrategicProgressWidget.cs" />
<Compile Include="SpriteLoaders\ShpTDLoader.cs" />
<Compile Include="SpriteLoaders\ShpTSLoader.cs" />
<Compile Include="SpriteLoaders\TmpRALoader.cs" />
@@ -246,4 +252,4 @@ cd "$(SolutionDir)"</PostBuildEvent>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -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)
{

View File

@@ -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<MustBeDestroyed> { }
public class MustBeDestroyed { }
}

View File

@@ -11,7 +11,7 @@
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
namespace OpenRA.Mods.Common.Traits
{
public class ConquestVictoryConditionsInfo : ITraitInfo, Requires<MissionObjectivesInfo>
{
@@ -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<MustBeDestroyed> { }
public class MustBeDestroyed { }
}

View File

@@ -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<Player> 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)
{

View File

@@ -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<StrategicPoint> { }
@@ -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) { }
}
}

View File

@@ -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<StrategicPoint>().Any();
IsVisible = () => visible;
Initialised = true;
initialised = true;
}
}
}

View File

@@ -166,7 +166,6 @@
<Compile Include="CashTrickler.cs" />
<Compile Include="Traits\PaletteEffects\ChronoshiftPaletteEffect.cs" />
<Compile Include="Traits\Chronoshiftable.cs" />
<Compile Include="ConquestVictoryConditions.cs" />
<Compile Include="Crate.cs" />
<Compile Include="CrateAction.cs" />
<Compile Include="CrateSpawner.cs" />
@@ -215,7 +214,6 @@
<Compile Include="Player\ClassicProductionQueue.cs" />
<Compile Include="Player\PlaceBuilding.cs" />
<Compile Include="Player\ProductionQueue.cs" />
<Compile Include="Player\MissionObjectives.cs" />
<Compile Include="Traits\PortableChrono.cs" />
<Compile Include="Scripting\Properties\GuardProperties.cs" />
<Compile Include="Traits\World\DomainIndex.cs" />
@@ -251,7 +249,6 @@
<Compile Include="SpawnMPUnits.cs" />
<Compile Include="Disguise.cs" />
<Compile Include="StoresResources.cs" />
<Compile Include="StrategicVictoryConditions.cs" />
<Compile Include="Traits\SupplyTruck.cs" />
<Compile Include="SupportPowers\AirstrikePower.cs" />
<Compile Include="Traits\SupportPowers\ChronoshiftPower.cs" />
@@ -326,7 +323,6 @@
<Compile Include="Widgets\Logic\ServerCreationLogic.cs" />
<Compile Include="Widgets\ObserverProductionIconsWidget.cs" />
<Compile Include="Widgets\ObserverSupportPowerIconsWidget.cs" />
<Compile Include="Widgets\StrategicProgressWidget.cs" />
<Compile Include="Widgets\SupportPowerTimerWidget.cs" />
<Compile Include="Widgets\WorldCommandWidget.cs" />
<Compile Include="Player\BaseAttackNotifier.cs" />
@@ -405,7 +401,6 @@
<Compile Include="Widgets\Logic\DebugMenuLogic.cs" />
<Compile Include="ProductionQueueFromSelection.cs" />
<Compile Include="GainsStatUpgrades.cs" />
<Compile Include="Player\Extensions.cs" />
<Compile Include="Warheads\CreateResourceWarhead.cs" />
<Compile Include="Warheads\DestroyResourceWarhead.cs" />
<Compile Include="Warheads\PerCellDamageWarhead.cs" />

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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
{