Elin Modding Docs Doc
Loading...
Searching...
No Matches
Critter.cs
1using System;
2using UnityEngine;
3
4// Token: 0x02000668 RID: 1640
5public class Critter : EClass
6{
7 // Token: 0x17000D0C RID: 3340
8 // (get) Token: 0x06002DF4 RID: 11764 RVA: 0x001010A7 File Offset: 0x000FF2A7
9 public virtual int[] animeTiles
10 {
11 get
12 {
13 return null;
14 }
15 }
16
17 // Token: 0x17000D0D RID: 3341
18 // (get) Token: 0x06002DF5 RID: 11765 RVA: 0x001010AA File Offset: 0x000FF2AA
19 public virtual int[] idleTiles
20 {
21 get
22 {
23 return null;
24 }
25 }
26
27 // Token: 0x17000D0E RID: 3342
28 // (get) Token: 0x06002DF6 RID: 11766 RVA: 0x001010AD File Offset: 0x000FF2AD
29 public virtual int AnimeTile
30 {
31 get
32 {
33 return this.animeTiles[this.index % this.animeTiles.Length];
34 }
35 }
36
37 // Token: 0x17000D0F RID: 3343
38 // (get) Token: 0x06002DF7 RID: 11767 RVA: 0x001010C5 File Offset: 0x000FF2C5
39 public virtual int IdleTile
40 {
41 get
42 {
43 return this.idleTiles[this.index % this.idleTiles.Length];
44 }
45 }
46
47 // Token: 0x17000D10 RID: 3344
48 // (get) Token: 0x06002DF8 RID: 11768 RVA: 0x001010DD File Offset: 0x000FF2DD
49 public virtual int SnowTile
50 {
51 get
52 {
53 return 0;
54 }
55 }
56
57 // Token: 0x17000D11 RID: 3345
58 // (get) Token: 0x06002DF9 RID: 11769 RVA: 0x001010E0 File Offset: 0x000FF2E0
59 public virtual int Interval
60 {
61 get
62 {
63 return 5;
64 }
65 }
66
67 // Token: 0x17000D12 RID: 3346
68 // (get) Token: 0x06002DFA RID: 11770 RVA: 0x001010E3 File Offset: 0x000FF2E3
69 public virtual float BaseSpeed
70 {
71 get
72 {
73 return 1f;
74 }
75 }
76
77 // Token: 0x06002DFB RID: 11771 RVA: 0x001010EC File Offset: 0x000FF2EC
78 public static Critter Create(Cell cell)
79 {
80 BiomeProfile biomeProfile = cell.sourceFloor.biome ?? EClass.core.refs.biomes.Plain;
81 if (biomeProfile == null)
82 {
83 return null;
84 }
85 if (cell.IsTopWater)
86 {
87 if (EClass.rnd(12) == 0)
88 {
89 return new CritterFish();
90 }
91 return null;
92 }
93 else
94 {
95 if (biomeProfile.id == BiomeID.Snow)
96 {
97 return null;
98 }
99 if (EClass.rnd(12) == 0)
100 {
101 return new CritterFrog();
102 }
103 if (EClass.rnd(6) == 0)
104 {
105 return new CritterFrogSmall();
106 }
107 if (EClass.rnd(12) == 0)
108 {
109 return new CritterCancer();
110 }
111 if (EClass.rnd(6) == 0)
112 {
113 return new CritterCancerSmall();
114 }
115 if (EClass.rnd(12) == 0)
116 {
117 return new CritterRat();
118 }
119 if (EClass.rnd(6) == 0)
120 {
121 return new CritterRatSmall();
122 }
123 if (EClass.rnd(12) == 0)
124 {
125 return new CritterRoach();
126 }
127 if (EClass.rnd(6) == 0)
128 {
129 return new CritterRoachSmall();
130 }
131 return new CritterRandom();
132 }
133 }
134
135 // Token: 0x06002DFC RID: 11772 RVA: 0x001011C5 File Offset: 0x000FF3C5
136 public static void RebuildCritter(Cell cell)
137 {
138 cell.critter = null;
139 if (cell.sourceObj.id == 68)
140 {
141 cell.critter = new CritterFish();
142 }
143 }
144
145 // Token: 0x06002DFD RID: 11773 RVA: 0x001011E8 File Offset: 0x000FF3E8
146 public void Update()
147 {
148 float gameDelta = Core.gameDelta;
149 this.animeTimer -= gameDelta * this.speed * 100f;
150 if (this.animeTimer < 0f)
151 {
152 this.index++;
153 this.animeTimer = 2f;
154 }
155 if (this.dir.x != 0f || this.dir.y != 0f)
156 {
157 this.tile = this.AnimeTile;
158 }
159 else
160 {
161 this.tile = this.IdleTile;
162 }
163 this.dirTimer -= gameDelta;
164 if (this.dirTimer < 0f)
165 {
166 this.dirTimer = (float)(this.Interval + EClass.rnd(this.Interval) / 2);
167 this.dir.x = (float)(EClass.rnd(3) - 1);
168 this.dir.y = (float)(EClass.rnd(3) - 1);
169 this.speed = 0.01f * (float)(EClass.rnd(20) + 1) * this.BaseSpeed;
170 this.reverse = (this.dir.x > 0f);
171 }
172 this.x += this.dir.x * gameDelta * this.speed;
173 if (this.x > 0.12f)
174 {
175 this.x = 0.12f;
176 this.dir.x = 0f;
177 }
178 else if (this.x < -0.12f)
179 {
180 this.x = -0.12f;
181 this.dir.x = 0f;
182 }
183 this.y += this.dir.y * gameDelta * this.speed;
184 if (this.y > 0.12f)
185 {
186 this.y = 0.12f;
187 this.dir.y = 0f;
188 return;
189 }
190 if (this.y < -0.12f)
191 {
192 this.y = -0.12f;
193 this.dir.y = 0f;
194 }
195 }
196
197 // Token: 0x04001A03 RID: 6659
198 public const float R = 0.12f;
199
200 // Token: 0x04001A04 RID: 6660
201 public int tile;
202
203 // Token: 0x04001A05 RID: 6661
204 public int index;
205
206 // Token: 0x04001A06 RID: 6662
207 public Vector2 dir;
208
209 // Token: 0x04001A07 RID: 6663
210 public float x;
211
212 // Token: 0x04001A08 RID: 6664
213 public float y;
214
215 // Token: 0x04001A09 RID: 6665
216 public float dirTimer;
217
218 // Token: 0x04001A0A RID: 6666
219 public float animeTimer;
220
221 // Token: 0x04001A0B RID: 6667
222 public float speed = 0.1f;
223
224 // Token: 0x04001A0C RID: 6668
225 public bool reverse;
226}
Definition Cell.cs:10