Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
GoalSleep.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
3public class GoalSleep : Goal
4{
5 public int timer = 20;
6
7 public Thing bed;
8
9 public override IEnumerable<Status> Run()
10 {
11 for (int j = 0; j < 5; j++)
12 {
13 yield return Status.Running;
14 }
15 TraitBed traitBed = owner.FindBed();
16 if (traitBed == null)
17 {
18 traitBed = owner.TryAssignBed();
19 }
20 if (traitBed != null)
21 {
22 bed = traitBed.owner.Thing;
23 }
24 if (bed != null)
25 {
26 yield return DoGoto(bed, base.KeepRunning);
27 }
28 else if (owner.memberType != FactionMemberType.Livestock)
29 {
31 if (baseArea != null)
32 {
33 yield return DoGoto(baseArea.GetRandomFreePos(), 0, ignoreConnection: false, base.KeepRunning);
34 }
35 }
36 for (int j = 0; j < 5; j++)
37 {
39 {
40 break;
41 }
43 yield return Status.Running;
44 }
45 owner.AddCondition<ConSleep>(3000, force: true);
46 yield return Status.Running;
47 }
48
49 public override void OnSimulatePosition()
50 {
51 owner.AddCondition<ConSleep>(2000, force: true);
52 bed = owner.FindBed()?.owner.Thing ?? null;
53 if (bed == null && EClass._zone.IsPCFaction)
54 {
56 }
57 if (bed != null)
58 {
60 return;
61 }
63 if (baseArea != null)
64 {
66 }
67 }
68}
FactionMemberType
new Chara owner
Definition: AIAct.cs:14
Status
Definition: AIAct.cs:8
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:432
Point GetRandomFreePos()
Definition: BaseArea.cs:60
Point pos
Definition: Card.cs:55
virtual Thing Thing
Definition: Card.cs:1934
void MoveImmediate(Point p, bool focus=true, bool cancelAI=true)
Definition: Card.cs:5127
Condition AddCondition(string id, int p=100, bool force=false)
Definition: Chara.cs:8415
TraitBed TryAssignBed()
Definition: Chara.cs:6641
TraitBed FindBed()
Definition: Chara.cs:6629
bool MoveRandom()
Definition: Chara.cs:2284
FactionMemberType memberType
Definition: Chara.cs:46
Definition: EClass.cs:5
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
override IEnumerable< Status > Run()
Definition: GoalSleep.cs:9
override void OnSimulatePosition()
Definition: GoalSleep.cs:49
Thing bed
Definition: GoalSleep.cs:7
int timer
Definition: GoalSleep.cs:5
Definition: Goal.cs:4
BaseArea FindPublicArea()
Definition: Map.cs:2693
bool HasMultipleChara
Definition: Point.cs:252
Definition: Thing.cs:8
Card owner
Definition: Trait.cs:26
bool IsPCFaction
Definition: Zone.cs:464