1+ using UnityEngine ;
2+
3+ namespace EG . ScriptableObjectSystem . Editor
4+ {
5+ public class ArgInfo
6+ {
7+ public EventSupportedArgs SupportedType { get ; private set ; }
8+ public string ArgType { get ; private set ; }
9+ public string ArgNamespace { get ; private set ; }
10+
11+ public static ArgInfo CreateStandardArg ( )
12+ {
13+ return new ArgInfo ( EventSupportedArgs . Int ) ;
14+ }
15+
16+ public static ArgInfo CreateStandardArg ( EventSupportedArgs supportedType )
17+ {
18+ return new ArgInfo ( supportedType ) ;
19+ }
20+
21+ public static ArgInfo CreateCustomTypeArg ( string argType , string argNamespace )
22+ {
23+ return new ArgInfo ( EventSupportedArgs . Custom , argType , argNamespace ) ;
24+ }
25+
26+ public void UpdateInfo ( EventSupportedArgs supportedType , string customArgType = null , string argNamespace = null )
27+ {
28+ if ( supportedType != EventSupportedArgs . Custom )
29+ {
30+ if ( ! string . IsNullOrEmpty ( customArgType ) )
31+ {
32+ Debug . LogWarning ( "You´re marking the Arg as standard Type. Custom Arg Type and its namespace are not required and will be ignored." ) ;
33+ }
34+
35+ SetStandardType ( supportedType ) ;
36+ }
37+ else
38+ {
39+ if ( string . IsNullOrEmpty ( customArgType ) )
40+ {
41+ Debug . LogWarning ( "You´re updating the Arg Info with Custom type. You must provide the Type and, optionally, its namespace" ) ;
42+ }
43+
44+ SetCustomType ( supportedType , customArgType , argNamespace ) ;
45+ }
46+ }
47+
48+ public void ForceCustomArg ( )
49+ {
50+ SetCustomType ( EventSupportedArgs . Custom , null , null ) ;
51+ }
52+
53+ private ArgInfo ( EventSupportedArgs supportedType )
54+ {
55+ SetStandardType ( supportedType ) ;
56+ }
57+
58+ private ArgInfo ( EventSupportedArgs supportedType , string customArgType , string argNamespace )
59+ {
60+ SetCustomType ( supportedType , customArgType , argNamespace ) ;
61+ }
62+
63+ private void SetStandardType ( EventSupportedArgs supportedType )
64+ {
65+ SupportedType = supportedType ;
66+ ArgType = SupportedType . ToString ( ) . ToLower ( ) ;
67+ }
68+
69+ private void SetCustomType ( EventSupportedArgs supportedType , string customArgType , string argNamespace )
70+ {
71+ SupportedType = supportedType ;
72+ ArgType = customArgType ;
73+ ArgNamespace = argNamespace ;
74+ }
75+ }
76+ }
0 commit comments