Elin Modding Docs Doc
Loading...
Searching...
No Matches
AI_Eat.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x020001F3 RID: 499
6public class AI_Eat : AIAct
7{
8 // Token: 0x06000E4D RID: 3661 RVA: 0x0006BE60 File Offset: 0x0006A060
9 public bool IsValidTarget(Card c)
10 {
11 return c != null && c.trait.CanEat(this.owner);
12 }
13
14 // Token: 0x170003AA RID: 938
15 // (get) Token: 0x06000E4E RID: 3662 RVA: 0x0006BE78 File Offset: 0x0006A078
16 public override bool LocalAct
17 {
18 get
19 {
20 return false;
21 }
22 }
23
24 // Token: 0x06000E4F RID: 3663 RVA: 0x0006BE7B File Offset: 0x0006A07B
25 public override bool CanManualCancel()
26 {
27 return true;
28 }
29
30 // Token: 0x170003AB RID: 939
31 // (get) Token: 0x06000E50 RID: 3664 RVA: 0x0006BE7E File Offset: 0x0006A07E
32 public override bool IsHostileAct
33 {
34 get
35 {
36 return this.target != null && this.target.isNPCProperty;
37 }
38 }
39
40 // Token: 0x06000E51 RID: 3665 RVA: 0x0006BE95 File Offset: 0x0006A095
41 public override void OnStart()
42 {
43 }
44
45 // Token: 0x06000E52 RID: 3666 RVA: 0x0006BE97 File Offset: 0x0006A097
46 public override IEnumerable<AIAct.Status> Run()
47 {
48 if (this.target != null && (this.target.GetRootCard() == this.owner || this.target.parent == null))
49 {
50 this.owner.HoldCard(this.target, 1);
51 }
52 else if (this.target != null)
53 {
54 yield return base.DoGrab(this.target, 1, false, null);
55 }
56 else
57 {
58 if (!this.IsValidTarget(this.owner.held))
59 {
60 yield return base.DoGrab<TraitFood>();
61 if (!this.IsValidTarget(this.owner.held))
62 {
63 yield return this.Cancel();
64 }
65 }
66 if (this.cook)
67 {
68 yield return base.Do(new AI_Cook(), new Func<AIAct.Status>(base.KeepRunning));
69 if (!this.IsValidTarget(this.owner.held))
70 {
71 yield return this.Cancel();
72 }
73 yield return base.DoGotoSpot<TraitHearth>(new Func<AIAct.Status>(base.KeepRunning));
74 }
75 }
76 this.target = this.owner.held;
77 if (this.target == null)
78 {
79 yield return this.Cancel();
80 }
81 if (EClass._zone.IsPCFaction && !this.owner.IsPCParty && this.owner.memberType != FactionMemberType.Livestock && !this.owner.noMove)
82 {
83 yield return base.DoGotoSpot<TraitSpotDining>(new Func<AIAct.Status>(base.KeepRunning));
84 }
85 int max = (this.target.SelfWeight < 100) ? 1 : (2 + (int)Mathf.Sqrt((float)(this.target.SelfWeight * 2 / 3)));
86 int turn = 0;
88 {
89 cancelWhenMoved = false,
90 canProgress = (() => this.IsValidTarget(this.target) && this.owner.held == this.target),
91 onProgressBegin = delegate()
92 {
93 this.owner.Say("eat_start", this.owner, this.target.GetName(NameStyle.Full, 1), null);
94 this.owner.PlaySound("eat", 1f, true);
95 },
96 onProgress = delegate(Progress_Custom p)
97 {
98 this.target.PlayAnime(AnimeID.Eat, false);
99 int turn;
100 if (turn == 1 && this.owner.IsPC && this.owner.hunger.GetPhase() == 0 && !EClass.debug.godFood)
101 {
102 this.owner.Say("eat_full", null, null);
103 p.Cancel();
104 }
105 if (turn == 1)
106 {
107 foreach (Element element in this.target.elements.dict.Values)
108 {
109 if (!element.source.foodEffect.IsEmpty())
110 {
111 string[] foodEffect = element.source.foodEffect;
112 if (foodEffect[0] == "poison" || foodEffect[0] == "love")
113 {
114 this.owner.Talk("eatWeird", null, null, false);
115 break;
116 }
117 }
118 }
119 CardRow refCard = this.target.refCard;
120 if (refCard != null && refCard.id == "mammoth")
121 {
122 EClass.player.forceTalk = true;
123 this.owner.Talk("eatammoth", null, null, false);
124 }
125 }
126 turn = turn;
127 turn++;
128 },
129 onProgressComplete = delegate()
130 {
131 if (this.owner.IsPC && this.owner.hunger.GetPhase() == 0 && !EClass.debug.godFood)
132 {
133 this.owner.Say("eat_full", null, null);
134 return;
135 }
136 this.owner.Say("eat_end", this.owner, this.target.GetName(NameStyle.Full, 1), null);
137 this.owner.ShowEmo(Emo.happy, 0f, true);
138 FoodEffect.Proc(this.owner, this.target.Thing);
139 this.target.ModNum(-1, true);
140 }
141 }.SetDuration(max, 5);
142 yield return base.Do(seq, null);
143 yield break;
144 }
145
146 // Token: 0x04000D48 RID: 3400
147 public Card target;
148
149 // Token: 0x04000D49 RID: 3401
150 public bool cook = true;
151}
Definition AIAct.cs:7
Definition Card.cs:13