Move crates option to rules.
This commit is contained in:
@@ -58,7 +58,6 @@ namespace OpenRA
|
||||
|
||||
public class MapOptions
|
||||
{
|
||||
public bool? Crates;
|
||||
public bool? Creeps;
|
||||
public bool? Fog;
|
||||
public bool? Shroud;
|
||||
@@ -71,8 +70,6 @@ namespace OpenRA
|
||||
|
||||
public void UpdateServerSettings(Session.Global settings)
|
||||
{
|
||||
if (Crates.HasValue)
|
||||
settings.Crates = Crates.Value;
|
||||
if (Creeps.HasValue)
|
||||
settings.Creeps = Creeps.Value;
|
||||
if (Fog.HasValue)
|
||||
|
||||
@@ -519,7 +519,8 @@ namespace OpenRA.Mods.Common.Server
|
||||
return true;
|
||||
}
|
||||
|
||||
if (server.Map.Options.Crates.HasValue)
|
||||
var crateSpawner = server.Map.Rules.Actors["world"].TraitInfoOrDefault<CrateSpawnerInfo>();
|
||||
if (crateSpawner == null || crateSpawner.Locked)
|
||||
{
|
||||
server.SendOrderTo(conn, "Message", "Map has disabled crate configuration.");
|
||||
return true;
|
||||
@@ -1015,6 +1016,9 @@ namespace OpenRA.Mods.Common.Server
|
||||
var gs = server.LobbyInfo.GlobalSettings;
|
||||
var devMode = server.Map.Rules.Actors["player"].TraitInfo<DeveloperModeInfo>();
|
||||
gs.AllowCheats = devMode.Enabled;
|
||||
|
||||
var crateSpawner = server.Map.Rules.Actors["world"].TraitInfoOrDefault<CrateSpawnerInfo>();
|
||||
gs.Crates = crateSpawner != null && crateSpawner.Enabled;
|
||||
server.Map.Options.UpdateServerSettings(server.LobbyInfo.GlobalSettings);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class CrateSpawnerInfo : ITraitInfo
|
||||
{
|
||||
[Desc("Default value of the crates checkbox in the lobby.")]
|
||||
public readonly bool Enabled = true;
|
||||
|
||||
[Desc("Prevent the crates state from being changed in the lobby.")]
|
||||
public readonly bool Locked = false;
|
||||
|
||||
[Desc("Minimum number of crates.")]
|
||||
public readonly int Minimum = 1;
|
||||
|
||||
@@ -42,14 +48,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int WaterChance = 20;
|
||||
|
||||
[ActorReference]
|
||||
[Desc("Crate actors to drop")]
|
||||
[Desc("Crate actors to drop.")]
|
||||
public readonly string[] CrateActors = { "crate" };
|
||||
|
||||
[Desc("Chance of each crate actor spawning")]
|
||||
[Desc("Chance of each crate actor spawning.")]
|
||||
public readonly int[] CrateActorShares = { 10 };
|
||||
|
||||
[ActorReference]
|
||||
[Desc("If a DeliveryAircraft: is specified, then this actor will deliver crates")]
|
||||
[Desc("If a DeliveryAircraft: is specified, then this actor will deliver crates.")]
|
||||
public readonly string DeliveryAircraft = null;
|
||||
|
||||
[Desc("Number of facings that the delivery aircraft may approach from.")]
|
||||
|
||||
@@ -361,8 +361,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var crates = optionsBin.GetOrNull<CheckboxWidget>("CRATES_CHECKBOX");
|
||||
if (crates != null)
|
||||
{
|
||||
var cratesLocked = new CachedTransform<Map, bool>(map =>
|
||||
{
|
||||
var crateSpawner = map.Rules.Actors["world"].TraitInfoOrDefault<CrateSpawnerInfo>();
|
||||
return crateSpawner == null || crateSpawner.Locked;
|
||||
});
|
||||
|
||||
crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates;
|
||||
crates.IsDisabled = () => configurationDisabled() || Map.Options.Crates.HasValue;
|
||||
crates.IsDisabled = () => configurationDisabled() || cratesLocked.Update(Map);
|
||||
crates.OnClick = () => orderManager.IssueOrder(Order.Command(
|
||||
"crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates)));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ Type: Drop Zone
|
||||
Videos:
|
||||
|
||||
Options:
|
||||
Crates: True
|
||||
Fog: False
|
||||
Shroud: False
|
||||
AllyBuildRadius: False
|
||||
|
||||
@@ -163,7 +163,6 @@ ServerTraits:
|
||||
LobbySettingsNotification
|
||||
|
||||
LobbyDefaults:
|
||||
Crates: true
|
||||
StartingUnitsClass: light
|
||||
FragileAlliances: false
|
||||
Shroud: true
|
||||
|
||||
@@ -156,7 +156,6 @@ ServerTraits:
|
||||
LobbySettingsNotification
|
||||
|
||||
LobbyDefaults:
|
||||
Crates: true
|
||||
StartingUnitsClass: none
|
||||
FragileAlliances: false
|
||||
Shroud: true
|
||||
|
||||
@@ -166,7 +166,6 @@ ServerTraits:
|
||||
LobbySettingsNotification
|
||||
|
||||
LobbyDefaults:
|
||||
Crates: true
|
||||
StartingUnitsClass: none
|
||||
FragileAlliances: false
|
||||
Shroud: true
|
||||
|
||||
@@ -215,7 +215,6 @@ ServerTraits:
|
||||
LobbySettingsNotification
|
||||
|
||||
LobbyDefaults:
|
||||
Crates: true
|
||||
StartingUnitsClass: none
|
||||
FragileAlliances: false
|
||||
Shroud: true
|
||||
|
||||
Reference in New Issue
Block a user