Elin Modding Docs Doc
Loading...
Searching...
No Matches
TraitBed.cs
1using System;
2using System.Collections.Generic;
3
4// Token: 0x02000406 RID: 1030
5public class TraitBed : Trait
6{
7 // Token: 0x1700092F RID: 2351
8 // (get) Token: 0x06001D93 RID: 7571 RVA: 0x000AC003 File Offset: 0x000AA203
9 public override bool CanStack
10 {
11 get
12 {
13 return false;
14 }
15 }
16
17 // Token: 0x17000930 RID: 2352
18 // (get) Token: 0x06001D94 RID: 7572 RVA: 0x000AC006 File Offset: 0x000AA206
19 public int MaxHolders
20 {
21 get
22 {
23 if (this.owner.c_bedType != BedType.residentOne)
24 {
25 return ((base.GetParam(1, null) == null) ? 1 : base.GetParam(1, null).ToInt()) + this.owner.c_containerSize;
26 }
27 return 1;
28 }
29 }
30
31 // Token: 0x17000931 RID: 2353
32 // (get) Token: 0x06001D95 RID: 7573 RVA: 0x000AC03E File Offset: 0x000AA23E
33 public override bool IsChangeFloorHeight
34 {
35 get
36 {
37 return true;
38 }
39 }
40
41 // Token: 0x06001D96 RID: 7574 RVA: 0x000AC044 File Offset: 0x000AA244
42 public override void TrySetAct(ActPlan p)
43 {
44 p.TrySetAct(new AI_Sleep
45 {
46 target = this.owner.Thing
47 }, this.owner);
48 p.TrySetAct(new AI_PassTime
49 {
50 target = this.owner.Thing
51 }, this.owner);
52 if (EClass._zone.IsPCFaction)
53 {
54 p.TrySetAct("bedConfig", delegate()
55 {
56 UIContextMenu uicontextMenu = EClass.ui.CreateContextMenuInteraction();
57 if (this.HasHolder())
58 {
59 uicontextMenu.AddButton("unassignBed", delegate()
60 {
61 this.ClearHolders();
62 SE.Trash();
63 }, true);
64 }
65 else if (this.owner.c_bedType == BedType.resident || this.owner.c_bedType == BedType.residentOne)
66 {
67 uicontextMenu.AddButton("claimBed", delegate()
68 {
69 this.ClearHolders();
70 this.AddHolder(EClass.pc);
71 Msg.Say("claimBed", EClass.pc, null, null, null);
72 SE.Play("jingle_embark");
73 }, true);
74 }
75 using (List<BedType>.Enumerator enumerator = new List<BedType>
76 {
77 BedType.resident,
78 BedType.residentOne,
79 BedType.guest
80 }.GetEnumerator())
81 {
82 while (enumerator.MoveNext())
83 {
84 BedType t = enumerator.Current;
85 if (t != BedType.livestock && t != BedType.patient)
86 {
87 uicontextMenu.AddButton(((t == this.owner.c_bedType) ? "context_checker".lang() : "") + ("bed_" + t.ToString()).lang(), delegate()
88 {
89 this.SetBedType(t);
90 SE.ClickOk();
91 }, true);
92 }
93 }
94 }
95 CursorSystem.ignoreCount = 5;
96 uicontextMenu.Show();
97 return false;
98 }, this.owner, null, 1, false, true, false);
99 }
100 }
101
102 // Token: 0x06001D97 RID: 7575 RVA: 0x000AC0C8 File Offset: 0x000AA2C8
103 public void AddHolder(Chara c)
104 {
105 CharaList charaList = this.owner.c_charaList;
106 if (charaList == null)
107 {
108 charaList = (this.owner.c_charaList = new CharaList());
109 }
110 charaList.Add(c);
111 }
112
113 // Token: 0x06001D98 RID: 7576 RVA: 0x000AC100 File Offset: 0x000AA300
114 public void RemoveHolder(Chara c)
115 {
116 CharaList c_charaList = this.owner.c_charaList;
117 if (c_charaList == null)
118 {
119 return;
120 }
121 c_charaList.Remove(c);
122 if (c_charaList.list.Count == 0)
123 {
124 this.owner.c_charaList = null;
125 }
126 }
127
128 // Token: 0x06001D99 RID: 7577 RVA: 0x000AC140 File Offset: 0x000AA340
129 public void ClearHolders()
130 {
131 CharaList c_charaList = this.owner.c_charaList;
132 if (c_charaList != null)
133 {
134 c_charaList.list.Clear();
135 }
136 }
137
138 // Token: 0x06001D9A RID: 7578 RVA: 0x000AC168 File Offset: 0x000AA368
139 public bool IsHolder(Chara c)
140 {
141 CharaList c_charaList = this.owner.c_charaList;
142 return c_charaList != null && c_charaList.list.Contains(c.uid);
143 }
144
145 // Token: 0x06001D9B RID: 7579 RVA: 0x000AC198 File Offset: 0x000AA398
146 public bool IsFull()
147 {
148 CharaList c_charaList = this.owner.c_charaList;
149 return c_charaList != null && c_charaList.list.Count >= this.MaxHolders;
150 }
151
152 // Token: 0x06001D9C RID: 7580 RVA: 0x000AC1CC File Offset: 0x000AA3CC
153 public bool HasHolder()
154 {
155 CharaList c_charaList = this.owner.c_charaList;
156 return c_charaList != null && c_charaList.list.Count > 0;
157 }
158
159 // Token: 0x06001D9D RID: 7581 RVA: 0x000AC1F8 File Offset: 0x000AA3F8
160 public bool CanAssign(Chara c)
161 {
162 CharaList c_charaList = this.owner.c_charaList;
163 if (c_charaList != null && c_charaList.list.Count >= this.MaxHolders)
164 {
165 return false;
166 }
167 BedType c_bedType = this.owner.c_bedType;
168 FactionMemberType memberType = c.memberType;
169 return (memberType == FactionMemberType.Default && (c_bedType == BedType.resident || c_bedType == BedType.residentOne)) || (memberType == FactionMemberType.Livestock && c_bedType == BedType.livestock) || (memberType == FactionMemberType.Guest && c_bedType == BedType.guest);
170 }
171
172 // Token: 0x06001D9E RID: 7582 RVA: 0x000AC25A File Offset: 0x000AA45A
173 public void SetBedType(BedType bedType)
174 {
175 if (bedType == this.owner.c_bedType)
176 {
177 return;
178 }
179 this.owner.c_bedType = bedType;
180 this.ClearHolders();
181 }
182
183 // Token: 0x06001D9F RID: 7583 RVA: 0x000AC280 File Offset: 0x000AA480
184 public override void SetName(ref string s)
185 {
186 CharaList c_charaList = this.owner.c_charaList;
187 if (c_charaList != null)
188 {
189 List<Chara> list = c_charaList.Get();
190 if (list.Count == 1)
191 {
192 s = "_bed".lang(list[0].NameSimple, s, null, null, null);
193 return;
194 }
195 if (list.Count == 2)
196 {
197 s = "_bed".lang("_and".lang(list[0].NameSimple, list[1].NameSimple, null, null, null), s, null, null, null);
198 return;
199 }
200 }
201 if (this.owner.c_bedType == BedType.resident)
202 {
203 return;
204 }
205 string @ref = ("bed_" + this.owner.c_bedType.ToString()).lang().ToLower();
206 s = "_of4".lang(@ref, s, null, null, null);
207 }
208
209 // Token: 0x06001DA0 RID: 7584 RVA: 0x000AC358 File Offset: 0x000AA558
210 public override string GetHoverText()
211 {
212 CharaList c_charaList = this.owner.c_charaList;
213 if (c_charaList == null || c_charaList.Get().Count < 3)
214 {
215 return null;
216 }
217 string text = "";
218 foreach (Chara chara in c_charaList.Get())
219 {
220 if (text != "")
221 {
222 text += ", ";
223 }
224 text += chara.NameSimple;
225 }
226 return "(" + text + ")";
227 }
228}
Definition Chara.cs:12
Definition Msg.cs:7
Definition Trait.cs:9