Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Hoard.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using System.Runtime.Serialization;
4using Newtonsoft.Json;
5using UnityEngine;
6
7public class Hoard : EClass
8{
9 public enum Mode
10 {
11 all,
12 lux,
13 junk
14 }
15
16 public class Item : EClass
17 {
18 [JsonProperty]
19 public string id;
20
21 [JsonProperty]
22 public int[] ints = new int[5];
23
25
26 public int num
27 {
28 get
29 {
30 return ints[1];
31 }
32 set
33 {
34 ints[1] = value;
35 }
36 }
37
38 public int show
39 {
40 get
41 {
42 return ints[2];
43 }
44 set
45 {
46 ints[2] = value;
47 }
48 }
49
50 public bool random
51 {
52 get
53 {
54 return bits[0];
55 }
56 set
57 {
58 bits[0] = value;
59 }
60 }
61
62 public bool floating
63 {
64 get
65 {
66 return bits[1];
67 }
68 set
69 {
70 bits[1] = value;
71 }
72 }
73
75 {
76 get
77 {
78 if (!EClass.sources.collectibles.initialized)
79 {
81 }
82 return EClass.sources.collectibles.map[id];
83 }
84 }
85
86 public bool IsUnique => Source.tag.Contains("unique");
87
89 internal void OnSerializing(StreamingContext context)
90 {
91 ints[0] = (int)bits.Bits;
92 }
93
95 internal void _OnDeserialized(StreamingContext context)
96 {
97 bits.Bits = (uint)ints[0];
98 }
99
100 public string Name(int n)
101 {
102 return "(" + "collectible".lang() + ") [" + Lang._rarity(Source.rarity) + "] " + Source.GetName() + " x " + n;
103 }
104 }
105
106 public Dictionary<string, Item> items = new Dictionary<string, Item>();
107
108 [JsonProperty]
109 public List<Item> list = new List<Item>();
110
111 [JsonProperty]
112 public Mode mode;
113
114 [JsonProperty]
115 public int bg;
116
117 [JsonProperty]
118 public int reflection = 100;
119
120 [JsonProperty]
121 public int maxSounds = 28;
122
123 [JsonProperty]
124 public int volume = 40;
125
126 [JsonProperty]
127 public int hiScore;
128
129 [JsonProperty]
130 public int score;
131
132 public bool shadow = true;
133
134 public bool voice = true;
135
136 public bool pixelPerfect;
137
138 public bool hentai;
139
141 private void OnDeserialized(StreamingContext context)
142 {
143 foreach (Item item in list)
144 {
145 items.Add(item.id, item);
146 }
147 }
148
149 public Item AddRandom(int r, bool msg = true)
150 {
151 IEnumerable<SourceCollectible.Row> ie = EClass.sources.collectibles.rows.Where((SourceCollectible.Row a) => a.rarity == r);
152 return Add(ie.RandomItem().id, 1, msg);
153 }
154
155 public Item AddRandom(bool msg = true)
156 {
157 string id = EClass.sources.collectibles.rows.RandomItem().id;
158 return Add(id, 1, msg);
159 }
160
161 public Item Add(string id)
162 {
164 int num = ((row.num == 0) ? 10 : row.num);
165 if (num != 1)
166 {
167 num *= 2;
168 }
169 Item item = Add(row.id, num);
170 item.random = true;
171 return item;
172 }
173
174 public Item Add(string id, int num, bool msg = false)
175 {
176 if (num == 0)
177 {
178 return items.TryGetValue(id);
179 }
180 Item value = null;
181 if (!items.TryGetValue(id, out value))
182 {
183 value = new Item
184 {
185 id = id
186 };
187 list.Add(value);
188 items[id] = value;
189 }
190 if (value.num == value.show)
191 {
192 value.show += num;
193 }
194 value.num += num;
195 if (value.IsUnique && value.show > 1)
196 {
197 value.show = 1;
198 }
199 if (msg)
200 {
201 Msg.SetColor(EClass.Colors.GetRarityColor(value.Source.rarity, light: true));
202 Msg.AquireItem(value.Name(num));
203 }
204 if (hentai)
205 {
206 value.show = value.num;
207 }
208 return value;
209 }
210
211 public Sprite GetSprite(string id)
212 {
213 SpriteSheet.Add("UI/Layer/Hoard/Molds/_sprites_hoard");
214 return SpriteSheet.Get("_sprites_hoard_" + id);
215 }
216
217 public GameObject GetActor(string id)
218 {
221 SpriteRenderer spriteRenderer = Object.Instantiate(ResourceCache.Load<SpriteRenderer>("UI/Layer/Hoard/Molds/" + row.prefab.IsEmpty("default")));
222 spriteRenderer.sprite = GetSprite(id);
223 return spriteRenderer.gameObject;
224 }
225
226 public void Clear()
227 {
228 items.Clear();
229 list.Clear();
230 }
231}
Color GetRarityColor(int r, bool light=false)
Definition: EClass.cs:5
static ColorProfile Colors
Definition: EClass.cs:38
static SourceManager sources
Definition: EClass.cs:42
SourceCollectible.Row Source
Definition: Hoard.cs:75
int num
Definition: Hoard.cs:27
BitArray32 bits
Definition: Hoard.cs:24
bool random
Definition: Hoard.cs:51
void _OnDeserialized(StreamingContext context)
Definition: Hoard.cs:95
bool IsUnique
Definition: Hoard.cs:86
bool floating
Definition: Hoard.cs:63
string Name(int n)
Definition: Hoard.cs:100
int[] ints
Definition: Hoard.cs:22
void OnSerializing(StreamingContext context)
Definition: Hoard.cs:89
string id
Definition: Hoard.cs:19
int show
Definition: Hoard.cs:39
Definition: Hoard.cs:8
int reflection
Definition: Hoard.cs:118
GameObject GetActor(string id)
Definition: Hoard.cs:217
bool shadow
Definition: Hoard.cs:132
Item Add(string id, int num, bool msg=false)
Definition: Hoard.cs:174
Mode mode
Definition: Hoard.cs:112
Item Add(string id)
Definition: Hoard.cs:161
int score
Definition: Hoard.cs:130
bool voice
Definition: Hoard.cs:134
int maxSounds
Definition: Hoard.cs:121
bool hentai
Definition: Hoard.cs:138
void Clear()
Definition: Hoard.cs:226
Sprite GetSprite(string id)
Definition: Hoard.cs:211
int bg
Definition: Hoard.cs:115
Item AddRandom(int r, bool msg=true)
Definition: Hoard.cs:149
List< Item > list
Definition: Hoard.cs:109
Item AddRandom(bool msg=true)
Definition: Hoard.cs:155
Dictionary< string, Item > items
Definition: Hoard.cs:106
bool pixelPerfect
Definition: Hoard.cs:136
int hiScore
Definition: Hoard.cs:127
int volume
Definition: Hoard.cs:124
Mode
Definition: Hoard.cs:10
void OnDeserialized(StreamingContext context)
Definition: Hoard.cs:141
Definition: Lang.cs:6
static string _rarity(int a)
Definition: Lang.cs:187
Definition: Msg.cs:5
static void AquireItem(string itemName)
Definition: Msg.cs:140
static void SetColor()
Definition: Msg.cs:22
SourceCollectible collectibles
static void Add(Sprite sprite)
Definition: SpriteSheet.cs:10
static Sprite Get(string id)
Definition: SpriteSheet.cs:28
uint Bits
Definition: BitArray32.cs:6