-
Notifications
You must be signed in to change notification settings - Fork 3
/
GameStateSMSO.cs
58 lines (56 loc) · 1.62 KB
/
GameStateSMSO.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using SO;
namespace SO.SMachine
{
[CreateAssetMenu(fileName = "GameStateSO", menuName = "SM/Variables/GameState")]
public class GameStateSMSO : VariableSO<GameStateSM>
{
public override void SetValue(string value)
{
IVariableSO parsedVal;
if (IVariableSO.TryParse(value, out parsedVal))
{
try
{
SetValue((GameStateSMSO) parsedVal);
}
catch (Exception e) {
Debug.LogException(e);
}
}
}
public void SetState(GameStateSM value)
{
SetValue(value);
}
public void ForceSetState(GameStateSM value)
{
SetValue(value,true);
}
public override string ToString(string format, IFormatProvider formatProvider = null)
{
if (String.IsNullOrEmpty(format)) format = "N";
if (Value != null)
{
switch (format)
{
case "N":
case "Name":
return Value.name;
case "ID":
case "InstanceID":
return Value.GetInstanceID().ToString();
default:
throw new FormatException(String.Format("The {0} format string is not supported.", format));
}
}
else
{
return "Null";
}
}
}
}