Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
CardInspector.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using UnityEngine;
6
7public class CardInspector : EMono
8{
9 public static CardInspector Instance;
10
11 public Card card;
12
13 public List<EditorTag> tags = new List<EditorTag>();
14
15 public string traitVals;
16
17 public string Info
18 {
19 get
20 {
21 if (card != null)
22 {
23 return card.id + "(" + card.NameSimple + ")";
24 }
25 return "";
26 }
27 }
28
29 public string idEditor
30 {
31 get
32 {
33 return card?.c_idEditor;
34 }
35 set
36 {
37 if (card != null)
38 {
39 card.c_idEditor = value;
40 }
41 }
42 }
43
44 public string trait
45 {
46 get
47 {
48 return card?.c_idTrait;
49 }
50 set
51 {
52 if (card != null)
53 {
54 card.c_idTrait = value;
55 }
56 }
57 }
58
59 public string BGM
60 {
61 get
62 {
63 if (card == null || card.refVal == 0)
64 {
65 return "0";
66 }
67 BGMData bGMData = EMono.core.refs.bgms.FirstOrDefault((BGMData a) => a.id == card.refVal);
68 if (!(bGMData == null))
69 {
70 return bGMData.name;
71 }
72 return "0";
73 }
74 set
75 {
76 if (card != null)
77 {
78 card.refVal = value.Split(' ')[0].ToInt();
79 }
80 }
81 }
82
83 public bool IsTape => card?.trait is TraitTape;
84
85 public string spawnList
86 {
87 get
88 {
89 if (card == null || card.c_idRefCard.IsEmpty() || !EMono.editorSources.spawnLists.map.ContainsKey(card.c_idRefCard))
90 {
91 return "-";
92 }
94 if (row != null)
95 {
96 return row.id;
97 }
98 return "-";
99 }
100 set
101 {
102 if (card != null)
103 {
104 card.c_idRefCard = value;
105 }
106 }
107 }
108
109 private IEnumerable<string> _TapeList()
110 {
111 List<string> list = new List<string>();
112 foreach (BGMData bgm in EMono.core.refs.bgms)
113 {
114 list.Add(bgm.name);
115 }
116 return list;
117 }
118
119 private IEnumerable<string> Traits()
120 {
121 IEnumerable<Type> obj = ((card == null || !card.isChara) ? GetInheritedClasses(typeof(Trait), typeof(TraitChara)) : GetInheritedClasses(typeof(TraitChara)));
122 List<string> list = new List<string> { "" };
123 foreach (Type item in obj)
124 {
125 list.Add(item.Name);
126 }
127 return list;
128 }
129
130 private IEnumerable<Type> GetInheritedClasses(Type MyType, Type exclude = null)
131 {
132 return from TheType in Assembly.GetAssembly(MyType).GetTypes()
133 where TheType.IsClass && TheType.IsSubclassOf(MyType) && (exclude == null || !TheType.IsSubclassOf(exclude))
134 select TheType;
135 }
136
137 protected IEnumerable<string> _SpawnList()
138 {
139 return EMono.editorSources.spawnLists.GetListString();
140 }
141
142 private void Awake()
143 {
144 Instance = this;
145 }
146
147 public void SetCard(Card c, bool select = true)
148 {
149 card = c;
150 tags.Clear();
151 if (c != null && !c.c_editorTags.IsEmpty())
152 {
153 string[] array = c.c_editorTags.Split(',');
154 foreach (string text in array)
155 {
156 try
157 {
158 tags.Add(text.ToEnum<EditorTag>());
159 }
160 catch
161 {
162 Debug.Log("No Editor Tag Found:" + text);
163 }
164 }
165 }
167 }
168
169 private void OnValidate()
170 {
171 if (!Application.isPlaying || !EMono.core.IsGameStarted || card == null)
172 {
173 return;
174 }
175 string text = null;
176 bool flag = true;
177 if (tags != null)
178 {
179 foreach (EditorTag tag in tags)
180 {
181 text = text + (flag ? "" : ",") + tag;
182 flag = false;
183 }
184 }
185 card.c_editorTags = text;
186 card.c_editorTraitVal = (traitVals.IsEmpty() ? null : traitVals);
187 }
188}
EditorTag
Definition: EditorTag.cs:2
IEnumerable< string > _SpawnList()
string traitVals
IEnumerable< Type > GetInheritedClasses(Type MyType, Type exclude=null)
void SetCard(Card c, bool select=true)
static CardInspector Instance
Definition: CardInspector.cs:9
List< EditorTag > tags
string spawnList
IEnumerable< string > Traits()
IEnumerable< string > _TapeList()
Definition: Card.cs:11
string c_idTrait
Definition: Card.cs:1625
string c_idEditor
Definition: Card.cs:1589
string c_editorTags
Definition: Card.cs:1601
int refVal
Definition: Card.cs:190
Trait trait
Definition: Card.cs:49
virtual bool isChara
Definition: Card.cs:1959
string c_editorTraitVal
Definition: Card.cs:1613
string c_idRefCard
Definition: Card.cs:1637
List< BGMData > bgms
Definition: CoreRef.cs:365
CoreRef refs
Definition: Core.cs:51
bool IsGameStarted
Definition: Core.cs:84
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static SourceManager editorSources
Definition: EMono.cs:43
SourceSpawnList spawnLists
Definition: Trait.cs:7