Elin Modding Docs Doc
Loading...
Searching...
No Matches
GoalSleep.cs
1using System;
2using System.Collections.Generic;
3
4// Token: 0x0200023F RID: 575
5public class GoalSleep : Goal
6{
7 // Token: 0x06001003 RID: 4099 RVA: 0x000727C7 File Offset: 0x000709C7
8 public override IEnumerable<AIAct.Status> Run()
9 {
10 int i;
11 int num;
12 for (i = 0; i < 5; i = num + 1)
13 {
14 yield return AIAct.Status.Running;
15 num = i;
16 }
17 TraitBed traitBed = this.owner.FindBed();
18 if (traitBed == null)
19 {
20 traitBed = this.owner.TryAssignBed();
21 }
22 if (traitBed != null)
23 {
24 this.bed = traitBed.owner.Thing;
25 }
26 if (this.bed != null)
27 {
28 yield return base.DoGoto(this.bed, new Func<AIAct.Status>(base.KeepRunning));
29 }
30 else if (this.owner.memberType != FactionMemberType.Livestock)
31 {
32 BaseArea baseArea = EClass._map.FindPublicArea();
33 if (baseArea != null)
34 {
35 yield return base.DoGoto(baseArea.GetRandomFreePos(), 0, false, new Func<AIAct.Status>(base.KeepRunning));
36 }
37 }
38 i = 0;
39 while (i < 5 && this.owner.pos.HasMultipleChara)
40 {
41 this.owner.MoveRandom();
42 yield return AIAct.Status.Running;
43 num = i;
44 i = num + 1;
45 }
46 this.owner.AddCondition<ConSleep>(3000, true);
47 yield return AIAct.Status.Running;
48 yield break;
49 }
50
51 // Token: 0x06001004 RID: 4100 RVA: 0x000727D8 File Offset: 0x000709D8
52 public override void OnSimulatePosition()
53 {
54 this.owner.AddCondition<ConSleep>(2000, true);
55 TraitBed traitBed = this.owner.FindBed();
56 this.bed = (((traitBed != null) ? traitBed.owner.Thing : null) ?? null);
57 if (this.bed == null && EClass._zone.IsPCFaction)
58 {
59 this.owner.TryAssignBed();
60 }
61 if (this.bed != null && !this.bed.pos.HasChara)
62 {
63 this.owner.MoveImmediate(this.bed.pos, true, true);
64 return;
65 }
66 BaseArea baseArea = EClass._map.FindPublicArea();
67 if (baseArea != null)
68 {
69 this.owner.MoveImmediate(baseArea.GetRandomFreePos(), true, true);
70 }
71 }
72
73 // Token: 0x04000D9A RID: 3482
74 public int timer = 20;
75
76 // Token: 0x04000D9B RID: 3483
77 public Thing bed;
78}
Definition AIAct.cs:7
Definition Goal.cs:5
Definition Thing.cs:10