Elin Modding Docs Doc
Loading...
Searching...
No Matches
CardActor.cs
1using System;
2using UnityEngine;
3
4// Token: 0x02000172 RID: 370
5public class CardActor : Actor
6{
7 // Token: 0x170002B4 RID: 692
8 // (get) Token: 0x06000ACA RID: 2762 RVA: 0x00042A93 File Offset: 0x00040C93
9 public virtual bool isPCC
10 {
11 get
12 {
13 return false;
14 }
15 }
16
17 // Token: 0x170002B5 RID: 693
18 // (get) Token: 0x06000ACB RID: 2763 RVA: 0x00042A96 File Offset: 0x00040C96
19 public virtual int currentDir
20 {
21 get
22 {
23 return 0;
24 }
25 }
26
27 // Token: 0x06000ACC RID: 2764 RVA: 0x00042A99 File Offset: 0x00040C99
28 private void Awake()
29 {
30 this.originalScale = base.transform.localScale;
31 }
32
33 // Token: 0x06000ACD RID: 2765 RVA: 0x00042AAC File Offset: 0x00040CAC
34 public void SetOwner(Card t)
35 {
36 base.gameObject.SetActive(true);
37 this.owner = t;
38 if (this.mpb == null)
39 {
40 this.mpb = new MaterialPropertyBlock();
41 }
42 this.mpb.SetColor("_Mat", EMono.Colors.matColors.TryGetValue(t.material.alias, null).main);
43 if (this.sr)
44 {
45 this.sr.SetPropertyBlock(this.mpb);
46 }
47 if (this.sr2)
48 {
49 if (this.mpb2 == null)
50 {
51 this.mpb2 = new MaterialPropertyBlock();
52 }
53 this.mpb2.SetColor("_Mat", Color.white);
54 this.sr2.SetPropertyBlock(this.mpb2);
55 }
56 this.OnSetOwner();
57 if (Application.isEditor)
58 {
59 base.gameObject.name = this.owner.Name;
60 }
61 if (this.type == CardActor.Type.Boat)
62 {
63 this.srAnime.SetData(this.owner.id + "_anime");
64 }
65 this.RefreshSprite();
66 }
67
68 // Token: 0x06000ACE RID: 2766 RVA: 0x00042BC5 File Offset: 0x00040DC5
69 public virtual void OnSetOwner()
70 {
71 }
72
73 // Token: 0x06000ACF RID: 2767 RVA: 0x00042BC7 File Offset: 0x00040DC7
74 public virtual void IdleFrame()
75 {
76 }
77
78 // Token: 0x06000AD0 RID: 2768 RVA: 0x00042BC9 File Offset: 0x00040DC9
79 public virtual void NextFrame()
80 {
81 }
82
83 // Token: 0x06000AD1 RID: 2769 RVA: 0x00042BCB File Offset: 0x00040DCB
84 public virtual void NextDir()
85 {
86 }
87
88 // Token: 0x06000AD2 RID: 2770 RVA: 0x00042BCD File Offset: 0x00040DCD
89 public virtual int GetFrame()
90 {
91 return 0;
92 }
93
94 // Token: 0x06000AD3 RID: 2771 RVA: 0x00042BD0 File Offset: 0x00040DD0
95 public virtual void OnRender(RenderParam p)
96 {
97 this.SetActive(true);
98 SubPassData current = SubPassData.Current;
99 RenderData data = this.owner.renderer.data;
100 if (data.useOffsetBack && this.owner != EMono.pc.held && (data.symmetry ? (p.dir % 2 == 1) : (p.dir == 1 || p.dir == 2)))
101 {
102 CardActor.tempV.x = p.x + data.offsetBack.x + current.offset.x;
103 CardActor.tempV.y = p.y + data.offsetBack.y + current.offset.y;
104 CardActor.tempV.z = p.z + data.offsetBack.z + current.offset.z;
105 }
106 else
107 {
108 CardActor.tempV.x = p.x + data.offset.x + current.offset.x;
109 CardActor.tempV.y = p.y + data.offset.y + current.offset.y;
110 CardActor.tempV.z = p.z + data.offset.z + current.offset.z;
111 }
112 if (this.isPCC)
113 {
114 RenderDataPcc renderDataPcc = data as RenderDataPcc;
115 CharaActorPCC charaActorPCC = this as CharaActorPCC;
116 CardActor.tempV.x = (float)((int)(CardActor.tempV.x * 100f)) * 0.01f;
117 CardActor.tempV.y = (float)((int)(CardActor.tempV.y * 100f)) * 0.01f;
118 CardActor.tempV2.x = charaActorPCC.provider.vCurrent.source.size.x * current.scale.x;
119 CardActor.tempV2.y = charaActorPCC.provider.vCurrent.source.size.y * current.scale.y;
120 CardActor.tempV2.z = renderDataPcc._scale.z * current.scale.z;
121 base.transform.localRotation = current.rotation;
122 }
123 else
124 {
125 CardActor.tempV2.x = this.originalScale.x * current.scale.x;
126 CardActor.tempV2.y = this.originalScale.y * current.scale.y;
127 CardActor.tempV2.z = this.originalScale.z * current.scale.z;
128 }
129 if (this.type == CardActor.Type.Boat)
130 {
131 float floatY = EMono.scene.screenElin.tileMap.floatY;
132 int floatV = EMono.scene.screenElin.tileMap.floatV;
133 this.sr2.transform.localPosition = new Vector3(0f, -0.005f * floatY, this.sr2.transform.localPosition.z);
134 if (floatV == 1)
135 {
136 if (floatY < 2f)
137 {
138 }
139 }
140 else if (floatY < 3f)
141 {
142 }
143 int index;
144 if (floatV == 1)
145 {
146 if (floatY < 0f)
147 {
148 index = 0;
149 }
150 else if (floatY < 3f)
151 {
152 index = 1;
153 }
154 else
155 {
156 index = 2;
157 }
158 }
159 else if (floatY < 2f)
160 {
161 index = 0;
162 }
163 else if (floatY < 5f)
164 {
165 index = 3;
166 }
167 else
168 {
169 index = 2;
170 }
171 this.srAnime.sr.sprite = this.srAnime.data.GetSprites().TryGet(index, -1);
172 }
173 base.transform.position = CardActor.tempV;
174 base.transform.localScale = CardActor.tempV2;
175 this.destLiquid = Mathf.Lerp(this.destLiquid, (float)p.liquidLv, Core.gameDelta * (float)((this.destLiquid > (float)p.liquidLv) ? 90 : 20));
176 this.mpb.SetFloat("_MatColor", p.matColor);
177 this.mpb.SetFloat("_Color", p.color);
178 this.mpb.SetFloat("_Liquid", this.destLiquid);
179 this.sr.SetPropertyBlock(this.mpb);
180 if (this.sr2)
181 {
182 if (this.sr2.sprite)
183 {
184 this.mpb2.SetTexture("_MainTex", this.sr2.sprite.texture);
185 }
186 this.mpb2.SetTexture("_MaskTex", this.sr.sprite.texture);
187 this.mpb2.SetFloat("_MatColor", p.matColor);
188 this.mpb2.SetFloat("_Color", p.color);
189 this.mpb2.SetFloat("_Liquid", this.destLiquid);
190 this.sr2.SetPropertyBlock(this.mpb2);
191 }
192 if (this.owner.sourceCard.replacer.data != null)
193 {
194 SpriteData data2 = this.owner.sourceCard.replacer.data;
195 if (data2.frame > 1)
196 {
197 this.spriteTimer += Core.delta;
198 if (this.spriteTimer >= data2.time)
199 {
200 this.spriteTimer -= data2.time;
201 this.spriteIndex++;
202 if (this.spriteIndex >= data2.frame)
203 {
204 this.spriteIndex = 0;
205 }
206 this.sr.sprite = ((data2.spritesSnow != null && p.snow) ? data2.spritesSnow[this.spriteIndex] : data2.sprites[this.spriteIndex]);
207 }
208 }
209 }
210 }
211
212 // Token: 0x06000AD4 RID: 2772 RVA: 0x000431C0 File Offset: 0x000413C0
213 public virtual void RefreshSprite()
214 {
215 switch (this.type)
216 {
217 case CardActor.Type.Boat:
218 this.sr2.SetActive(this.owner.Cell.IsFloorWater);
219 break;
220 case CardActor.Type.Canvas:
221 if (this.owner != null && this.owner.c_textureData != null && this.sr2)
222 {
223 this.sr2.sprite = this.owner.GetPaintSprite();
224 TraitCanvas traitCanvas = this.owner.trait as TraitCanvas;
225 if (traitCanvas != null)
226 {
227 this.sr2.transform.SetLocalScale(traitCanvas.Scale, traitCanvas.Scale, 1f);
228 }
229 }
230 break;
231 case CardActor.Type.MultiSprite:
232 this.sr2.sprite = this.owner.GetSprite(0);
233 break;
234 }
235 int dir = this.owner.dir;
236 Sprite sprite = this.sr.sprite = (this.sr.sprite = this.owner.GetSprite(dir));
237 this.sr.flipX = ((dir == 1 || dir == 3) && (this.owner.Thing == null || !this.owner.Thing.isEquipped));
238 this.mpb.SetTexture("_MainTex", sprite.texture);
239 Vector4 value = new Vector4(sprite.textureRect.min.x / (float)sprite.texture.width, sprite.textureRect.min.y / (float)sprite.texture.height, sprite.textureRect.max.x / (float)sprite.texture.width, sprite.textureRect.max.y / (float)sprite.texture.height);
240 this.mpb.SetVector("_Rect", value);
241 this.mpb.SetFloat("_PixelHeight", sprite.rect.height);
242 if (this.sr2)
243 {
244 if (this.sr2.sprite && this.sr2.sprite.texture)
245 {
246 this.sr2.flipX = (dir == 1 || dir == 3);
247 sprite = this.sr2.sprite;
248 if (sprite)
249 {
250 Rect textureRect = sprite.textureRect;
251 value = new Vector4(sprite.textureRect.min.x / (float)sprite.texture.width, sprite.textureRect.min.y / (float)sprite.texture.height, sprite.textureRect.max.x / (float)sprite.texture.width, sprite.textureRect.max.y / (float)sprite.texture.height);
252 this.mpb2.SetTexture("_MainTex", sprite.texture);
253 this.mpb2.SetVector("_Rect", value);
254 this.mpb2.SetFloat("_PixelHeight", sprite.rect.height);
255 return;
256 }
257 }
258 else
259 {
260 this.sr2.sprite = null;
261 }
262 }
263 }
264
265 // Token: 0x06000AD5 RID: 2773 RVA: 0x00043531 File Offset: 0x00041731
266 public virtual void Kill()
267 {
268 PoolManager.Despawn(base.transform);
269 }
270
271 // Token: 0x040009E8 RID: 2536
272 public Card owner;
273
274 // Token: 0x040009E9 RID: 2537
275 public SpriteRenderer sr;
276
277 // Token: 0x040009EA RID: 2538
278 public SpriteRenderer sr2;
279
280 // Token: 0x040009EB RID: 2539
281 public SpriteReplacerAnimation srAnime;
282
283 // Token: 0x040009EC RID: 2540
284 public MaterialPropertyBlock mpb;
285
286 // Token: 0x040009ED RID: 2541
287 public MaterialPropertyBlock mpb2;
288
289 // Token: 0x040009EE RID: 2542
290 public CardActor.Type type;
291
292 // Token: 0x040009EF RID: 2543
293 private float destLiquid;
294
295 // Token: 0x040009F0 RID: 2544
296 private float spriteTimer;
297
298 // Token: 0x040009F1 RID: 2545
299 private int spriteIndex;
300
301 // Token: 0x040009F2 RID: 2546
302 private Vector3 originalScale;
303
304 // Token: 0x040009F3 RID: 2547
305 protected static Vector3 tempV;
306
307 // Token: 0x040009F4 RID: 2548
308 protected static Vector3 tempV2;
309
310 // Token: 0x02000882 RID: 2178
311 public enum Type
312 {
313 // Token: 0x04002468 RID: 9320
314 Default,
315 // Token: 0x04002469 RID: 9321
316 Boat,
317 // Token: 0x0400246A RID: 9322
318 Canvas,
319 // Token: 0x0400246B RID: 9323
321 }
322}
Definition Actor.cs:5
Definition Card.cs:13
Definition EMono.cs:6