Add "Spawn Child Actor" checkbox in the map editor actor properties.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Player receives a unit for free once the building is placed. This also works for structures.",
|
||||
"If you want more than one unit to appear copy this section and assign IDs like FreeActor@2, ...")]
|
||||
public class FreeActorInfo : ConditionalTraitInfo
|
||||
public class FreeActorInfo : ConditionalTraitInfo, IEditorActorOptions
|
||||
{
|
||||
[ActorReference]
|
||||
[FieldLoader.Require]
|
||||
@@ -32,6 +33,26 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Whether another actor should spawn upon re-enabling the trait.")]
|
||||
public readonly bool AllowRespawn = false;
|
||||
|
||||
[Desc("Display order for the free actor checkbox in the map editor")]
|
||||
public readonly int EditorFreeActorDisplayOrder = 4;
|
||||
|
||||
IEnumerable<EditorActorOption> IEditorActorOptions.ActorOptions(ActorInfo ai, World world)
|
||||
{
|
||||
yield return new EditorActorCheckbox("Spawn Child Actor", EditorFreeActorDisplayOrder,
|
||||
actor =>
|
||||
{
|
||||
var init = actor.Init<FreeActorInit>();
|
||||
if (init != null)
|
||||
return init.Value(world);
|
||||
|
||||
return true;
|
||||
},
|
||||
(actor, value) =>
|
||||
{
|
||||
actor.ReplaceInit(new FreeActorInit(value));
|
||||
});
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new FreeActor(init, this); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user