Elin Modding Docs Doc
Loading...
Searching...
No Matches
AI_Fish.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x020001F0 RID: 496
6public class AI_Fish : AIAct
7{
8 // Token: 0x170003A4 RID: 932
9 // (get) Token: 0x06000E34 RID: 3636 RVA: 0x0006B85F File Offset: 0x00069A5F
10 public override int MaxRestart
11 {
12 get
13 {
14 return 9999;
15 }
16 }
17
18 // Token: 0x06000E35 RID: 3637 RVA: 0x0006B866 File Offset: 0x00069A66
19 public override bool CanManualCancel()
20 {
21 return true;
22 }
23
24 // Token: 0x170003A5 RID: 933
25 // (get) Token: 0x06000E36 RID: 3638 RVA: 0x0006B869 File Offset: 0x00069A69
26 public override TargetType TargetType
27 {
28 get
29 {
30 return TargetType.Ground;
31 }
32 }
33
34 // Token: 0x06000E37 RID: 3639 RVA: 0x0006B870 File Offset: 0x00069A70
35 public override bool CanPerform()
36 {
37 return Act.TP.cell.IsTopWaterAndNoSnow;
38 }
39
40 // Token: 0x06000E38 RID: 3640 RVA: 0x0006B881 File Offset: 0x00069A81
41 public override AIProgress CreateProgress()
42 {
43 return new AI_Fish.ProgressFish
44 {
45 posWater = this.pos
46 };
47 }
48
49 // Token: 0x06000E39 RID: 3641 RVA: 0x0006B894 File Offset: 0x00069A94
50 public override IEnumerable<AIAct.Status> Run()
51 {
52 if (!this.owner.IsPC)
53 {
54 this.owner.TryPickGroundItem();
55 }
56 if (this.pos != null)
57 {
58 if (!this.pos.cell.IsTopWaterAndNoSnow)
59 {
60 yield return this.Cancel();
61 }
62 yield return base.DoGoto(this.pos, 1, false, null);
63 this.owner.LookAt(this.pos);
64 if (this.owner.IsPC)
65 {
66 EClass.player.TryEquipBait();
67 if (EClass.player.eqBait == null)
68 {
69 Msg.Say("noBait");
70 yield return this.Cancel();
71 }
72 }
73 if (!this.pos.cell.IsTopWaterAndNoSnow || this.owner.Dist(this.pos) > 1)
74 {
75 yield return this.Cancel();
76 }
77 AIAct.Status status = base.DoProgress();
78 if (AI_Fish.shouldCancel)
79 {
80 AI_Fish.shouldCancel = false;
81 yield return this.Cancel();
82 }
83 if (status == AIAct.Status.Running)
84 {
85 yield return AIAct.Status.Running;
86 }
87 if (this.owner == EClass.pc)
88 {
89 yield return base.Restart();
90 }
91 yield return base.DoWait(2);
92 if (this.owner != null)
93 {
94 if (!this.owner.IsPC)
95 {
96 this.owner.TryPickGroundItem();
97 }
98 if (this.owner.IsPCFaction && !this.owner.IsPCParty)
99 {
100 this.owner.ClearInventory(ClearInventoryType.Silent);
101 }
102 }
103 yield return base.Success(null);
104 }
105 if (this.owner.fov == null)
106 {
107 yield return this.Cancel();
108 }
109 List<Point> list = this.owner.fov.ListPoints();
110 foreach (Point p in list)
111 {
112 if (!p.cell.IsTopWaterAndNoSnow)
113 {
114 int num;
115 for (int _x = p.x - 1; _x <= p.x + 1; _x = num + 1)
116 {
117 for (int _z = p.z - 1; _z <= p.z + 1; _z = num + 1)
118 {
119 Point.shared.Set(_x, _z);
120 if (Point.shared.IsValid && Point.shared.cell.IsTopWaterAndNoSnow)
121 {
122 Point dest = Point.shared.Copy();
123 yield return base.DoGoto(dest, 0, false, null);
124 this.owner.LookAt(dest);
125 yield return base.DoProgress();
126 yield return AIAct.Status.Success;
127 dest = null;
128 }
129 num = _z;
130 }
131 num = _x;
132 }
133 p = null;
134 }
135 }
136 List<Point>.Enumerator enumerator = default(List<Point>.Enumerator);
137 yield break;
138 yield break;
139 }
140
141 // Token: 0x06000E3A RID: 3642 RVA: 0x0006B8A4 File Offset: 0x00069AA4
142 public static Point GetFishingPoint(Point p)
143 {
144 Point point = new Point();
145 if (p.cell.IsTopWaterAndNoSnow)
146 {
147 return Point.Invalid;
148 }
149 for (int i = p.x - 1; i <= p.x + 1; i++)
150 {
151 for (int j = p.z - 1; j <= p.z + 1; j++)
152 {
153 point.Set(i, j);
154 if (point.IsValid && point.cell.IsTopWaterAndNoSnow)
155 {
156 return point;
157 }
158 }
159 }
160 return Point.Invalid;
161 }
162
163 // Token: 0x06000E3B RID: 3643 RVA: 0x0006B924 File Offset: 0x00069B24
164 public static Thing Makefish(Chara c)
165 {
166 int num = c.Evalue(245);
167 if (EClass.rnd(3 + num) == 0)
168 {
169 return null;
170 }
171 int[] source = new int[]
172 {
173 233,
174 235,
175 236,
176 236,
177 236,
178 1170,
179 1143,
180 1144,
181 727,
182 728,
183 237,
184 869,
185 1178,
186 1179,
187 1180
188 };
189 int num2 = 1;
190 string text = "";
191 if (c.IsPC || EClass.rnd(20) == 0)
192 {
193 if (EClass.rnd(30) == 0)
194 {
195 text = "book_ancient";
196 }
197 if (EClass.rnd(35) == 0 || EClass.debug.enable)
198 {
199 text = "plat";
200 if (EClass.rnd(2) == 0)
201 {
202 text = "scratchcard";
203 }
204 if (EClass.rnd(3) == 0)
205 {
206 text = "casino_coin";
207 }
208 if (EClass.rnd(3) == 0)
209 {
210 text = "gacha_coin";
211 }
212 if (EClass.rnd(50) == 0 || EClass.debug.enable)
213 {
214 text = new string[]
215 {
216 "659",
217 "758",
218 "759",
219 "806",
220 "828",
221 "1190",
222 "1191"
223 }.RandomItem<string>();
224 }
225 }
226 if (EClass.rnd(30) == 0 && EClass.rnd(100) > num + 10)
227 {
228 text = "medal";
229 }
230 }
231 Thing thing;
232 if (text != "")
233 {
234 thing = ThingGen.Create(text, -1, -1);
235 }
236 else if (EClass.rnd(5 + num / 3) == 0)
237 {
238 thing = ThingGen.Create(source.RandomItem<int>().ToString() ?? "", -1, -1);
239 }
240 else
241 {
242 int num3 = EClass.rnd(num * 2) + 1;
243 thing = ThingGen.Create("fish", -1, num3);
244 num2 = EClass.rnd(num / (num3 + 10)) + 1;
245 int num4 = 5;
246 if (EClass.Branch != null)
247 {
248 num4 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3706) * 25;
249 }
250 if (num4 >= EClass.rnd(100))
251 {
252 num2++;
253 }
254 }
255 if (thing != null)
256 {
257 thing.SetNum(num2);
258 thing.SetBlessedState(BlessedState.Normal);
259 }
260 return thing;
261 }
262
263 // Token: 0x04000D40 RID: 3392
264 public Point pos;
265
266 // Token: 0x04000D41 RID: 3393
267 public static bool shouldCancel;
268
269 // Token: 0x020008DE RID: 2270
271 {
272 // Token: 0x17001170 RID: 4464
273 // (get) Token: 0x06003B88 RID: 15240 RVA: 0x0013BEAB File Offset: 0x0013A0AB
274 public override bool ShowProgress
275 {
276 get
277 {
278 return false;
279 }
280 }
281
282 // Token: 0x17001171 RID: 4465
283 // (get) Token: 0x06003B89 RID: 15241 RVA: 0x0013BEAE File Offset: 0x0013A0AE
284 public override int MaxProgress
285 {
286 get
287 {
288 return 100;
289 }
290 }
291
292 // Token: 0x17001172 RID: 4466
293 // (get) Token: 0x06003B8A RID: 15242 RVA: 0x0013BEB2 File Offset: 0x0013A0B2
294 public override int LeftHand
295 {
296 get
297 {
298 return -1;
299 }
300 }
301
302 // Token: 0x17001173 RID: 4467
303 // (get) Token: 0x06003B8B RID: 15243 RVA: 0x0013BEB5 File Offset: 0x0013A0B5
304 public override int RightHand
305 {
306 get
307 {
308 return 1107;
309 }
310 }
311
312 // Token: 0x06003B8C RID: 15244 RVA: 0x0013BEBC File Offset: 0x0013A0BC
313 public override void OnStart()
314 {
315 if (AI_Fish.shouldCancel)
316 {
317 return;
318 }
319 this.owner.PlaySound("fish_cast", 1f, true);
320 if (this.owner.Tool != null)
321 {
322 this.owner.Say("fish_start", this.owner, this.owner.Tool, null, null);
323 return;
324 }
325 this.owner.Say("fish_start2", this.owner, null, null);
326 }
327
328 // Token: 0x06003B8D RID: 15245 RVA: 0x0013BF34 File Offset: 0x0013A134
329 public override void OnProgress()
330 {
331 if (this.owner.IsPC && (this.owner.Tool == null || !this.owner.Tool.HasElement(245, 1)))
332 {
333 this.Cancel();
334 return;
335 }
336 if (this.hit >= 0)
337 {
338 this.owner.renderer.PlayAnime(AnimeID.Fishing, default(Vector3), false);
339 this.owner.PlaySound("fish_fight", 1f, true);
340 this.Ripple();
341 int a = Mathf.Clamp(10 - EClass.rnd(this.owner.Evalue(245) + 1) / 10, 5, 10);
342 if (this.hit > EClass.rnd(a))
343 {
344 this.hit = 100;
345 this.progress = this.MaxProgress;
346 }
347 this.hit++;
348 return;
349 }
350 if (EClass.rnd(Mathf.Clamp(10 - EClass.rnd(this.owner.Evalue(245) + 1) / 5, 2, 10)) == 0 && this.progress >= 10)
351 {
352 this.hit = 0;
353 }
354 if (this.progress == 2 || (this.progress >= 8 && this.progress % 6 == 0 && EClass.rnd(3) == 0))
355 {
356 this.owner.renderer.PlayAnime(AnimeID.Shiver, default(Vector3), false);
357 this.Ripple();
358 }
359 }
360
361 // Token: 0x06003B8E RID: 15246 RVA: 0x0013C098 File Offset: 0x0013A298
362 public void Ripple()
363 {
364 if (this.posWater != null)
365 {
366 Effect.Get("ripple").Play(this.posWater, -0.04f, null, null);
367 this.posWater.PlaySound("fish_splash", true, 1f, true);
368 }
369 }
370
371 // Token: 0x06003B8F RID: 15247 RVA: 0x0013C0D8 File Offset: 0x0013A2D8
372 public override void OnProgressComplete()
373 {
374 this.owner.renderer.PlayAnime(AnimeID.Fishing, default(Vector3), false);
375 if (this.hit < 100)
376 {
377 this.Fail();
378 return;
379 }
380 if (this.owner.IsPC && !EClass.debug.enable)
381 {
382 if (EClass.player.eqBait == null || EClass.player.eqBait.isDestroyed)
383 {
384 Msg.Say("noBait");
385 return;
386 }
387 EClass.player.eqBait.ModNum(-1, true);
388 }
389 Thing thing = AI_Fish.Makefish(this.owner);
390 if (thing == null)
391 {
392 this.Fail();
393 return;
394 }
395 int num = thing.Num;
396 EClass._zone.AddCard(thing, this.owner.pos);
397 thing.renderer.PlayAnime(AnimeID.Jump, default(Vector3), false);
398 this.owner.Say("fish_get", this.owner, thing, null, null);
399 this.owner.PlaySound("fish_get", 1f, true);
400 this.owner.elements.ModExp(245, 100, false);
401 if (thing.id == "medal")
402 {
403 thing.isHidden = false;
404 }
405 if (this.owner.IsPC)
406 {
407 if (EClass.game.config.preference.pickFish)
408 {
409 if (StatsBurden.GetPhase((EClass.pc.ChildrenWeight + thing.ChildrenAndSelfWeight) * 100 / EClass.pc.WeightLimit) >= 3)
410 {
411 EClass.pc.Say("tooHeavy", thing, null, null);
412 AI_Fish.shouldCancel = true;
413 }
414 else
415 {
416 this.owner.Pick(thing, true, true);
417 }
418 }
419 }
420 else
421 {
422 foreach (Thing thing2 in this.owner.things.List((Thing t) => t.source._origin == "fish", false))
423 {
424 thing2.Destroy();
425 }
426 }
427 if (EClass.rnd(2) == 0 || num > 1)
428 {
429 this.owner.stamina.Mod(-1 * num);
430 }
431 }
432
433 // Token: 0x06003B90 RID: 15248 RVA: 0x0013C314 File Offset: 0x0013A514
434 public void Fail()
435 {
436 if (this.owner.IsPC)
437 {
438 this.owner.Say("fish_miss", this.owner, null, null);
439 }
440 this.owner.stamina.Mod(-1);
441 }
442
443 // Token: 0x040025A1 RID: 9633
444 public int hit = -1;
445
446 // Token: 0x040025A2 RID: 9634
447 public Point posWater;
448 }
449}
Definition AIAct.cs:7
Definition Act.2.cs:7
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Thing.cs:10