Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IfAction.cs
Go to the documentation of this file.
2
3internal class IfAction : ContainerAction
4{
11
12 private readonly ConditionType _type;
13
14 private int _testKey = -1;
15
17 {
18 _type = type;
19 }
20
21 internal override void Compile(Compiler compiler)
22 {
24 if (_type != ConditionType.ConditionOtherwise)
25 {
27 }
28 if (compiler.Recurse())
29 {
31 compiler.ToParent();
32 }
33 }
34
35 internal override bool CompileAttribute(Compiler compiler)
36 {
37 string localName = compiler.Input.LocalName;
38 string value = compiler.Input.Value;
39 if (Ref.Equal(localName, compiler.Atoms.Test))
40 {
41 if (_type == ConditionType.ConditionOtherwise)
42 {
43 return false;
44 }
45 _testKey = compiler.AddBooleanQuery(value);
46 return true;
47 }
48 return false;
49 }
50
51 internal override void Execute(Processor processor, ActionFrame frame)
52 {
53 switch (frame.State)
54 {
55 case 0:
56 if ((_type == ConditionType.ConditionIf || _type == ConditionType.ConditionWhen) && !processor.EvaluateBoolean(frame, _testKey))
57 {
58 frame.Finished();
59 break;
60 }
61 processor.PushActionFrame(frame);
62 frame.State = 1;
63 break;
64 case 1:
65 if (_type == ConditionType.ConditionWhen || _type == ConditionType.ConditionOtherwise)
66 {
67 frame.Exit();
68 }
69 frame.Finished();
70 break;
71 }
72 }
73}
static bool Equal(string strA, string strB)
Definition Ref.cs:5
void CompileAttributes(Compiler compiler)
void CheckRequiredAttribute(Compiler compiler, object attrValue, string attrName)
override bool CompileAttribute(Compiler compiler)
Definition IfAction.cs:35
override void Compile(Compiler compiler)
Definition IfAction.cs:21
IfAction(ConditionType type)
Definition IfAction.cs:16
readonly ConditionType _type
Definition IfAction.cs:12
override void Execute(Processor processor, ActionFrame frame)
Definition IfAction.cs:51