Elin Decompiled Documentation EA 23.318 Nightly
Loading...
Searching...
No Matches
GameUpdater.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Algorithms;
3using UnityEngine;
4
5public class GameUpdater : EClass
6{
7 public class Updater : EClass
8 {
9 public int index;
10
11 public int updatesPerFrame;
12
13 public int maxCount;
14
15 public float duration = 1f;
16
17 public float _updatesPerFrame;
18
19 public Point pos = new Point();
20
21 public virtual void FixedUpdate()
22 {
23 }
24
25 public void SetUpdatesPerFrame(int _maxcount, float _duration)
26 {
27 duration = _duration;
28 maxCount = _maxcount;
29 if (maxCount <= 0)
30 {
32 return;
33 }
34 _updatesPerFrame += EClass.scene.actionMode.gameSpeed * (float)maxCount / (1f / delta) / duration;
37 }
38 }
39
40 public class AreaUpdater : Updater
41 {
42 public override void FixedUpdate()
43 {
44 List<Area> listArea = EClass._map.rooms.listArea;
45 if (listArea.Count == 0)
46 {
47 return;
48 }
49 SetUpdatesPerFrame(listArea.Count, 1f);
50 for (int i = 0; i < updatesPerFrame; i++)
51 {
52 index++;
53 if (index >= listArea.Count)
54 {
55 index = 0;
56 }
57 listArea[index].Update();
58 }
59 }
60 }
61
62 public class SurfaceUpdater : Updater
63 {
64 public int x;
65
66 public int z;
67
68 public int SizeXZ => EClass._map.SizeXZ;
69
70 public int Size => EClass._map.Size;
71
72 public override void FixedUpdate()
73 {
74 if (!pos.Set(x, z).IsValid)
75 {
76 x = (z = 0);
77 }
79 _ = EClass._map.Roaming.raceMap.TryGetValue("fish")?.num;
80 bool isRaining = EClass.world.weather.IsRaining;
81 for (int i = 0; i < updatesPerFrame; i++)
82 {
83 pos.Set(x, z);
84 _ = pos.sourceObj;
85 bool flag = pos.sourceBlock.id != 0;
86 Cell cell = pos.cell;
87 bool flag2 = EClass._map.IsIndoor || cell.HasRoof;
88 if (cell.effect != null)
89 {
90 if (cell.HasFire)
91 {
92 if (isRaining)
93 {
94 pos.ModFire(-5);
95 }
96 else if (EClass.rnd(2) == 0)
97 {
98 pos.ModFire(-2);
99 }
100 }
101 else if (cell.HasLiquid && (!isRaining || cell.IsTopWater || cell.HasRoof))
102 {
103 EClass._map.ModLiquid(pos.x, pos.z, -1);
104 }
105 }
106 if (isRaining)
107 {
108 if (!flag2)
109 {
110 if (cell.IsFarmField)
111 {
112 cell.isWatered = true;
113 }
114 if (EClass.rnd(500) == 0 && !flag && !cell.blocked && !cell.HasObj && !cell.IsTopWaterAndNoSnow && !EClass._zone.IsRegion)
115 {
116 EClass._map.SetLiquid(pos.x, pos.z, 1, EClass.rnd(3) + 1);
117 }
118 }
119 if (EClass.rnd(50) == 0 && cell.decal != 0)
120 {
121 cell.decal = 0;
122 }
123 }
124 if (EClass.rnd(30) == 0 && cell.decal != 0 && !pos.IsInBounds)
125 {
126 cell.decal = 0;
127 }
128 x++;
129 if (x >= Size)
130 {
131 x = 0;
132 z++;
133 if (z >= Size)
134 {
135 z = 0;
136 }
137 }
138 }
139 }
140 }
141
143 {
144 public override void FixedUpdate()
145 {
146 if (!pos.Set(x, z).IsValid)
147 {
148 x = (z = 0);
149 }
150 SetUpdatesPerFrame(base.SizeXZ, 1f);
151 for (int i = 0; i < updatesPerFrame; i++)
152 {
153 pos.Set(x, z);
154 Cell cell = pos.cell;
155 if (cell.effect != null && cell.effect.WillFade)
156 {
157 cell.effect.amount--;
158 if (cell.effect.amount <= 0)
159 {
161 }
162 }
163 if (cell.sourceSurface.id == 20 && EClass.rnd(10) == 0)
164 {
165 EClass._map.TryShatter(pos, 910, 100);
166 }
167 x++;
168 if (x >= base.Size)
169 {
170 x = 0;
171 z++;
172 if (z >= base.Size)
173 {
174 z = 0;
175 }
176 }
177 }
178 }
179 }
180
181 public class LogicUpdater : Updater
182 {
183 public virtual LogicalPointManager manager => null;
184
185 public virtual float UpdateDuration => 1f;
186
187 public virtual bool RefreshTile => true;
188
189 public override void FixedUpdate()
190 {
191 List<LogicalPoint> list = manager.list;
192 if (list.Count == 0)
193 {
194 return;
195 }
197 bool flag = false;
198 for (int i = 0; i < updatesPerFrame; i++)
199 {
200 index++;
201 if (index >= list.Count)
202 {
203 index = 0;
204 flag = true;
205 }
206 list[index].Update();
207 }
208 if (RefreshTile)
209 {
210 foreach (Point refresh in manager.refreshList)
211 {
212 EClass._map.RefreshSingleTile(refresh.x, refresh.z);
213 }
214 }
215 manager.refreshList.Clear();
216 }
217 }
218
220 {
222
223 public override float UpdateDuration => 5f;
224 }
225
226 public class SensorUpdater : Updater
227 {
228 public override void FixedUpdate()
229 {
230 List<Chara> charas = EClass._map.charas;
231 SetUpdatesPerFrame(charas.Count, 1f);
232 for (int i = 0; i < updatesPerFrame; i++)
233 {
234 index++;
235 if (index >= charas.Count)
236 {
237 index = 0;
238 }
239 Chara chara = charas[index];
240 if (chara.IsAliveInCurrentZone && !chara.IsPC)
241 {
242 chara.FindNewEnemy();
243 }
244 }
245 }
246 }
247
248 public class CharaUpdater : Updater
249 {
250 public override void FixedUpdate()
251 {
252 if (Game.isPaused)
253 {
254 return;
255 }
256 List<Chara> charas = EClass._map.charas;
257 float gameDelta = Core.gameDelta;
258 bool flag = false;
259 for (int i = 0; i < charas.Count; i++)
260 {
261 Chara chara = charas[i];
262 if (Game.isPaused && !chara.IsPC)
263 {
264 break;
265 }
266 chara.roundTimer += gameDelta;
267 while (chara.roundTimer > chara.actTime)
268 {
269 chara.Tick();
270 chara.roundTimer -= chara.actTime;
271 if (chara.ai is GoalEndTurn)
272 {
273 chara.SetNoGoal();
274 return;
275 }
276 if (i > charas.Count)
277 {
278 flag = true;
279 break;
280 }
281 }
282 if (flag)
283 {
284 break;
285 }
286 }
287 }
288 }
289
291 {
292 public override void FixedUpdate()
293 {
294 List<Chara> charas = EClass._map.charas;
295 SetUpdatesPerFrame(charas.Count, 0.01f * (float)EClass.pc.Speed * (EClass._zone.IsRegion ? 0.1f : 1f));
296 for (int i = 0; i < updatesPerFrame; i++)
297 {
298 index++;
299 if (index >= charas.Count)
300 {
301 index = 0;
302 }
303 Chara chara = charas[index];
304 for (int num = chara.conditions.Count - 1; num >= 0; num--)
305 {
306 if (num < chara.conditions.Count)
307 {
308 Condition condition = chara.conditions[num];
309 if (condition.TimeBased)
310 {
311 condition.Tick();
312 }
313 if (chara.isDead)
314 {
315 break;
316 }
317 }
318 }
319 }
320 }
321 }
322
323 public class ThingUpdater : Updater
324 {
325 public override void FixedUpdate()
326 {
327 List<Thing> things = EClass._map.things;
328 SetUpdatesPerFrame(things.Count, 1f);
329 for (int i = 0; i < updatesPerFrame; i++)
330 {
331 index++;
332 if (index >= things.Count)
333 {
334 index = 0;
335 }
336 Thing thing = things[index];
337 if (thing.fov != null)
338 {
339 thing.CalculateFOV();
340 }
341 if (thing.trait.HaveUpdate)
342 {
343 thing.trait.Update();
344 }
345 if ((thing.id == "snow" || thing.id == "flyer") && EClass.rnd(30) == 0 && !thing.IsInstalled && !LayerDragGrid.Instance && !LayerCraft.Instance)
346 {
347 thing.Destroy();
348 }
349 }
350 }
351 }
352
353 public static float delta;
354
356
358
360
362
364
366
368
370
372
373 public Updater[] all;
374
375 private float dateTimer;
376
377 private float counterTimer;
378
379 private int counter;
380
381 private float timerThunder;
382
383 public void Reset()
384 {
385 area = new AreaUpdater();
386 surface = new SurfaceUpdater();
388 fire = new FireUpdater();
389 chara = new CharaUpdater();
391 thing = new ThingUpdater();
392 sensor = new SensorUpdater();
393 }
394
395 public void Update100ms()
396 {
398 {
400 }
401 bool flag = EClass.world.weather.CurrentCondition == Weather.Condition.RainHeavy;
402 bool flag2 = EClass._map.config.indoor || (EClass.pc.IsInActiveZone && (EClass.pc.pos.cell.room?.HasRoof ?? false));
403 bool flag3 = EClass.pc.pos.cell.room?.data.atrium ?? false;
404 float mtpVolume = ((EClass._zone.lv <= -2) ? 0f : ((flag2 && !flag3) ? 0.5f : 1f));
406 {
407 for (int i = 0; i < EClass.setting.weather.splashCount * ((!flag) ? 1 : 2); i++)
408 {
409 Point randomPoint = EClass.screen.GetRandomPoint();
410 if (!randomPoint.IsValid)
411 {
412 continue;
413 }
414 Cell cell = randomPoint.cell;
415 if (!cell.HasRoof && cell._block == 0 && !randomPoint.IsSky)
416 {
417 if (cell.IsTopWaterAndNoSnow)
418 {
419 EClass.scene.psRainSplash.Emit(randomPoint.PositionCenter(), Vector3.zero, Rand.Range(0.6f, 1.1f), 0.2f, Color.white);
420 }
421 else
422 {
423 EClass.scene.psRainSplashWater.Emit(randomPoint.PositionCenter(), Vector3.zero, Rand.Range(0.6f, 1.1f), 0.2f, Color.white);
424 }
425 }
426 }
427 }
428 if (!flag)
429 {
430 return;
431 }
432 timerThunder += 0.1f;
434 {
436 {
437 ScreenFlash.Play("storm" + (EClass.rnd(2) + 1), (flag2 && !flag3) ? 0.3f : 1f);
438 }
439 EClass.Sound.Play("Ambience/Random/storm", mtpVolume);
441 }
442 }
443
444 public void FixedUpdate()
445 {
448 {
449 if (all == null)
450 {
452 }
453 delta = Core.delta;
462 }
463 }
464
465 public void Update()
466 {
467 if (EClass.game.activeZone == null)
468 {
469 return;
470 }
472 if (EClass.debug.testLOS)
473 {
475 {
476 Zone zone = EClass.game.spatials.Find("palmia");
478 if (pathProgress.HasPath)
479 {
480 Debug.Log(pathProgress.nodes.Count);
481 foreach (PathFinderNode node in pathProgress.nodes)
482 {
483 Point point2 = new Point(node.X, node.Z);
485 }
486 }
487 }
488 Point hit2 = Scene.HitPoint;
489 if (hit2.IsValid)
490 {
491 for (int i = 0; i < EClass._map.charas.Count; i++)
492 {
493 Chara tg = EClass._map.charas[i];
494 if (!Los.IsVisible(hit2, tg.pos))
495 {
496 continue;
497 }
498 Los.IsVisible(hit2, tg.pos, delegate(Point point, bool blocked)
499 {
501 if (Input.GetKey(KeyCode.LeftControl))
502 {
503 Debug.Log(tg.Name + ": Distance:" + hit2.Distance(tg.pos));
504 }
505 });
506 }
507 }
508 }
510 {
511 Point hit = Scene.HitPoint;
512 if (hit.IsValid)
513 {
514 EClass._map.ForeachSphere(hit.x, hit.z, 6f, delegate(Point p)
515 {
516 if (p.IsValid && Los.IsVisible(hit, p))
517 {
518 EClass.screen.tileMap.passGuideFloor.Add(p, 20f);
519 }
520 });
521 }
522 }
523 if (EClass.scene.paused)
524 {
525 return;
526 }
528 EClass.player.renderExtraTime -= delta;
530 {
531 return;
532 }
534 dateTimer += delta;
536 {
537 dateTimer = 0f;
539 }
541 if (!(counterTimer > 0.1f))
542 {
543 return;
544 }
545 counterTimer = 0f;
546 counter++;
547 if (counter == 10)
548 {
549 counter = 0;
550 }
551 switch (counter)
552 {
553 case 1:
555 break;
556 case 5:
557 if ((bool)EClass.Sound.currentAmbience)
558 {
559 EClass.Sound.currentAmbience.TryEmit(EClass.world.date.IsDay, ref Point.shared.Set(EClass.pc.pos.x + EClass.rnd(5) - EClass.rnd(5), EClass.pc.pos.z).Clamp().Position());
560 }
561 break;
562 }
563 }
564
565 public string GetText()
566 {
567 if (all == null)
568 {
569 return "";
570 }
571 string text = "";
572 Updater[] array = all;
573 foreach (Updater updater in array)
574 {
575 text = text + updater.GetType().Name + ": " + updater.updatesPerFrame + " / frame " + updater.maxCount + " in " + updater.duration + "sec \n";
576 }
577 return text;
578 }
579}
bool atrium
Definition: AreaData.cs:66
AreaData data
Definition: BaseArea.cs:29
Point GetRandomPoint()
BaseTileMap tileMap
MeshPass passGuideBlock
Definition: BaseTileMap.cs:137
MeshPass passGuideFloor
Definition: BaseTileMap.cs:139
Point pos
Definition: Card.cs:60
int amount
Definition: CellEffect.cs:26
bool WillFade
Definition: CellEffect.cs:185
Definition: Cell.cs:7
byte _block
Definition: Cell.cs:32
Room room
Definition: Cell.cs:110
CellEffect effect
Definition: Cell.cs:102
byte decal
Definition: Cell.cs:46
bool IsTopWaterAndNoSnow
Definition: Cell.cs:720
bool IsFarmField
Definition: Cell.cs:738
bool IsTopWater
Definition: Cell.cs:708
bool HasLiquid
Definition: Cell.cs:681
bool HasRoof
Definition: Cell.cs:656
bool HasFire
Definition: Cell.cs:684
bool HasObj
Definition: Cell.cs:649
SourceFloor.Row sourceSurface
Definition: Cell.cs:1069
Definition: Chara.cs:10
int Speed
Definition: Chara.cs:1118
GraphicSetting graphic
Definition: CoreConfig.cs:615
bool testLOS2
Definition: CoreDebug.cs:165
bool testLOS
Definition: CoreDebug.cs:163
Definition: Core.cs:14
static float gameDelta
Definition: Core.cs:21
static float delta
Definition: Core.cs:17
CoreConfig config
Definition: Core.cs:70
bool IsDay
Definition: Date.cs:109
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Scene scene
Definition: EClass.cs:31
static Core core
Definition: EClass.cs:7
static Zone _zone
Definition: EClass.cs:21
static World world
Definition: EClass.cs:41
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static FactionBranch Branch
Definition: EClass.cs:23
static BaseGameScreen screen
Definition: EClass.cs:33
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
static SoundManager Sound
Definition: EClass.cs:47
static GameSetting setting
Definition: EClass.cs:35
int minX
Definition: EloMap.cs:112
int minY
Definition: EloMap.cs:114
HomeResourceManager resources
void AdvanceMin(int a)
Definition: GameDate.cs:22
WeatherSetting weather
Definition: GameSetting.cs:315
float secsPerHour
Definition: GameSetting.cs:321
override void FixedUpdate()
Definition: GameUpdater.cs:42
override void FixedUpdate()
Definition: GameUpdater.cs:250
override void FixedUpdate()
Definition: GameUpdater.cs:292
override LogicalPointManager manager
Definition: GameUpdater.cs:221
override float UpdateDuration
Definition: GameUpdater.cs:223
override void FixedUpdate()
Definition: GameUpdater.cs:189
virtual float UpdateDuration
Definition: GameUpdater.cs:185
virtual bool RefreshTile
Definition: GameUpdater.cs:187
virtual LogicalPointManager manager
Definition: GameUpdater.cs:183
override void FixedUpdate()
Definition: GameUpdater.cs:228
override void FixedUpdate()
Definition: GameUpdater.cs:72
override void FixedUpdate()
Definition: GameUpdater.cs:325
void SetUpdatesPerFrame(int _maxcount, float _duration)
Definition: GameUpdater.cs:25
virtual void FixedUpdate()
Definition: GameUpdater.cs:21
void Update100ms()
Definition: GameUpdater.cs:395
ConditionUpdater condition
Definition: GameUpdater.cs:365
AreaUpdater area
Definition: GameUpdater.cs:355
string GetText()
Definition: GameUpdater.cs:565
FireUpdater fire
Definition: GameUpdater.cs:361
float dateTimer
Definition: GameUpdater.cs:375
CharaUpdater chara
Definition: GameUpdater.cs:363
void FixedUpdate()
Definition: GameUpdater.cs:444
SurfaceUpdater surface
Definition: GameUpdater.cs:357
void Update()
Definition: GameUpdater.cs:465
Updater[] all
Definition: GameUpdater.cs:373
static float delta
Definition: GameUpdater.cs:353
float counterTimer
Definition: GameUpdater.cs:377
SensorUpdater sensor
Definition: GameUpdater.cs:369
void Reset()
Definition: GameUpdater.cs:383
RecipeUpdater recipe
Definition: GameUpdater.cs:371
ThingUpdater thing
Definition: GameUpdater.cs:367
FastSurfaceUpdater surfaceFast
Definition: GameUpdater.cs:359
float timerThunder
Definition: GameUpdater.cs:381
Definition: Game.cs:9
static bool isPaused
Definition: Game.cs:150
SpatialManager spatials
Definition: Game.cs:153
Zone activeZone
Definition: Game.cs:252
static LayerCraft Instance
Definition: LayerCraft.cs:8
static LayerDragGrid Instance
HashSet< Point > refreshList
List< LogicalPoint > list
Definition: Los.cs:5
static bool IsVisible(Point p1, Point p2, Action< Point, bool > _onVisit=null)
Definition: Los.cs:167
int Size
Definition: MapBounds.cs:20
bool IsIndoor
Definition: Map.cs:131
void ForeachSphere(int _x, int _z, float r, Action< Point > action)
Definition: Map.cs:2438
void RefreshSunMap()
Definition: Map.cs:2800
void RefreshSingleTile(int x, int z)
Definition: Map.cs:2148
int SizeXZ
Definition: Map.cs:133
void SetLiquid(int x, int z, CellEffect effect=null)
Definition: Map.cs:1522
PropsRoaming Roaming
Definition: Map.cs:125
List< Thing > things
Definition: Map.cs:49
void ModLiquid(int x, int z, int amount)
Definition: Map.cs:1558
void TryShatter(Point pos, int ele, int power, Card CC=null)
Definition: Map.cs:1221
RoomManager rooms
Definition: Map.cs:31
void SetEffect(int x, int z, CellEffect effect=null)
Definition: Map.cs:1553
CellEffectManager effectManager
Definition: Map.cs:89
List< Chara > charas
Definition: Map.cs:81
void Add(Point point, float tile=0f, float color=0f)
Definition: MeshPass.cs:122
void RequestPathImmediate(PathProgress progress)
Definition: PathManager.cs:41
static PathManager Instance
Definition: PathManager.cs:16
List< PathFinderNode > nodes
Definition: PathProgress.cs:16
float renderExtraTime
Definition: Player.cs:1273
Definition: Point.cs:9
static Point shared
Definition: Point.cs:20
ref Vector3 Position(int height)
Definition: Point.cs:553
bool IsSky
Definition: Point.cs:224
Point Set(int _x, int _z)
Definition: Point.cs:503
ref Vector3 PositionTopdown()
Definition: Point.cs:574
int x
Definition: Point.cs:36
void ModFire(int value, bool extinguish=false)
Definition: Point.cs:939
int z
Definition: Point.cs:39
ref Vector3 PositionCenter()
Definition: Point.cs:592
SourceObj.Row sourceObj
Definition: Point.cs:69
bool IsValid
Definition: Point.cs:88
Point Clamp(bool useBounds=false)
Definition: Point.cs:1014
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
Dictionary< string, PropSet > raceMap
Definition: Props.cs:14
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:49
void FixedUpdate()
List< Area > listArea
Definition: RoomManager.cs:10
bool HasRoof
Definition: Room.cs:29
Definition: Scene.cs:8
ParticleSystem psRainSplashWater
Definition: Scene.cs:117
static Point HitPoint
Definition: Scene.cs:21
ParticleSystem psRainSplash
Definition: Scene.cs:115
EloMap elomap
Definition: Scene.cs:149
bool paused
Definition: Scene.cs:140
static void Play(string id, float mtp=1f)
Definition: ScreenFlash.cs:24
Zone Find(string id)
virtual bool IsRegion
Definition: Spatial.cs:515
int y
Definition: Spatial.cs:106
int x
Definition: Spatial.cs:94
Definition: Thing.cs:8
static void Refresh()
Condition
Definition: Weather.cs:16
bool IsRaining
Definition: Weather.cs:117
GameDate date
Definition: World.cs:6
Weather weather
Definition: World.cs:12
void Tick(float delta)
Definition: Zone.cs:12
ZoneEventManager events
Definition: Zone.cs:40
bool IsPCFaction
Definition: Zone.cs:477