Allow plugs to be configured in the map editor.
This commit is contained in:
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
public class PluggableInfo : TraitInfo
|
public class PluggableInfo : TraitInfo, IEditorActorOptions
|
||||||
{
|
{
|
||||||
[Desc("Footprint cell offset where a plug can be placed.")]
|
[Desc("Footprint cell offset where a plug can be placed.")]
|
||||||
public readonly CVec Offset = CVec.Zero;
|
public readonly CVec Offset = CVec.Zero;
|
||||||
@@ -32,6 +32,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
"Value is the condition expression defining the requirements to place the plug.")]
|
"Value is the condition expression defining the requirements to place the plug.")]
|
||||||
public readonly Dictionary<string, BooleanExpression> Requirements = new Dictionary<string, BooleanExpression>();
|
public readonly Dictionary<string, BooleanExpression> Requirements = new Dictionary<string, BooleanExpression>();
|
||||||
|
|
||||||
|
[Desc("Options to display in the map editor.",
|
||||||
|
"Key is the plug type that the requirements applies to.",
|
||||||
|
"Value is the label that is displayed in the actor editor dropdown.")]
|
||||||
|
public readonly Dictionary<string, string> EditorOptions = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
[Desc("Label to use for an empty plug socket.")]
|
||||||
|
public readonly string EmptyOption = "Empty";
|
||||||
|
|
||||||
|
[Desc("Display order for the dropdown in the map editor")]
|
||||||
|
public readonly int EditorDisplayOrder = 5;
|
||||||
|
|
||||||
[GrantedConditionReference]
|
[GrantedConditionReference]
|
||||||
public IEnumerable<string> LinterConditions { get { return Conditions.Values; } }
|
public IEnumerable<string> LinterConditions { get { return Conditions.Values; } }
|
||||||
|
|
||||||
@@ -41,6 +52,28 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
get { return Requirements.Values.SelectMany(r => r.Variables).Distinct(); }
|
get { return Requirements.Values.SelectMany(r => r.Variables).Distinct(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEnumerable<EditorActorOption> IEditorActorOptions.ActorOptions(ActorInfo ai, World world)
|
||||||
|
{
|
||||||
|
if (!EditorOptions.Any())
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
// Make sure the no-plug option is always available
|
||||||
|
EditorOptions[""] = EmptyOption;
|
||||||
|
yield return new EditorActorDropdown("Plug", EditorDisplayOrder, EditorOptions,
|
||||||
|
actor =>
|
||||||
|
{
|
||||||
|
var init = actor.GetInitOrDefault<PlugInit>(this);
|
||||||
|
return init != null ? init.Value : "";
|
||||||
|
},
|
||||||
|
(actor, value) =>
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
actor.RemoveInit<PlugInit>(this);
|
||||||
|
else
|
||||||
|
actor.ReplaceInit(new PlugInit(this, value), this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Pluggable(init, this); }
|
public override object Create(ActorInitializer init) { return new Pluggable(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,9 +91,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
|
|
||||||
var plugInit = init.GetValue<PlugsInit, Dictionary<CVec, string>>(info, new Dictionary<CVec, string>());
|
initialPlug = init.GetValue<PlugInit, string>(info, null);
|
||||||
if (plugInit.ContainsKey(Info.Offset))
|
var plugsInit = init.GetValue<PlugsInit, Dictionary<CVec, string>>(new Dictionary<CVec, string>());
|
||||||
initialPlug = plugInit[Info.Offset];
|
if (plugsInit.ContainsKey(Info.Offset))
|
||||||
|
initialPlug = plugsInit[Info.Offset];
|
||||||
|
|
||||||
if (info.Requirements.Count > 0)
|
if (info.Requirements.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -125,4 +159,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public PlugsInit(Dictionary<CVec, string> value)
|
public PlugsInit(Dictionary<CVec, string> value)
|
||||||
: base(value) { }
|
: base(value) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PlugInit : ValueActorInit<string>
|
||||||
|
{
|
||||||
|
public PlugInit(TraitInfo info, string value)
|
||||||
|
: base(info, value) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,14 +208,12 @@ Actors:
|
|||||||
Location: 84,-1
|
Location: 84,-1
|
||||||
TurretFacing: 92
|
TurretFacing: 92
|
||||||
Facing: 60
|
Facing: 60
|
||||||
Plugs:
|
Plug: tower.vulcan
|
||||||
0,0: tower.vulcan
|
|
||||||
Actor56: gactwr
|
Actor56: gactwr
|
||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 80,-3
|
Location: 80,-3
|
||||||
Facing: 60
|
Facing: 60
|
||||||
Plugs:
|
Plug: tower.vulcan
|
||||||
0,0: tower.vulcan
|
|
||||||
Actor57: gawall
|
Actor57: gawall
|
||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 79,-3
|
Location: 79,-3
|
||||||
@@ -247,8 +245,7 @@ Actors:
|
|||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 84,-4
|
Location: 84,-4
|
||||||
Facing: 60
|
Facing: 60
|
||||||
Plugs:
|
Plug: tower.rocket
|
||||||
0,0: tower.rocket
|
|
||||||
Actor67: gawall
|
Actor67: gawall
|
||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 88,-1
|
Location: 88,-1
|
||||||
@@ -295,21 +292,18 @@ Actors:
|
|||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 86,-3
|
Location: 86,-3
|
||||||
Facing: 60
|
Facing: 60
|
||||||
Plugs:
|
Plug@pluga: powrup
|
||||||
0,1: powrup
|
Plug@plugb: powrup
|
||||||
1,1: powrup
|
|
||||||
Actor82: gapowr
|
Actor82: gapowr
|
||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 86,-5
|
Location: 86,-5
|
||||||
Plugs:
|
Plug@pluga: powrup
|
||||||
0,1: powrup
|
Plug@plugb: powrup
|
||||||
1,1: powrup
|
|
||||||
Actor91: gactwr
|
Actor91: gactwr
|
||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 85,-11
|
Location: 85,-11
|
||||||
Facing: -40
|
Facing: -40
|
||||||
Plugs:
|
Plug: tower.vulcan
|
||||||
0,0: tower.vulcan
|
|
||||||
Actor90: gasilo
|
Actor90: gasilo
|
||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 79,-10
|
Location: 79,-10
|
||||||
@@ -326,8 +320,7 @@ Actors:
|
|||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 81,-11
|
Location: 81,-11
|
||||||
Facing: -40
|
Facing: -40
|
||||||
Plugs:
|
Plug: tower.vulcan
|
||||||
0,0: tower.vulcan
|
|
||||||
Actor89: gagate_a
|
Actor89: gagate_a
|
||||||
Owner: GDI
|
Owner: GDI
|
||||||
Location: 82,-11
|
Location: 82,-11
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ GAPOWR:
|
|||||||
powrup: powrup.a
|
powrup: powrup.a
|
||||||
Requirements:
|
Requirements:
|
||||||
powrup: !build-incomplete && !powrup.a
|
powrup: !build-incomplete && !powrup.a
|
||||||
|
EditorOptions:
|
||||||
|
powrup: Power Turbine
|
||||||
Power@pluga:
|
Power@pluga:
|
||||||
RequiresCondition: !empdisable && powrup.a
|
RequiresCondition: !empdisable && powrup.a
|
||||||
Amount: 50
|
Amount: 50
|
||||||
@@ -55,6 +57,8 @@ GAPOWR:
|
|||||||
powrup: powrup.b
|
powrup: powrup.b
|
||||||
Requirements:
|
Requirements:
|
||||||
powrup: !build-incomplete && !powrup.b
|
powrup: !build-incomplete && !powrup.b
|
||||||
|
EditorOptions:
|
||||||
|
powrup: Power Turbine
|
||||||
WithIdleOverlay@plugb:
|
WithIdleOverlay@plugb:
|
||||||
RequiresCondition: !build-incomplete && powrup.b
|
RequiresCondition: !build-incomplete && powrup.b
|
||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
@@ -508,6 +512,9 @@ GAPLUG:
|
|||||||
Requirements:
|
Requirements:
|
||||||
plug.ioncannon: !build-incomplete && !plug.ioncannonb && !plug.ioncannona && !plug.hunterseekera
|
plug.ioncannon: !build-incomplete && !plug.ioncannonb && !plug.ioncannona && !plug.hunterseekera
|
||||||
plug.hunterseeker: !build-incomplete && !plug.hunterseekerb && !plug.ioncannona && !plug.hunterseekera
|
plug.hunterseeker: !build-incomplete && !plug.hunterseekerb && !plug.ioncannona && !plug.hunterseekera
|
||||||
|
EditorOptions:
|
||||||
|
plug.ioncannon: Ion Cannon
|
||||||
|
plug.hunterseeker: Hunter Seeker
|
||||||
WithIdleOverlay@ioncannona:
|
WithIdleOverlay@ioncannona:
|
||||||
RequiresCondition: !build-incomplete && plug.ioncannona
|
RequiresCondition: !build-incomplete && plug.ioncannona
|
||||||
PauseOnCondition: disabled
|
PauseOnCondition: disabled
|
||||||
@@ -524,6 +531,9 @@ GAPLUG:
|
|||||||
Requirements:
|
Requirements:
|
||||||
plug.ioncannon: !build-incomplete && !plug.ioncannona && !plug.ioncannonb && !plug.hunterseekerb
|
plug.ioncannon: !build-incomplete && !plug.ioncannona && !plug.ioncannonb && !plug.hunterseekerb
|
||||||
plug.hunterseeker: !build-incomplete && !plug.hunterseekera && !plug.ioncannonb && !plug.hunterseekerb
|
plug.hunterseeker: !build-incomplete && !plug.hunterseekera && !plug.ioncannonb && !plug.hunterseekerb
|
||||||
|
EditorOptions:
|
||||||
|
plug.ioncannon: Ion Cannon
|
||||||
|
plug.hunterseeker: Hunter Seeker
|
||||||
WithIdleOverlay@ioncannonb:
|
WithIdleOverlay@ioncannonb:
|
||||||
RequiresCondition: !build-incomplete && plug.ioncannonb
|
RequiresCondition: !build-incomplete && plug.ioncannonb
|
||||||
PauseOnCondition: disabled
|
PauseOnCondition: disabled
|
||||||
|
|||||||
@@ -138,6 +138,10 @@ GACTWR:
|
|||||||
tower.vulcan: !build-incomplete && !tower.vulcan && !tower.rocket && !tower.sam
|
tower.vulcan: !build-incomplete && !tower.vulcan && !tower.rocket && !tower.sam
|
||||||
tower.rocket: !build-incomplete && !tower.rocket && !tower.vulcan && !tower.sam
|
tower.rocket: !build-incomplete && !tower.rocket && !tower.vulcan && !tower.sam
|
||||||
tower.sam: !build-incomplete && !tower.vulcan && !tower.rocket && !tower.sam
|
tower.sam: !build-incomplete && !tower.vulcan && !tower.rocket && !tower.sam
|
||||||
|
EditorOptions:
|
||||||
|
tower.vulcan: Vulcan Tower
|
||||||
|
tower.rocket: RPG Upgrade
|
||||||
|
tower.sam: SAM Upgrade
|
||||||
ProvidesPrerequisite@buildingname:
|
ProvidesPrerequisite@buildingname:
|
||||||
ProvidesPrerequisite@pluggable:
|
ProvidesPrerequisite@pluggable:
|
||||||
RequiresCondition: !build-incomplete && !tower.vulcan && !tower.rocket && !tower.sam
|
RequiresCondition: !build-incomplete && !tower.vulcan && !tower.rocket && !tower.sam
|
||||||
|
|||||||
Reference in New Issue
Block a user