forked from CnCNet/WorldAlteringEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd Map Reveal Trigger.cs
More file actions
71 lines (60 loc) · 2.28 KB
/
Add Map Reveal Trigger.cs
File metadata and controls
71 lines (60 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Script for adding a map reveal trigger
// Using clauses.
// Unless you know what's in the WAE code-base, you want to always include
// these "standard usings".
using System;
using TSMapEditor;
using TSMapEditor.Models;
using TSMapEditor.CCEngine;
using TSMapEditor.Rendering;
using TSMapEditor.GameMath;
using TSMapEditor.UI.Windows;
namespace WAEScript
{
public class AddMapRevealTrigger
{
/// <summary>
/// Returns the description of this script.
/// All scripts must contain this function.
/// </summary>
public string GetDescription() => "This script will create a new map reveal trigger. Continue?";
/// <summary>
/// Returns the message that is presented to the user if running this script succeeded.
/// All scripts must contain this function.
/// </summary>
public string GetSuccessMessage()
{
if (error == null)
return $"Successfully created a map reveal trigger with name \"{mapRevealTriggerName}\". You can locate it in the Triggers window.";
return error;
}
private string error;
private const string mapRevealTriggerName = "Map Reveal Trigger";
/// <summary>
/// The function that actually does the magic.
/// </summary>
/// <param name="map">Map argument that allows us to access map data.</param>
public void Perform(Map map)
{
var trigger = new Trigger(map.GetNewUniqueInternalId());
trigger.Name = mapRevealTriggerName;
trigger.HouseType = "Neutral";
var timeElapsedCondition = new TriggerCondition();
timeElapsedCondition.ConditionIndex = 13;
timeElapsedCondition.Parameters[0] = "0";
trigger.Conditions.Add(timeElapsedCondition);
var mapRevealAction = new TriggerAction();
mapRevealAction.ActionIndex = 16;
mapRevealAction.Parameters[0] = "0";
trigger.Actions.Add(mapRevealAction);
map.AddTrigger(trigger);
map.AddTag(new Tag()
{
ID = map.GetNewUniqueInternalId(),
Name = trigger.Name + " (tag)",
Trigger = trigger,
Repeating = 0
});
}
}
}