Elin Modding Docs Doc
Loading...
Searching...
No Matches
ConSleep.cs
1using System;
2using System.Runtime.CompilerServices;
3using Newtonsoft.Json;
4
5// Token: 0x020002C2 RID: 706
6public class ConSleep : BadCondition
7{
8 // Token: 0x17000663 RID: 1635
9 // (get) Token: 0x060016E0 RID: 5856 RVA: 0x00097363 File Offset: 0x00095563
10 public override Emo2 EmoIcon
11 {
12 get
13 {
14 return Emo2.speeing;
15 }
16 }
17
18 // Token: 0x060016E1 RID: 5857 RVA: 0x00097367 File Offset: 0x00095567
19 public override int GetPhase()
20 {
21 return 0;
22 }
23
24 // Token: 0x17000664 RID: 1636
25 // (get) Token: 0x060016E2 RID: 5858 RVA: 0x0009736A File Offset: 0x0009556A
26 public override bool ConsumeTurn
27 {
28 get
29 {
30 return true;
31 }
32 }
33
34 // Token: 0x17000665 RID: 1637
35 // (get) Token: 0x060016E3 RID: 5859 RVA: 0x0009736D File Offset: 0x0009556D
36 public override bool CancelAI
37 {
38 get
39 {
40 return false;
41 }
42 }
43
44 // Token: 0x060016E4 RID: 5860 RVA: 0x00097370 File Offset: 0x00095570
45 public override void SetOwner(Chara _owner, bool onDeserialize = false)
46 {
47 base.SetOwner(_owner, false);
48 this.owner.conSleep = this;
49 if (this.owner.renderer != null)
50 {
51 this.owner.renderer.RefreshSprite();
52 }
53 }
54
55 // Token: 0x060016E5 RID: 5861 RVA: 0x000973A4 File Offset: 0x000955A4
56 public override void OnBeforeStart()
57 {
58 TraitPillow traitPillow = this.owner.pos.FindThing<TraitPillow>();
59 if (traitPillow != null)
60 {
61 this.owner.Say("pillow", this.owner, traitPillow.owner, null, null);
62 }
63 }
64
65 // Token: 0x060016E6 RID: 5862 RVA: 0x000973E4 File Offset: 0x000955E4
66 public override void Tick()
67 {
68 if (!this.succubusChecked && EClass._zone.isStarted && (base.value > 50 || this.pcSleep != 0))
69 {
70 ConSleep.SuccubusVisit(this.owner);
71 this.succubusChecked = true;
72 }
73 if (this.owner.IsPC && this.pcSleep > 0)
74 {
75 this.pcSleep--;
76 if (this.pcSleep == 0)
77 {
78 int phase = EClass.pc.sleepiness.GetPhase();
79 int num = (phase >= 3) ? 12 : ((phase >= 2) ? 10 : ((phase >= 1) ? 7 : 5));
80 phase = EClass.pc.stamina.GetPhase();
81 num += ((phase == 0) ? 4 : ((phase == 1) ? 3 : ((phase == 2) ? 2 : 0)));
82 num += EClass.rnd(3) - EClass.rnd(2);
83 ConSleep.SuccubusSleep(EClass.pc);
84 if (EClass.pc.isDead)
85 {
86 return;
87 }
88 base.value = 1;
89 this.slept = true;
90 EClass.ui.AddLayer<LayerSleep>().Sleep(num, this.pcBed, this.pcPillow);
91 }
92 return;
93 }
94 if (EClass.rnd(50) == 0 && !this.owner.IsPC)
95 {
96 if (EClass.rnd(10) == 0)
97 {
98 this.owner.Talk("sleepFav", (EClass.rnd(2) == 0) ? this.owner.GetFavCat().GetName().ToLower() : this.owner.GetFavFood().GetName(), null, false);
99 if (!this.owner.knowFav && this.owner.isSynced)
100 {
101 Msg.Say("noteFav", this.owner, null, null, null);
102 this.owner.knowFav = true;
103 }
104 }
105 else
106 {
107 this.owner.Talk("sleep", null, null, false);
108 }
109 }
110 if (this.owner.ai is GoalSleep && this.owner.CurrentSpan == TimeTable.Span.Sleep)
111 {
112 return;
113 }
114 this.owner.HealHP(EClass.rnd(4) + 1, HealSource.None);
115 this.owner.mana.Mod(EClass.rnd(3) + 1);
116 if (!this.owner.IsPC)
117 {
118 this.owner.stamina.Mod(EClass.rnd(2) + 1);
119 }
120 base.Mod(-1, false);
121 }
122
123 // Token: 0x060016E7 RID: 5863 RVA: 0x00097630 File Offset: 0x00095830
124 public static void SuccubusVisit(Chara tg)
125 {
126 if (tg.bio.IsUnderAge)
127 {
128 return;
129 }
130 foreach (Chara chara in EClass._map.charas)
131 {
132 if (chara != tg && !chara.IsPC && EClass.rnd(3) == 0 && !chara.IsDisabled && chara.IsIdle)
133 {
134 Thing thing = chara.things.Find<TraitDreamBug>();
135 if ((chara.HasElement(1216, 1) || thing != null) && chara.host == null && (!tg.IsPC || thing != null || EClass.rnd(200) == 0))
136 {
137 chara.Teleport(tg.pos, false, false);
138 if (chara.Dist(tg.pos) <= 2)
139 {
140 if (thing != null)
141 {
142 tg.Say("dreambug_teleport", chara, tg, null, null);
143 thing.ModCharge(-1, false);
144 if (thing.c_charges <= 0)
145 {
146 tg.Say("dreambug_destroy", chara, thing, null, null);
147 thing.Destroy();
148 }
149 }
150 chara.SetAI(new AI_Fuck
151 {
152 target = tg,
153 succubus = true
154 });
155 }
156 }
157 }
158 }
159 }
160
161 // Token: 0x060016E8 RID: 5864 RVA: 0x00097778 File Offset: 0x00095978
162 public static void SuccubusSleep(Chara tg)
163 {
164 EClass._map.charas.ForeachReverse(delegate(Chara c)
165 {
166 AI_Fuck ai_Fuck = c.ai as AI_Fuck;
167 if (ai_Fuck != null && ai_Fuck.IsRunning && ai_Fuck.target == tg)
168 {
169 ai_Fuck.Finish();
170 ai_Fuck.Cancel();
171 if (!c.HasCondition<ConSleep>())
172 {
173 c.AddCondition<ConSleep>(100 + EClass.rnd(100), true);
174 }
175 }
176 });
177 }
178
179 // Token: 0x060016E9 RID: 5865 RVA: 0x000977B0 File Offset: 0x000959B0
180 public unsafe override void OnRemoved()
181 {
182 this.owner.conSleep = null;
183 this.owner.renderer.RefreshSprite();
184 this.owner.renderer.SetFirst(true, *this.owner.pos.PositionAuto());
185 if (!this.owner.IsPC)
186 {
187 this.owner.sleepiness.Set(0);
188 return;
189 }
190 if (!this.owner.isDead)
191 {
192 Thing thing = this.pcPillow;
193 TraitPillow traitPillow = (((thing != null) ? thing.trait : null) as TraitPillow) ?? EClass.pc.pos.FindThing<TraitPillow>();
194 if (traitPillow != null)
195 {
196 if (traitPillow is TraitPillowEhekatl)
197 {
198 EClass.game.religions.Luck.Talk("morning", null, null);
199 }
200 else if (traitPillow is TraitPillowJure)
201 {
202 EClass.game.religions.Healing.Talk("morning", null, null);
203 EClass.pc.SAN.Mod(-EClass.rndHalf(5));
204 }
205 else if (traitPillow is TraitPillowOpatos)
206 {
207 EClass.game.religions.Earth.Talk("morning", null, null);
208 }
209 }
210 if (this.slept)
211 {
212 EClass.player.recipes.OnSleep(traitPillow is TraitPillowEhekatl);
213 EClass.player.DreamSpell();
214 }
215 if (this.pickup)
216 {
217 ConSleep.<OnRemoved>g__TryPick|20_0(this.pcBed, this.posBed);
218 ConSleep.<OnRemoved>g__TryPick|20_0(this.pcPillow, this.posPillow);
219 }
220 if (this.slept)
221 {
222 Thing thing2 = EClass.pc.things.Find<TraitGrimoire>();
223 if (thing2 != null && thing2.c_lockLv == 0 && !EClass._zone.IsRegion)
224 {
225 foreach (Thing thing3 in thing2.things.List((Thing _t) => _t.trait is TraitSpellbook || _t.trait is TraitAncientbook, false))
226 {
227 TraitBaseSpellbook traitBaseSpellbook = thing3.trait as TraitBaseSpellbook;
228 if (!(thing3.trait is TraitAncientbook) || !thing3.isOn)
229 {
230 int c_charges = thing3.c_charges;
231 for (int i = 0; i < c_charges; i++)
232 {
233 int num = traitBaseSpellbook.GetActDuration(EClass.pc) + 1;
234 bool flag = false;
235 int j = 0;
236 while (j < num)
237 {
238 if (!traitBaseSpellbook.TryProgress(new AIProgress
239 {
240 owner = EClass.pc
241 }))
242 {
243 flag = true;
244 if (EClass.pc.isDead)
245 {
246 return;
247 }
248 break;
249 }
250 else
251 {
252 j++;
253 }
254 }
255 if (!flag)
256 {
257 traitBaseSpellbook.OnRead(EClass.pc);
258 }
259 }
260 }
261 }
262 }
263 }
264 }
265 }
266
267 // Token: 0x060016EB RID: 5867 RVA: 0x00097A7C File Offset: 0x00095C7C
268 [CompilerGenerated]
269 internal static void <OnRemoved>g__TryPick|20_0(Thing t, ItemPosition pos)
270 {
271 if (t == null)
272 {
273 return;
274 }
275 t = EClass._map.FindThing(t.uid);
276 if (t == null || !t.ExistsOnMap || t.isNPCProperty)
277 {
278 return;
279 }
280 if (pos != null)
281 {
282 Card card = (pos.uidContainer == EClass.pc.uid) ? EClass.pc : EClass.pc.things.Find(pos.uidContainer);
283 if (card != null)
284 {
285 EClass.pc.PlaySound("pick_thing", 1f, true);
286 EClass.pc.Say("pick_thing", EClass.pc, t, null, null);
287 t = card.AddThing(t, false, pos.invX, pos.invY);
288 t.invX = pos.invX;
289 t.invY = pos.invY;
290 LayerInventory.SetDirty(t);
291 return;
292 }
293 }
294 EClass.pc.Pick(t, true, true);
295 }
296
297 // Token: 0x0400106C RID: 4204
298 public bool succubusChecked;
299
300 // Token: 0x0400106D RID: 4205
301 [JsonProperty]
302 public int pcSleep;
303
304 // Token: 0x0400106E RID: 4206
305 [JsonProperty]
306 public Thing pcBed;
307
308 // Token: 0x0400106F RID: 4207
309 [JsonProperty]
310 public Thing pcPillow;
311
312 // Token: 0x04001070 RID: 4208
313 [JsonProperty]
314 public ItemPosition posBed;
315
316 // Token: 0x04001071 RID: 4209
317 [JsonProperty]
318 public ItemPosition posPillow;
319
320 // Token: 0x04001072 RID: 4210
321 [JsonProperty]
322 public bool pickup;
323
324 // Token: 0x04001073 RID: 4211
325 [JsonProperty]
326 public bool slept;
327}
Definition Card.cs:13
Definition Chara.cs:12
Definition Msg.cs:7
Definition Thing.cs:10