Elin Decompiled Documentation EA 23.247 Stable Patch 1
Loading...
Searching...
No Matches
CharaRenderer.cs
Go to the documentation of this file.
1using UnityEngine;
2
4{
5 public new Chara owner;
6
7 public Vector3 orgPos;
8
9 private float moveTimer;
10
11 private float nextframeTimer;
12
13 public bool first = true;
14
15 public bool ignoreFirst;
16
17 public Point movePoint = new Point();
18
19 public AnimationCurve hopCurve;
20
21 public PCCData pccData;
22
23 private float actTime = 0.3f;
24
25 private float lastShadowFix;
26
27 private float lastShadowFix2;
28
29 public int step;
30
31 public bool isMoving;
32
33 public static int _animeFramePC;
34
35 public static int _animeFramePCC;
36
37 public static int _animeFrame;
38
39 public static bool smoothmove;
40
41 public int currentDir
42 {
43 get
44 {
45 if (!hasActor)
46 {
47 if (!owner.flipX)
48 {
49 return 1;
50 }
51 return 0;
52 }
53 return actor.currentDir;
54 }
55 }
56
57 public override bool IsMoving => isMoving;
58
59 public override void SetOwner(Card c)
60 {
61 owner = c as Chara;
62 owner.spriteReplacer = null;
63 if (pccData != null)
64 {
65 data = ((pccData.GetBodySet2().id == "unique") ? EClass.core.refs.renderers.pcc_L : EClass.core.refs.renderers.pcc);
66 }
67 else if (replacer == null && !owner.c_idSpriteReplacer.IsEmpty())
68 {
70 if (spriteReplacer != null)
71 {
72 data = ResourceCache.Load<RenderData>("Scene/Render/Data/chara_custom_" + ((spriteReplacer.data.GetSprite().texture.height <= 128) ? "128" : "256"));
73 owner.spriteReplacer = spriteReplacer;
74 }
75 }
76 if (owner.source.moveAnime == "hop")
77 {
79 }
80 base.SetOwner(c);
81 }
82
83 public override void OnEnterScreen()
84 {
85 base.OnEnterScreen();
86 if (!ignoreFirst)
87 {
88 first = true;
89 }
90 ignoreFirst = false;
91 nextframeTimer = 0f;
93 {
94 EClass.player.enemySpotted = true;
95 }
96 }
97
98 public override void Draw(RenderParam p, ref Vector3 v, bool drawShadow)
99 {
100 base.Draw(p, ref v, drawShadow);
101 if ((Zone.sourceHat != null || owner.hat != null) && owner.host == null)
102 {
103 DrawHat();
104 }
105 if (owner.IsPC)
106 {
108 {
109 DrawHeld();
110 }
111 }
112 else if (owner.held != null && !owner.IsDeadOrSleeping && !owner.held.trait.ShowAsTool)
113 {
114 DrawHeld();
115 }
116 }
117
118 public override void NextFrame()
119 {
120 base.NextFrame();
121 owner.idleTimer = RenderObject.animeSetting.idleTime;
122 }
123
124 public override void UpdatePosition(ref Vector3 destPos, RenderParam p)
125 {
126 bool isPC = owner.IsPC;
127 int num = (isPC ? _animeFramePC : ((pccData != null) ? _animeFramePCC : _animeFrame));
128 bool flag = isPC || num >= 10;
129 if (num == 0 || Scene.skipAnime || first || !data.animate || (owner.IsDeadOrSleeping && pccData != null && !owner.IsPC))
130 {
131 first = false;
132 position = destPos;
133 if (isPC)
134 {
135 EClass.player.position = position;
136 }
138 step = 9999999;
139 isMoving = false;
140 moveTimer = 0f;
142 p.x = position.x;
143 p.y = position.y;
144 p.z = position.z;
146 return;
147 }
149 {
150 if (RenderObject.gameSpeed > 1f)
151 {
152 p.shadowFix = (lastShadowFix = 0f);
153 }
154 else
155 {
156 p.shadowFix = (lastShadowFix = lastShadowFix2);
157 }
162 step = 1;
163 if (!isMoving)
164 {
165 isMoving = true;
166 nextframeTimer = (RenderObject.animeSetting.nextFrameInterval + actTime / 4f) / 2f;
167 }
168 moveTimer = 0f;
169 }
170 if (num < 100)
171 {
172 num = (int)((float)num / 0.3f * actTime);
173 }
174 float num2 = (actTime + ((!isPC && owner.IsPCParty) ? RenderObject.animeSetting.animeExtraTimeParty : RenderObject.animeSetting.animeExtraTime) * RenderObject.gameSpeed) / (float)num;
176 if (step >= num)
177 {
178 if (position == destPos)
179 {
180 if (isMoving && isPC)
181 {
182 EClass.player.position = position;
183 }
184 isMoving = false;
185 moveTimer = 0f;
186 }
187 else if (!flag)
188 {
189 position = destPos;
190 }
191 else if (moveTimer >= num2)
192 {
193 int num3 = (int)(moveTimer / num2);
194 moveTimer -= (float)num3 * num2;
195 if (Vector3.Distance(position, destPos) < RenderObject.animeSetting.destRadius)
196 {
197 position = destPos;
198 if (isMoving && isPC)
199 {
200 EClass.player.position = position;
201 }
202 isMoving = false;
203 }
204 else
205 {
206 position.z = destPos.z;
207 Vector3 vector = Vector3.MoveTowards(position, destPos, (float)num3 * RenderObject.animeSetting.slowSpeed / (float)step);
208 position = vector;
209 }
210 }
211 if (owner.idleTimer > 0f)
212 {
213 owner.idleTimer -= RenderObject.gameDelta;
214 if (flag && owner.idleTimer <= 0f)
215 {
216 IdleFrame();
217 nextframeTimer = 0f;
218 }
219 }
220 p.x = position.x;
221 p.y = position.y;
222 p.z = position.z;
224 if (isPC)
225 {
226 CellDetail detail = EClass.pc.Cell.detail;
227 if (detail == null || detail.anime == null)
228 {
229 position.z = destPos.z;
230 Vector3 vector2 = Vector3.MoveTowards(position, destPos, 0.1f);
231 position = vector2;
232 EClass.player.position = Vector3.Lerp(EClass.player.position, position, 0.6f);
233 }
234 }
235 return;
236 }
237 if (moveTimer >= num2)
238 {
239 int num4 = (int)(moveTimer / num2);
240 step += num4;
241 moveTimer -= (float)num4 * num2;
242 if (step >= num)
243 {
244 step = num;
245 }
246 }
247 owner.idleTimer = RenderObject.animeSetting.idleTime;
248 float num5 = (float)step / (float)num;
249 p.shadowFix = p.shadowFix * num5 + lastShadowFix * (1f - num5);
251 Vector3 vector3 = orgPos + (destPos - orgPos) * num5 * ((flag && smoothmove) ? RenderObject.animeSetting.fixedMove : 1f);
252 if (destPos.z < orgPos.z)
253 {
254 vector3.z = orgPos.z + (destPos.z - orgPos.z) * RenderObject.animeSetting.gradientZForward.Evaluate(num5);
255 }
256 else
257 {
258 vector3.z = orgPos.z + (destPos.z - orgPos.z) * RenderObject.animeSetting.gradientZBack.Evaluate(num5);
259 }
260 position = vector3;
261 if (hasActor)
262 {
264 {
265 nextframeTimer += RenderObject.gameDelta * 0.5f;
266 float nextFrameInterval = RenderObject.animeSetting.nextFrameInterval;
267 if (nextframeTimer > nextFrameInterval)
268 {
269 if (owner.ai is AI_Trolley)
270 {
272 }
273 else
274 {
276 }
277 nextframeTimer -= nextFrameInterval;
278 }
279 }
280 else
281 {
283 float num6 = RenderObject.animeSetting.nextFrameInterval + actTime / 4f * (0.5f + RenderObject.gameSpeed / 2f);
284 if (nextframeTimer > num6)
285 {
286 if (owner.ai is AI_Trolley)
287 {
289 }
290 else
291 {
293 }
294 nextframeTimer -= num6;
295 }
296 }
297 }
298 p.x = position.x;
299 p.y = position.y;
300 p.z = position.z;
301 if (isPC)
302 {
303 EClass.player.position = vector3;
304 }
305 else if (!hasActor && num >= 5 && hopCurve != null)
306 {
307 p.y += hopCurve.Evaluate(num5) * RenderObject.animeSetting.hopStrength;
308 }
309 }
310
311 public void DrawHat()
312 {
313 if (pccData != null)
314 {
316 {
317 return;
318 }
319 }
320 else if (owner.conSleep != null && owner.host == null && owner.pos.Equals(EClass.pc.pos) && owner.IsHuman && owner.GetBool(123))
321 {
322 return;
323 }
324 CardRow cardRow = Zone.sourceHat ?? owner.hat;
325 SourcePref pref = GetPref();
326 if (pref.hatY != 0f)
327 {
328 bool flag = currentDir == 1 || currentDir == 3;
329 int liquidLv = RenderObject.currentParam.liquidLv;
330 float num = ((replacer != null) ? replacer.pref.hatY : pref.hatY);
331 if (pccData != null)
332 {
333 num += RenderObject.renderSetting.hatPos[actor.GetFrame()].y;
334 }
335 RenderObject.currentParam.liquidLv = 0;
336 RenderObject.currentParam.x += 0.01f * (float)pref.equipX;
337 RenderObject.currentParam.y += num + 0.01f * (float)(pref.equipY + cardRow.pref.equipY);
338 RenderObject.currentParam.z += -0.09f;
339 RenderObject.currentParam.tile = cardRow._tiles[owner.uid % cardRow._tiles.Length] * ((!flag) ? 1 : (-1));
340 RenderObject.currentParam.mat = cardRow.DefaultMaterial;
341 RenderObject.currentParam.matColor = cardRow.GetColorInt(RenderObject.currentParam.mat);
343 RenderObject.currentParam.x -= 0.01f * (float)pref.equipX;
344 RenderObject.currentParam.y -= num + 0.01f * (float)(pref.equipY + cardRow.pref.equipY);
345 RenderObject.currentParam.z -= -0.09f;
346 RenderObject.currentParam.liquidLv = liquidLv;
347 }
348 }
349
350 public override void DrawHeld()
351 {
352 Card held = owner.held;
353 int num = currentDir;
354 RenderData renderData = held.renderer.data;
355 SourcePref pref = held.Pref;
356 bool flag = num == 1 || num == 3;
357 if (held.isChara)
358 {
359 Vector3[] array = (EClass.player.altHeldPos ? RenderObject.renderSetting.heldPosChara2 : RenderObject.renderSetting.heldPosChara);
360 RenderObject.currentParam.x += array[num].x;
361 RenderObject.currentParam.y += array[num].y;
362 RenderObject.currentParam.z += array[num].z + data.offset.z - renderData.offset.z;
364 {
365 held.SetDir((owner.dir == 0) ? 2 : ((owner.dir == 1) ? 1 : ((owner.dir != 2) ? 3 : 0)));
366 }
367 else
368 {
369 held.SetDir((owner.dir == 0) ? 2 : owner.dir);
370 }
371 }
372 else
373 {
374 Vector3[] heldPos = RenderObject.renderSetting.heldPos;
375 if (hasActor)
376 {
377 RenderObject.currentParam.x += heldPos[num].x;
378 RenderObject.currentParam.y += heldPos[num].y + 0.02f * (float)(actor.GetFrame() % 2);
379 RenderObject.currentParam.z += heldPos[num].z + data.offset.z - renderData.offset.z;
380 }
381 else
382 {
383 RenderObject.currentParam.x += heldPos[4].x;
384 RenderObject.currentParam.y += heldPos[4].y;
385 RenderObject.currentParam.z += heldPos[4].z + data.offset.z - renderData.offset.z;
386 }
387 if (held.trait.NoHeldDir || !held.sourceCard.ContainsTag("noHeldDir"))
388 {
389 held.dir = (owner.flipX ? 1 : 0);
390 }
391 }
392 if (!owner.Cell.sourceSurface.tileType.IsDeepWater)
393 {
394 int liquidLv = RenderObject.currentParam.liquidLv;
395 if (held.isChara)
396 {
397 RenderObject.currentParam.liquidLv = 0;
398 }
400 RenderObject.currentParam.x += renderData.heldPos.x - renderData.offset.x + (flag ? 0.01f : (-0.01f)) * (float)pref.equipX;
401 RenderObject.currentParam.y += renderData.heldPos.y - renderData.offset.y + 0.01f * (float)pref.equipY;
402 RenderObject.currentParam.z += renderData.heldPos.z;
403 RenderObject.tempV.x = RenderObject.currentParam.x;
404 RenderObject.tempV.y = RenderObject.currentParam.y;
405 RenderObject.tempV.z = RenderObject.currentParam.z;
406 held.renderer.Draw(RenderObject.currentParam, ref RenderObject.tempV, drawShadow: false);
407 RenderObject.currentParam.liquidLv = liquidLv;
408 }
409 }
410
411 public override void RefreshStateIcon()
412 {
413 if (!isSynced)
414 {
415 return;
416 }
417 TCState tCState = GetTC<TCState>();
418 MultiSprite stateIcon = owner.ai.GetStateIcon();
419 if (stateIcon == null)
420 {
421 if ((bool)tCState)
422 {
423 RemoveTC(tCState);
424 }
425 return;
426 }
427 if (!tCState)
428 {
429 tCState = AddTC<TCState>(PoolManager.Spawn(EClass.core.refs.tcs.state));
430 }
431 tCState.SetSprite(stateIcon);
432 }
433
434 public override void SetFirst(bool first)
435 {
436 this.first = first;
438 }
439
440 public override void SetFirst(bool first, Vector3 pos)
441 {
442 this.first = first;
444 position = pos;
445 if (owner.IsPC)
446 {
447 EClass.player.position = position;
448 }
450 step = 9999999;
451 isMoving = false;
452 moveTimer = 0f;
453 }
454
455 public override void Refresh()
456 {
457 }
458}
override MultiSprite GetStateIcon()
Definition: AIAct.cs:129
bool GetBool(int id)
Definition: BaseCard.cs:15
virtual int currentDir
Definition: CardActor.cs:41
virtual void NextFrame()
Definition: CardActor.cs:90
virtual void IdleFrame()
Definition: CardActor.cs:86
virtual int GetFrame()
Definition: CardActor.cs:98
override void Draw(RenderParam p)
Definition: CardRenderer.cs:53
SourcePref GetPref()
RendererReplacer replacer
Definition: CardRenderer.cs:29
Vector3 position
Definition: CardRenderer.cs:21
void RefreshSprite()
virtual void IdleFrame()
CardActor actor
Definition: CardRenderer.cs:11
void RemoveTC(TC tc)
Definition: Card.cs:11
virtual void SetDir(int d)
Definition: Card.cs:6233
bool ExistsOnMap
Definition: Card.cs:2085
string c_idSpriteReplacer
Definition: Card.cs:1557
virtual SourcePref Pref
Definition: Card.cs:2107
Point pos
Definition: Card.cs:59
virtual void SetRenderParam(RenderParam p)
Definition: Card.cs:6014
Trait trait
Definition: Card.cs:53
CardRow hat
Definition: Card.cs:63
virtual bool isChara
Definition: Card.cs:2083
Cell Cell
Definition: Card.cs:2055
int dir
Definition: Card.cs:146
virtual CardRow sourceCard
Definition: Card.cs:2131
CardRenderer renderer
Definition: Card.cs:61
TransAnime anime
Definition: CellDetail.cs:21
CellDetail detail
Definition: Cell.cs:92
SourceFloor.Row sourceSurface
Definition: Cell.cs:1059
override void OnEnterScreen()
override void RefreshStateIcon()
static int _animeFramePCC
override void NextFrame()
AnimationCurve hopCurve
override void UpdatePosition(ref Vector3 destPos, RenderParam p)
override void SetFirst(bool first, Vector3 pos)
override void SetOwner(Card c)
override void SetFirst(bool first)
float lastShadowFix2
override void Draw(RenderParam p, ref Vector3 v, bool drawShadow)
Vector3 orgPos
Definition: CharaRenderer.cs:7
static int _animeFramePC
float lastShadowFix
override bool IsMoving
override void Refresh()
new Chara owner
Definition: CharaRenderer.cs:5
static bool smoothmove
static int _animeFrame
override void DrawHeld()
PCCData pccData
float nextframeTimer
Definition: Chara.cs:10
Card held
Definition: Chara.cs:70
float idleTimer
Definition: Chara.cs:120
AIAct ai
Definition: Chara.cs:202
override bool IsPC
Definition: Chara.cs:612
Chara host
Definition: Chara.cs:33
bool CanSeeLos(Card c, int dist=-1)
Definition: Chara.cs:1250
override bool IsPCParty
Definition: Chara.cs:615
bool IsHuman
Definition: Chara.cs:879
override bool flipX
Definition: Chara.cs:547
ConSleep conSleep
Definition: Chara.cs:102
float actTime
Definition: Chara.cs:178
override bool IsDeadOrSleeping
Definition: Chara.cs:573
SourceChara.Row source
Definition: Chara.cs:158
bool IsHostile()
Definition: Chara.cs:6526
new GameConfig game
Definition: CoreConfig.cs:609
GraphicSetting graphic
Definition: CoreConfig.cs:607
RenderData pcc_L
Definition: CoreRef.cs:300
RenderData pcc
Definition: CoreRef.cs:298
TCState state
Definition: CoreRef.cs:240
Renderers renderers
Definition: CoreRef.cs:357
TCs tcs
Definition: CoreRef.cs:353
CoreRef refs
Definition: Core.cs:51
CoreConfig config
Definition: Core.cs:70
Definition: EClass.cs:6
static Core core
Definition: EClass.cs:7
static Zone _zone
Definition: EClass.cs:21
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static GameSetting setting
Definition: EClass.cs:35
RenderSetting render
Definition: GameSetting.cs:301
static bool disableTool
Definition: HotItemHeld.cs:11
bool altHeldPos
Definition: Player.cs:1153
Vector3 position
Definition: Player.cs:1215
Definition: Point.cs:9
Point Set(int _x, int _z)
Definition: Point.cs:503
bool Equals(int _x, int _z)
Definition: Point.cs:960
static Transform Spawn(string id, string path, Transform parent)
Definition: PoolManager.cs:86
bool animate
Definition: RenderData.cs:34
void Draw(RenderParam p, int tile)
Definition: RenderData.cs:128
Vector3 offset
Definition: RenderData.cs:18
Vector3 heldPos
Definition: RenderData.cs:24
static Vector3 tempV
Definition: RenderObject.cs:20
static RenderParam currentParam
Definition: RenderObject.cs:18
static float gameDelta
Definition: RenderObject.cs:6
RenderData data
Definition: RenderObject.cs:34
static float gameSpeed
Definition: RenderObject.cs:8
static GameSetting.RenderSetting.AnimeSetting animeSetting
Definition: RenderObject.cs:12
static GameSetting.RenderSetting renderSetting
Definition: RenderObject.cs:14
SourceMaterial.Row mat
Definition: RenderParam.cs:17
int liquidLv
Definition: RenderParam.cs:7
float shadowFix
Definition: RenderParam.cs:21
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:429
RenderData renderData
Definition: RenderRow.cs:71
SourcePref pref
Definition: RenderRow.cs:68
bool ContainsTag(string _tag)
Definition: RenderRow.cs:148
int[] _tiles
Definition: RenderRow.cs:12
SourceMaterial.Row DefaultMaterial
Definition: RenderRow.cs:86
Definition: Scene.cs:8
static bool skipAnime
Definition: Scene.cs:25
float hatY
Definition: SourcePref.cs:87
virtual bool IsRegion
Definition: Spatial.cs:515
Sprite GetSprite(bool snow=false)
Definition: SpriteData.cs:67
SpriteData data
static Dictionary< string, SpriteReplacer > dictSkins
void SetSprite(MultiSprite _sprites)
Definition: TCState.cs:13
virtual bool ShowAsTool
Definition: Trait.cs:336
virtual bool NoHeldDir
Definition: Trait.cs:352
Definition: Zone.cs:12
static CardRow sourceHat
Definition: Zone.cs:29