Elin Modding Docs Doc
Loading...
Searching...
No Matches
GameUpdater.cs
1using System;
2using System.Collections.Generic;
3using Algorithms;
4using UnityEngine;
5
6// Token: 0x020000AE RID: 174
7public class GameUpdater : EClass
8{
9 // Token: 0x060004B0 RID: 1200 RVA: 0x00020488 File Offset: 0x0001E688
10 public void Reset()
11 {
12 this.area = new GameUpdater.AreaUpdater();
13 this.surface = new GameUpdater.SurfaceUpdater();
14 this.surfaceFast = new GameUpdater.FastSurfaceUpdater();
15 this.fire = new GameUpdater.FireUpdater();
16 this.chara = new GameUpdater.CharaUpdater();
17 this.condition = new GameUpdater.ConditionUpdater();
18 this.thing = new GameUpdater.ThingUpdater();
19 this.sensor = new GameUpdater.SensorUpdater();
20 }
21
22 // Token: 0x060004B1 RID: 1201 RVA: 0x000204F0 File Offset: 0x0001E6F0
23 public unsafe void Update100ms()
24 {
25 if (EClass.game.activeZone.IsPCFaction && EClass.Branch.resources.isDirty)
26 {
27 EClass.Branch.resources.Refresh();
28 }
29 bool flag = EClass.world.weather.CurrentCondition == Weather.Condition.RainHeavy;
30 bool flag2;
31 if (!EClass._map.config.indoor)
32 {
33 if (EClass.pc.IsInActiveZone)
34 {
35 Room room = EClass.pc.pos.cell.room;
36 flag2 = (room != null && room.HasRoof);
37 }
38 else
39 {
40 flag2 = false;
41 }
42 }
43 else
44 {
45 flag2 = true;
46 }
47 bool flag3 = flag2;
48 Room room2 = EClass.pc.pos.cell.room;
49 bool flag4 = room2 != null && room2.data.atrium;
50 float mtpVolume = (EClass._zone.lv <= -2) ? 0f : ((flag3 && !flag4) ? 0.5f : 1f);
51 if (EClass.world.weather.IsRaining && !EClass._map.IsIndoor)
52 {
53 for (int i = 0; i < EClass.setting.weather.splashCount * (flag ? 2 : 1); i++)
54 {
55 Point randomPoint = EClass.screen.GetRandomPoint();
56 if (randomPoint.IsValid)
57 {
58 Cell cell = randomPoint.cell;
59 if (!cell.HasRoof && cell._block == 0 && !randomPoint.IsSky)
60 {
61 if (cell.IsTopWaterAndNoSnow)
62 {
63 EClass.scene.psRainSplash.Emit(*randomPoint.PositionCenter(), Vector3.zero, Rand.Range(0.6f, 1.1f), 0.2f, Color.white);
64 }
65 else
66 {
67 EClass.scene.psRainSplashWater.Emit(*randomPoint.PositionCenter(), Vector3.zero, Rand.Range(0.6f, 1.1f), 0.2f, Color.white);
68 }
69 }
70 }
71 }
72 }
73 if (flag)
74 {
75 this.timerThunder += 0.1f;
76 if (this.timerThunder > EClass.setting.weather.thunerInterval)
77 {
78 if (!EClass._map.IsIndoor)
79 {
80 ScreenFlash.Play("storm" + (EClass.rnd(2) + 1).ToString(), (flag3 && !flag4) ? 0.3f : 1f);
81 }
82 EClass.Sound.Play("Ambience/Random/storm", mtpVolume);
83 this.timerThunder = 0f - Rand.Range(0f, EClass.setting.weather.thunerInterval);
84 }
85 }
86 }
87
88 // Token: 0x060004B2 RID: 1202 RVA: 0x00020794 File Offset: 0x0001E994
89 public void FixedUpdate()
90 {
91 this.recipe.FixedUpdate();
92 if (EClass.scene.paused)
93 {
94 return;
95 }
96 if (this.all == null)
97 {
98 this.all = new GameUpdater.Updater[]
99 {
100 this.area,
101 this.surface,
102 this.surfaceFast,
103 this.fire,
104 this.chara,
105 this.condition,
106 this.sensor,
107 this.thing
108 };
109 }
110 GameUpdater.delta = Core.delta;
111 this.area.FixedUpdate();
112 this.surface.FixedUpdate();
113 this.surfaceFast.FixedUpdate();
114 this.fire.FixedUpdate();
115 this.chara.FixedUpdate();
116 this.condition.FixedUpdate();
117 this.sensor.FixedUpdate();
118 this.thing.FixedUpdate();
119 }
120
121 // Token: 0x060004B3 RID: 1203 RVA: 0x00020878 File Offset: 0x0001EA78
122 public void Update()
123 {
124 if (EClass.game.activeZone == null)
125 {
126 return;
127 }
128 EClass._map.RefreshSunMap();
129 if (EClass.debug.testLOS)
130 {
131 if (EClass._zone.IsRegion)
132 {
133 Zone zone = EClass.game.spatials.Find("palmia");
134 PathProgress pathProgress = PathManager.Instance.RequestPathImmediate(new Point(zone.x - EClass.scene.elomap.minX, zone.y - EClass.scene.elomap.minY), EClass.pc.pos, EClass.pc, PathManager.MoveType.Default, -1, 0);
135 if (pathProgress.HasPath)
136 {
137 Debug.Log(pathProgress.nodes.Count);
138 foreach (PathFinderNode pathFinderNode in pathProgress.nodes)
139 {
140 Point point2 = new Point(pathFinderNode.X, pathFinderNode.Z);
141 EClass.screen.tileMap.passGuideBlock.Add(point2.PositionTopdown(), 20f, 0f);
142 }
143 }
144 }
145 Point hit = Scene.HitPoint;
146 if (hit.IsValid)
147 {
148 for (int i = 0; i < EClass._map.charas.Count; i++)
149 {
150 Chara tg = EClass._map.charas[i];
151 if (Los.IsVisible(hit, tg.pos, null))
152 {
153 Los.IsVisible(hit, tg.pos, delegate(Point point, bool blocked)
154 {
155 EClass.screen.tileMap.passGuideFloor.Add(point, 20f, 0f);
156 if (Input.GetKey(KeyCode.LeftControl))
157 {
158 Debug.Log(tg.Name + ": Distance:" + hit.Distance(tg.pos).ToString());
159 }
160 });
161 }
162 }
163 }
164 }
165 if (EClass.debug.testLOS2)
166 {
167 Point hit = Scene.HitPoint;
168 if (hit.IsValid)
169 {
170 EClass._map.ForeachSphere(hit.x, hit.z, 6f, delegate(Point p)
171 {
172 if (p.IsValid && Los.IsVisible(hit, p, null))
173 {
174 EClass.screen.tileMap.passGuideFloor.Add(p, 20f, 0f);
175 }
176 });
177 }
178 }
179 if (EClass.scene.paused)
180 {
181 return;
182 }
183 GameUpdater.delta = Core.gameDelta;
184 EClass._zone.events.Tick(GameUpdater.delta);
185 this.dateTimer += GameUpdater.delta;
186 if (this.dateTimer > EClass.setting.secsPerHour / 60f)
187 {
188 this.dateTimer = 0f;
189 EClass.world.date.AdvanceMin(1);
190 }
191 this.counterTimer += GameUpdater.delta;
192 if (this.counterTimer > 0.1f)
193 {
194 this.counterTimer = 0f;
195 this.counter++;
196 if (this.counter == 10)
197 {
198 this.counter = 0;
199 }
200 int num = this.counter;
201 if (num == 1)
202 {
203 UIResourceTrack.Refresh();
204 return;
205 }
206 if (num != 5)
207 {
208 return;
209 }
210 if (EClass.Sound.currentAmbience)
211 {
212 EClass.Sound.currentAmbience.TryEmit(EClass.world.date.IsDay, Point.shared.Set(EClass.pc.pos.x + EClass.rnd(5) - EClass.rnd(5), EClass.pc.pos.z).Clamp(false).Position(), 1f);
213 }
214 }
215 }
216
217 // Token: 0x060004B4 RID: 1204 RVA: 0x00020C14 File Offset: 0x0001EE14
218 public string GetText()
219 {
220 if (this.all == null)
221 {
222 return "";
223 }
224 string text = "";
225 foreach (GameUpdater.Updater updater in this.all)
226 {
227 text = string.Concat(new string[]
228 {
229 text,
230 updater.GetType().Name,
231 ": ",
232 updater.updatesPerFrame.ToString(),
233 " / frame ",
234 updater.maxCount.ToString(),
235 " in ",
236 updater.duration.ToString(),
237 "sec \n"
238 });
239 }
240 return text;
241 }
242
243 // Token: 0x0400063B RID: 1595
244 public static float delta;
245
246 // Token: 0x0400063C RID: 1596
247 public GameUpdater.AreaUpdater area;
248
249 // Token: 0x0400063D RID: 1597
250 public GameUpdater.SurfaceUpdater surface;
251
252 // Token: 0x0400063E RID: 1598
253 public GameUpdater.FastSurfaceUpdater surfaceFast;
254
255 // Token: 0x0400063F RID: 1599
256 public GameUpdater.FireUpdater fire;
257
258 // Token: 0x04000640 RID: 1600
259 public GameUpdater.CharaUpdater chara;
260
261 // Token: 0x04000641 RID: 1601
262 public GameUpdater.ConditionUpdater condition;
263
264 // Token: 0x04000642 RID: 1602
265 public GameUpdater.ThingUpdater thing;
266
267 // Token: 0x04000643 RID: 1603
268 public GameUpdater.SensorUpdater sensor;
269
270 // Token: 0x04000644 RID: 1604
271 public RecipeUpdater recipe = new RecipeUpdater();
272
273 // Token: 0x04000645 RID: 1605
274 public GameUpdater.Updater[] all;
275
276 // Token: 0x04000646 RID: 1606
277 private float dateTimer;
278
279 // Token: 0x04000647 RID: 1607
280 private float counterTimer;
281
282 // Token: 0x04000648 RID: 1608
283 private int counter;
284
285 // Token: 0x04000649 RID: 1609
286 private float timerThunder;
287
288 // Token: 0x020007F6 RID: 2038
289 public class Updater : EClass
290 {
291 // Token: 0x06003837 RID: 14391 RVA: 0x0012D107 File Offset: 0x0012B307
292 public virtual void FixedUpdate()
293 {
294 }
295
296 // Token: 0x06003838 RID: 14392 RVA: 0x0012D10C File Offset: 0x0012B30C
297 public void SetUpdatesPerFrame(int _maxcount, float _duration)
298 {
299 this.duration = _duration;
300 this.maxCount = _maxcount;
301 if (this.maxCount <= 0)
302 {
303 this.updatesPerFrame = 0;
304 return;
305 }
306 this._updatesPerFrame += EClass.scene.actionMode.gameSpeed * (float)this.maxCount / (1f / GameUpdater.delta) / this.duration;
307 this.updatesPerFrame = (int)this._updatesPerFrame;
308 this._updatesPerFrame -= (float)this.updatesPerFrame;
309 }
310
311 // Token: 0x04002276 RID: 8822
312 public int index;
313
314 // Token: 0x04002277 RID: 8823
315 public int updatesPerFrame;
316
317 // Token: 0x04002278 RID: 8824
318 public int maxCount;
319
320 // Token: 0x04002279 RID: 8825
321 public float duration = 1f;
322
323 // Token: 0x0400227A RID: 8826
324 public float _updatesPerFrame;
325
326 // Token: 0x0400227B RID: 8827
327 public Point pos = new Point();
328 }
329
330 // Token: 0x020007F7 RID: 2039
332 {
333 // Token: 0x0600383A RID: 14394 RVA: 0x0012D1B0 File Offset: 0x0012B3B0
334 public override void FixedUpdate()
335 {
336 List<Area> listArea = EClass._map.rooms.listArea;
337 if (listArea.Count == 0)
338 {
339 return;
340 }
341 base.SetUpdatesPerFrame(listArea.Count, 1f);
342 for (int i = 0; i < this.updatesPerFrame; i++)
343 {
344 this.index++;
345 if (this.index >= listArea.Count)
346 {
347 this.index = 0;
348 }
349 listArea[this.index].Update();
350 }
351 }
352 }
353
354 // Token: 0x020007F8 RID: 2040
356 {
357 // Token: 0x17001121 RID: 4385
358 // (get) Token: 0x0600383C RID: 14396 RVA: 0x0012D234 File Offset: 0x0012B434
359 public int SizeXZ
360 {
361 get
362 {
363 return EClass._map.SizeXZ;
364 }
365 }
366
367 // Token: 0x17001122 RID: 4386
368 // (get) Token: 0x0600383D RID: 14397 RVA: 0x0012D240 File Offset: 0x0012B440
369 public int Size
370 {
371 get
372 {
373 return EClass._map.Size;
374 }
375 }
376
377 // Token: 0x0600383E RID: 14398 RVA: 0x0012D24C File Offset: 0x0012B44C
378 public override void FixedUpdate()
379 {
380 if (!this.pos.Set(this.x, this.z).IsValid)
381 {
382 this.x = (this.z = 0);
383 }
384 base.SetUpdatesPerFrame(this.SizeXZ, 20f);
385 PropSet propSet = EClass._map.Roaming.raceMap.TryGetValue("fish", null);
386 if (propSet != null)
387 {
388 int num = propSet.num;
389 }
390 bool isRaining = EClass.world.weather.IsRaining;
391 for (int i = 0; i < this.updatesPerFrame; i++)
392 {
393 this.pos.Set(this.x, this.z);
394 SourceObj.Row sourceObj = this.pos.sourceObj;
395 bool flag = this.pos.sourceBlock.id != 0;
396 Cell cell = this.pos.cell;
397 bool flag2 = EClass._map.IsIndoor || cell.HasRoof;
398 if (cell.effect != null)
399 {
400 if (cell.HasFire)
401 {
402 if (isRaining)
403 {
404 this.pos.ModFire(-5);
405 }
406 else if (EClass.rnd(2) == 0)
407 {
408 this.pos.ModFire(-2);
409 }
410 }
411 else if (cell.HasLiquid && (!isRaining || cell.IsTopWater || cell.HasRoof))
412 {
413 EClass._map.ModLiquid(this.pos.x, this.pos.z, -1);
414 }
415 }
416 if (isRaining)
417 {
418 if (!flag2)
419 {
420 if (cell.IsFarmField)
421 {
422 cell.isWatered = true;
423 }
424 if (EClass.rnd(500) == 0 && !flag && !cell.blocked && !cell.HasObj && !cell.IsTopWaterAndNoSnow && !EClass._zone.IsRegion)
425 {
426 EClass._map.SetLiquid(this.pos.x, this.pos.z, 1, EClass.rnd(3) + 1);
427 }
428 }
429 if (EClass.rnd(50) == 0 && cell.decal != 0)
430 {
431 cell.decal = 0;
432 }
433 }
434 this.x++;
435 if (this.x >= this.Size)
436 {
437 this.x = 0;
438 this.z++;
439 if (this.z >= this.Size)
440 {
441 this.z = 0;
442 }
443 }
444 }
445 }
446
447 // Token: 0x0400227C RID: 8828
448 public int x;
449
450 // Token: 0x0400227D RID: 8829
451 public int z;
452 }
453
454 // Token: 0x020007F9 RID: 2041
456 {
457 // Token: 0x06003840 RID: 14400 RVA: 0x0012D4A0 File Offset: 0x0012B6A0
458 public override void FixedUpdate()
459 {
460 if (!this.pos.Set(this.x, this.z).IsValid)
461 {
462 this.x = (this.z = 0);
463 }
464 base.SetUpdatesPerFrame(base.SizeXZ, 1f);
465 for (int i = 0; i < this.updatesPerFrame; i++)
466 {
467 this.pos.Set(this.x, this.z);
468 Cell cell = this.pos.cell;
469 if (cell.effect != null && cell.effect.WillFade)
470 {
471 CellEffect effect = cell.effect;
472 int amount = effect.amount;
473 effect.amount = amount - 1;
474 if (cell.effect.amount <= 0)
475 {
476 EClass._map.SetEffect(this.pos.x, this.pos.z, null);
477 }
478 }
479 this.x++;
480 if (this.x >= base.Size)
481 {
482 this.x = 0;
483 this.z++;
484 if (this.z >= base.Size)
485 {
486 this.z = 0;
487 }
488 }
489 }
490 }
491 }
492
493 // Token: 0x020007FA RID: 2042
495 {
496 // Token: 0x17001123 RID: 4387
497 // (get) Token: 0x06003842 RID: 14402 RVA: 0x0012D5CE File Offset: 0x0012B7CE
498 public virtual LogicalPointManager manager
499 {
500 get
501 {
502 return null;
503 }
504 }
505
506 // Token: 0x17001124 RID: 4388
507 // (get) Token: 0x06003843 RID: 14403 RVA: 0x0012D5D1 File Offset: 0x0012B7D1
508 public virtual float UpdateDuration
509 {
510 get
511 {
512 return 1f;
513 }
514 }
515
516 // Token: 0x17001125 RID: 4389
517 // (get) Token: 0x06003844 RID: 14404 RVA: 0x0012D5D8 File Offset: 0x0012B7D8
518 public virtual bool RefreshTile
519 {
520 get
521 {
522 return true;
523 }
524 }
525
526 // Token: 0x06003845 RID: 14405 RVA: 0x0012D5DC File Offset: 0x0012B7DC
527 public override void FixedUpdate()
528 {
529 List<LogicalPoint> list = this.manager.list;
530 if (list.Count == 0)
531 {
532 return;
533 }
534 base.SetUpdatesPerFrame(list.Count, this.UpdateDuration);
535 for (int i = 0; i < this.updatesPerFrame; i++)
536 {
537 this.index++;
538 if (this.index >= list.Count)
539 {
540 this.index = 0;
541 }
542 list[this.index].Update();
543 }
544 if (this.RefreshTile)
545 {
546 foreach (Point point in this.manager.refreshList)
547 {
548 EClass._map.RefreshSingleTile(point.x, point.z);
549 }
550 }
551 this.manager.refreshList.Clear();
552 }
553 }
554
555 // Token: 0x020007FB RID: 2043
557 {
558 // Token: 0x17001126 RID: 4390
559 // (get) Token: 0x06003847 RID: 14407 RVA: 0x0012D6D8 File Offset: 0x0012B8D8
560 public override LogicalPointManager manager
561 {
562 get
563 {
564 return EClass._map.effectManager;
565 }
566 }
567
568 // Token: 0x17001127 RID: 4391
569 // (get) Token: 0x06003848 RID: 14408 RVA: 0x0012D6E4 File Offset: 0x0012B8E4
570 public override float UpdateDuration
571 {
572 get
573 {
574 return 5f;
575 }
576 }
577 }
578
579 // Token: 0x020007FC RID: 2044
581 {
582 // Token: 0x0600384A RID: 14410 RVA: 0x0012D6F4 File Offset: 0x0012B8F4
583 public override void FixedUpdate()
584 {
585 List<Chara> charas = EClass._map.charas;
586 base.SetUpdatesPerFrame(charas.Count, 1f);
587 for (int i = 0; i < this.updatesPerFrame; i++)
588 {
589 this.index++;
590 if (this.index >= charas.Count)
591 {
592 this.index = 0;
593 }
594 Chara chara = charas[this.index];
595 if (chara.IsAliveInCurrentZone && !chara.IsPC)
596 {
597 chara.FindNewEnemy();
598 }
599 }
600 }
601 }
602
603 // Token: 0x020007FD RID: 2045
605 {
606 // Token: 0x0600384C RID: 14412 RVA: 0x0012D780 File Offset: 0x0012B980
607 public override void FixedUpdate()
608 {
609 if (Game.isPaused)
610 {
611 return;
612 }
613 List<Chara> charas = EClass._map.charas;
614 base.SetUpdatesPerFrame(charas.Count, 0.05f);
615 float gameDelta = Core.gameDelta;
616 for (int i = 0; i < charas.Count; i++)
617 {
618 Chara chara = charas[i];
619 if (Game.isPaused && !chara.IsPC)
620 {
621 break;
622 }
623 chara.roundTimer += gameDelta;
624 float actTime = chara.actTime;
625 if (chara.roundTimer > actTime)
626 {
627 chara.Tick();
628 chara.roundTimer -= actTime;
629 if (chara.ai is GoalEndTurn)
630 {
631 chara.SetNoGoal();
632 return;
633 }
634 if (i > charas.Count)
635 {
636 break;
637 }
638 }
639 }
640 }
641 }
642
643 // Token: 0x020007FE RID: 2046
645 {
646 // Token: 0x0600384E RID: 14414 RVA: 0x0012D83C File Offset: 0x0012BA3C
647 public override void FixedUpdate()
648 {
649 List<Chara> charas = EClass._map.charas;
650 base.SetUpdatesPerFrame(charas.Count, 0.01f * (float)EClass.pc.Speed * (EClass._zone.IsRegion ? 0.1f : 1f));
651 for (int i = 0; i < this.updatesPerFrame; i++)
652 {
653 this.index++;
654 if (this.index >= charas.Count)
655 {
656 this.index = 0;
657 }
658 Chara chara = charas[this.index];
659 for (int j = chara.conditions.Count - 1; j >= 0; j--)
660 {
661 Condition condition = chara.conditions[j];
662 if (condition.TimeBased)
663 {
664 condition.Tick();
665 }
666 if (chara.isDead)
667 {
668 break;
669 }
670 }
671 }
672 }
673 }
674
675 // Token: 0x020007FF RID: 2047
677 {
678 // Token: 0x06003850 RID: 14416 RVA: 0x0012D914 File Offset: 0x0012BB14
679 public override void FixedUpdate()
680 {
681 List<Thing> things = EClass._map.things;
682 base.SetUpdatesPerFrame(things.Count, 1f);
683 for (int i = 0; i < this.updatesPerFrame; i++)
684 {
685 this.index++;
686 if (this.index >= things.Count)
687 {
688 this.index = 0;
689 }
690 Thing thing = things[this.index];
691 if (thing.fov != null)
692 {
693 thing.CalculateFOV();
694 }
695 if (thing.trait.HaveUpdate)
696 {
697 thing.trait.Update();
698 }
699 if ((thing.id == "snow" || thing.id == "flyer") && EClass.rnd(30) == 0 && !thing.IsInstalled && !LayerDragGrid.Instance && !LayerCraft.Instance)
700 {
701 thing.Destroy();
702 }
703 }
704 }
705 }
706}
Definition Cell.cs:10
Definition Chara.cs:12
Definition Game.cs:10
Definition Los.cs:6
Definition Point.cs:11
Definition Room.cs:6
Definition Scene.cs:10
Definition Thing.cs:10
Definition Zone.cs:14