Added buildradius checkbox to lobby options
This commit is contained in:
@@ -32,12 +32,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly BaseProviderInfo Info;
|
||||
readonly DeveloperMode devMode;
|
||||
readonly Actor self;
|
||||
readonly bool allyBuildEnabled;
|
||||
readonly bool buildRadiusEnabled;
|
||||
|
||||
Building building;
|
||||
|
||||
int total;
|
||||
int progress;
|
||||
bool allyBuildEnabled;
|
||||
|
||||
public BaseProvider(Actor self, BaseProviderInfo info)
|
||||
{
|
||||
@@ -45,7 +46,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.self = self;
|
||||
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
||||
progress = total = info.InitialDelay;
|
||||
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
||||
var mapBuildRadius = self.World.WorldActor.Trait<MapBuildRadius>();
|
||||
allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
|
||||
buildRadiusEnabled = mapBuildRadius.BuildRadiusEnabled;
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
@@ -74,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
bool ValidRenderPlayer()
|
||||
{
|
||||
return self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer));
|
||||
return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)));
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr)
|
||||
|
||||
@@ -154,7 +154,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
|
||||
{
|
||||
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
|
||||
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
||||
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
|
||||
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
|
||||
|
||||
if (!mapBuildRadius.BuildRadiusEnabled)
|
||||
return null;
|
||||
|
||||
foreach (var bp in world.ActorsWithTrait<BaseProvider>())
|
||||
{
|
||||
@@ -173,10 +177,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public virtual bool IsCloseEnoughToBase(World world, Player p, string buildingName, CPos topLeft)
|
||||
{
|
||||
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
|
||||
if (Adjacent < 0 || p.PlayerActor.Trait<DeveloperMode>().BuildAnywhere)
|
||||
return true;
|
||||
|
||||
if (RequiresBaseProvider && FindBaseProvider(world, p, topLeft) == null)
|
||||
if (mapBuildRadius.BuildRadiusEnabled && RequiresBaseProvider && FindBaseProvider(world, p, topLeft) == null)
|
||||
return false;
|
||||
|
||||
var buildingMaxBounds = Dimensions;
|
||||
@@ -186,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var nearnessCandidates = new List<CPos>();
|
||||
var bi = world.WorldActor.Trait<BuildingInfluence>();
|
||||
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
||||
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
|
||||
|
||||
for (var y = scanStart.Y; y < scanEnd.Y; y++)
|
||||
{
|
||||
|
||||
@@ -23,9 +23,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Prevent the ally build radius state from being changed in the lobby.")]
|
||||
public readonly bool AllyBuildRadiusLocked = false;
|
||||
|
||||
[Desc("Default value of the build radius checkbox in the lobby.")]
|
||||
public readonly bool BuildRadiusEnabled = true;
|
||||
|
||||
[Desc("Prevent the build radius state from being changed in the lobby.")]
|
||||
public readonly bool BuildRadiusLocked = false;
|
||||
|
||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||
{
|
||||
yield return new LobbyBooleanOption("allybuild", "Build off Allies' ConYards", AllyBuildRadiusEnabled, AllyBuildRadiusLocked);
|
||||
|
||||
yield return new LobbyBooleanOption("buildradius", "Limit ConYard Area", BuildRadiusEnabled, BuildRadiusLocked);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new MapBuildRadius(this); }
|
||||
@@ -35,6 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
readonly MapBuildRadiusInfo info;
|
||||
public bool AllyBuildRadiusEnabled { get; private set; }
|
||||
public bool BuildRadiusEnabled { get; private set; }
|
||||
|
||||
public MapBuildRadius(MapBuildRadiusInfo info)
|
||||
{
|
||||
@@ -45,6 +54,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled);
|
||||
BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("buildradius", info.BuildRadiusEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,6 +350,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "ALLYBUILDRADIUS_CHECKBOX", "allybuild" },
|
||||
{ "ALLOWCHEATS_CHECKBOX", "cheats" },
|
||||
{ "CREEPS_CHECKBOX", "creeps" },
|
||||
{ "BUILDRADIUS_CHECKBOX", "buildradius" },
|
||||
};
|
||||
|
||||
foreach (var kv in optionCheckboxes)
|
||||
|
||||
Reference in New Issue
Block a user