Add support for arbitrary objective type names

This commit is contained in:
abcdefg30
2019-03-07 19:46:06 +01:00
committed by reaperrr
parent 38b3a4a668
commit b2278e85f0
5 changed files with 33 additions and 35 deletions

View File

@@ -29,12 +29,20 @@ namespace OpenRA.Mods.Common.Scripting
shortGame = player.World.WorldActor.Trait<MapOptions>().ShortGame;
}
[ScriptActorPropertyActivity]
[Desc("Add a mission objective for this player. The function returns the " +
"ID of the newly created objective, so that it can be referred to later.")]
public int AddObjective(string description, string type = "Primary", bool required = true)
{
return mo.Add(Player, description, type, required);
}
[ScriptActorPropertyActivity]
[Desc("Add a primary mission objective for this player. The function returns the " +
"ID of the newly created objective, so that it can be referred to later.")]
public int AddPrimaryObjective(string description)
{
return mo.Add(Player, description, ObjectiveType.Primary);
return AddObjective(description);
}
[ScriptActorPropertyActivity]
@@ -42,7 +50,7 @@ namespace OpenRA.Mods.Common.Scripting
"ID of the newly created objective, so that it can be referred to later.")]
public int AddSecondaryObjective(string description)
{
return mo.Add(Player, description, ObjectiveType.Secondary);
return AddObjective(description, "Secondary", false);
}
[ScriptActorPropertyActivity]
@@ -106,7 +114,7 @@ namespace OpenRA.Mods.Common.Scripting
if (id < 0 || id >= mo.Objectives.Count)
throw new LuaException("Objective ID is out of range.");
return mo.Objectives[id].Type == ObjectiveType.Primary ? "Primary" : "Secondary";
return mo.Objectives[id].Type;
}
[ScriptActorPropertyActivity]