Move creeps configuration to rules.
This commit is contained in:
@@ -58,7 +58,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
public class MapOptions
|
public class MapOptions
|
||||||
{
|
{
|
||||||
public bool? Creeps;
|
|
||||||
public bool? AllyBuildRadius;
|
public bool? AllyBuildRadius;
|
||||||
public string TechLevel;
|
public string TechLevel;
|
||||||
public string[] Difficulties = { };
|
public string[] Difficulties = { };
|
||||||
@@ -66,8 +65,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void UpdateServerSettings(Session.Global settings)
|
public void UpdateServerSettings(Session.Global settings)
|
||||||
{
|
{
|
||||||
if (Creeps.HasValue)
|
|
||||||
settings.Creeps = Creeps.Value;
|
|
||||||
if (AllyBuildRadius.HasValue)
|
if (AllyBuildRadius.HasValue)
|
||||||
settings.AllyBuildRadius = AllyBuildRadius.Value;
|
settings.AllyBuildRadius = AllyBuildRadius.Value;
|
||||||
if (ShortGame.HasValue)
|
if (ShortGame.HasValue)
|
||||||
|
|||||||
@@ -732,6 +732,7 @@
|
|||||||
<Compile Include="Traits\Render\WithGateSpriteBody.cs" />
|
<Compile Include="Traits\Render\WithGateSpriteBody.cs" />
|
||||||
<Compile Include="ColorValidator.cs" />
|
<Compile Include="ColorValidator.cs" />
|
||||||
<Compile Include="UtilityCommands\ResizeMapCommand.cs" />
|
<Compile Include="UtilityCommands\ResizeMapCommand.cs" />
|
||||||
|
<Compile Include="Traits\World\MapCreeps.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -545,7 +545,8 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.Map.Options.Creeps.HasValue)
|
var mapCreeps = server.Map.Rules.Actors["world"].TraitInfoOrDefault<MapCreepsInfo>();
|
||||||
|
if (mapCreeps == null || mapCreeps.Locked)
|
||||||
{
|
{
|
||||||
server.SendOrderTo(conn, "Message", "Map has disabled Creeps spawning configuration.");
|
server.SendOrderTo(conn, "Message", "Map has disabled Creeps spawning configuration.");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
28
OpenRA.Mods.Common/Traits/World/MapCreeps.cs
Normal file
28
OpenRA.Mods.Common/Traits/World/MapCreeps.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2016 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, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Controls the 'Creeps' checkbox in the lobby options.")]
|
||||||
|
public class MapCreepsInfo : TraitInfo<MapCreeps>
|
||||||
|
{
|
||||||
|
[Desc("Default value of the creeps checkbox in the lobby.")]
|
||||||
|
public readonly bool Enabled = true;
|
||||||
|
|
||||||
|
[Desc("Prevent the creeps state from being changed in the lobby.")]
|
||||||
|
public readonly bool Locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MapCreeps { }
|
||||||
|
}
|
||||||
@@ -376,8 +376,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var creeps = optionsBin.GetOrNull<CheckboxWidget>("CREEPS_CHECKBOX");
|
var creeps = optionsBin.GetOrNull<CheckboxWidget>("CREEPS_CHECKBOX");
|
||||||
if (creeps != null)
|
if (creeps != null)
|
||||||
{
|
{
|
||||||
|
var creepsLocked = new CachedTransform<Map, bool>(map =>
|
||||||
|
{
|
||||||
|
var mapCreeps = map.Rules.Actors["world"].TraitInfoOrDefault<MapCreepsInfo>();
|
||||||
|
return mapCreeps == null || mapCreeps.Locked;
|
||||||
|
});
|
||||||
|
|
||||||
creeps.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Creeps;
|
creeps.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Creeps;
|
||||||
creeps.IsDisabled = () => configurationDisabled() || Map.Options.Creeps.HasValue;
|
creeps.IsDisabled = () => configurationDisabled() || creepsLocked.Update(Map);
|
||||||
creeps.OnClick = () => orderManager.IssueOrder(Order.Command(
|
creeps.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||||
"creeps {0}".F(!orderManager.LobbyInfo.GlobalSettings.Creeps)));
|
"creeps {0}".F(!orderManager.LobbyInfo.GlobalSettings.Creeps)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ World:
|
|||||||
ResourceClaimLayer:
|
ResourceClaimLayer:
|
||||||
PathfinderDebugOverlay:
|
PathfinderDebugOverlay:
|
||||||
WarheadDebugOverlay:
|
WarheadDebugOverlay:
|
||||||
|
MapCreeps:
|
||||||
SpawnMapActors:
|
SpawnMapActors:
|
||||||
MPStartLocations:
|
MPStartLocations:
|
||||||
CreateMPPlayers:
|
CreateMPPlayers:
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ World:
|
|||||||
Type: SandCrater
|
Type: SandCrater
|
||||||
Sequence: sandcraters
|
Sequence: sandcraters
|
||||||
SmokePercentage: 0
|
SmokePercentage: 0
|
||||||
|
MapCreeps:
|
||||||
SpawnMapActors:
|
SpawnMapActors:
|
||||||
CreateMPPlayers:
|
CreateMPPlayers:
|
||||||
MPStartLocations:
|
MPStartLocations:
|
||||||
|
|||||||
Reference in New Issue
Block a user