1+ // Script for disabling all debug triggers in WAE.
2+
3+ // Using clauses.
4+ // Unless you know what's in the WAE code-base, you want to always include
5+ // these "standard usings".
6+ using System ;
7+ using TSMapEditor ;
8+ using TSMapEditor . Models ;
9+ using TSMapEditor . CCEngine ;
10+ using TSMapEditor . Rendering ;
11+ using TSMapEditor . GameMath ;
12+ using TSMapEditor . UI . Windows ;
13+ using Rampastring . XNAUI ;
14+
15+ namespace WAEScript
16+ {
17+ public class DisableAllDebugTriggersScript
18+ {
19+ /// <summary>
20+ /// Returns the description of this script.
21+ /// All scripts must contain this function.
22+ /// </summary>
23+ public string GetDescription ( ) => "This script will disable all triggers with 'debug' in their name (case insensitive). Continue?" ;
24+
25+ /// <summary>
26+ /// Returns the message that is presented to the user if running this script succeeded.
27+ /// All scripts must contain this function.
28+ /// </summary>
29+ public string GetSuccessMessage ( )
30+ {
31+ if ( error == null )
32+ return $ "Successfully disabled all { debugTriggerCount } debug triggers.";
33+
34+ return error ;
35+ }
36+
37+ private string error ;
38+
39+ private const string debugString = "debug" ;
40+ private int debugTriggerCount ;
41+
42+ /// <summary>
43+ /// The function that actually does the magic.
44+ /// </summary>
45+ /// <param name="map">Map argument that allows us to access map data.</param>
46+ public void Perform ( Map map )
47+ {
48+ var debugTriggers = map . Triggers . FindAll ( trigger => trigger . Name . Contains ( debugString , StringComparison . CurrentCultureIgnoreCase ) ) ;
49+ if ( debugTriggers . Count == 0 )
50+ {
51+ error = "No debug triggers found!" ;
52+ return ;
53+ }
54+
55+ foreach ( var debugTrigger in debugTriggers )
56+ {
57+ debugTrigger . Disabled = true ;
58+ }
59+
60+ debugTriggerCount = debugTriggers . Count ;
61+ }
62+ }
63+ }
0 commit comments