Move crates option to rules.
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user