Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StringSwitchInstruction.cs
Go to the documentation of this file.
3
5
6internal sealed class StringSwitchInstruction : Instruction
7{
9
10 private readonly StrongBox<int> _nullCase;
11
12 public override string InstructionName => "StringSwitch";
13
14 public override int ConsumedStack => 1;
15
21
22 public override int Run(InterpretedFrame frame)
23 {
24 object obj = frame.Pop();
25 if (obj == null)
26 {
27 return _nullCase.Value;
28 }
29 if (!_cases.TryGetValue((string)obj, out var value))
30 {
31 return 1;
32 }
33 return value;
34 }
35}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
StringSwitchInstruction(Dictionary< string, int > cases, StrongBox< int > nullCase)