15 return this.owner.rawSlots;
20 public void SetOwner(
Chara chara,
bool deserialized =
false)
25 if (this.rawSlots !=
null)
27 for (
int i = 0; i < this.rawSlots.Length; i++)
29 this.AddBodyPart(this.rawSlots[i],
null);
32 foreach (
Thing thing
in this.owner.things)
36 int num = thing.c_equippedSlot - 1;
37 if (num < 0 || num >= this.slots.Count)
39 thing.c_equippedSlot = 0;
43 this.slots[num].thing = thing;
44 thing.elements.SetParent(this.owner);
52 public void Unequip(
Thing thing,
bool refresh =
true)
54 if (!thing.isEquipped)
58 this.Unequip(this.slots[thing.c_equippedSlot - 1], refresh);
62 public void UnequipAll(
int idSlot)
64 foreach (
BodySlot bodySlot
in this.slots)
66 if (bodySlot.elementId == idSlot)
68 this.Unequip(bodySlot,
true);
74 public void Unequip(
BodySlot slot,
bool refresh =
true)
76 if (slot.thing ==
null)
80 Thing thing = slot.thing;
83 EClass.pc.faction.charaElements.OnUnequip(this.owner, thing);
85 thing.elements.SetParent(
null);
86 thing.c_equippedSlot = 0;
94 if (slot.elementId == 45 &&
EClass.core.IsGameStarted)
96 this.owner.RecalculateFOV();
98 if (refresh && this.owner.isCreated &&
EClass.core.IsGameStarted)
100 this.owner.Refresh(
false);
101 if (slot.elementId == 37 &&
this.owner.HasElement(1209, 1))
103 this.owner.Say(
"tail_free", this.owner,
null,
null);
109 public bool IsEquippable(
Thing thing,
BodySlot slot,
bool text =
true)
111 CharaBody.<>c__DisplayClass11_0 CS$<>8__locals1;
112 CS$<>8__locals1.text = text;
113 CS$<>8__locals1.slot = slot;
114 if (CS$<>8__locals1.slot ==
null)
118 int elementId = CS$<>8__locals1.slot.elementId;
125 if (this.owner.HasElement(1552, 1))
127 return CharaBody.<IsEquippable>g__CannotEquip|11_0(ref CS$<>8__locals1);
131 else if (this.owner.HasElement(1554, 1))
133 return CharaBody.<IsEquippable>g__CannotEquip|11_0(ref CS$<>8__locals1);
136 else if (this.owner.HasElement(1555, 1))
138 return CharaBody.<IsEquippable>g__CannotEquip|11_0(ref CS$<>8__locals1);
140 if (this.IsTooHeavyToEquip(thing))
142 if (
EClass.core.IsGameStarted &&
this.owner.IsPC && CS$<>8__locals1.text)
144 Msg.Say(
"tooHeavyToEquip", thing,
null,
null,
null);
152 public bool IsTooHeavyToEquip(
Thing thing)
154 return this.owner.HasElement(1204, 1) && thing.ChildrenAndSelfWeight > 1000 && thing.category.slot != 44;
158 public void UnqeuipIfTooHeavy(
Thing t)
162 BodySlot bodySlot = this.slots[t.c_equippedSlot - 1];
163 if (this.IsTooHeavyToEquip(t))
165 this.owner.Say(
"tooHeavyToEquip", t,
null,
null);
166 this.Unequip(t,
true);
169 if (!this.owner.IsPC && !t.isEquipped)
171 this.owner.TryEquip(t,
false);
176 public bool Equip(
Thing thing,
BodySlot slot =
null,
bool msg =
true)
179 if ((bodySlot = slot) ==
null)
181 bodySlot = (this.GetSlot(thing.category.slot,
true,
false) ?? this.GetSlot(thing.category.slot,
false,
false));
184 if (slot == this.slotMainHand || slot == this.slotOffHand)
186 this.owner.combatCount = 10;
188 if (slot ==
null || slot.elementId != thing.category.slot)
190 string[] array =
new string[6];
191 array[0] =
"could not equip:";
192 array[1] = ((thing !=
null) ? thing.ToString() :
null);
196 array[num] = ((bodySlot2 !=
null) ? bodySlot2.ToString() :
null);
199 Chara chara = this.owner;
200 array[num2] = ((chara !=
null) ? chara.ToString() :
null);
201 Debug.LogWarning(
string.Concat(array));
204 if (!this.IsEquippable(thing, slot,
true))
208 if (slot.thing !=
null)
210 if (slot.thing == thing)
212 this.Unequip(slot,
true);
215 this.Unequip(slot,
false);
217 this.Unequip(thing,
false);
218 if (thing.parent !=
this.owner)
220 if (msg && this.owner.IsPC && thing.parent is
Thing)
222 Msg.Say(
"movedToEquip", thing, thing.parent as
Thing,
null,
null);
224 this.owner.AddCard(thing);
227 thing.c_equippedSlot = slot.index + 1;
228 thing.elements.SetParent(this.owner);
231 EClass.pc.faction.charaElements.OnEquip(this.owner, thing);
233 this.owner.SetTempHand(0, 0);
240 if (slot.elementId == 45 &&
EClass.core.IsGameStarted)
242 this.owner.RecalculateFOV();
244 if (this.owner.isCreated &&
EClass.core.IsGameStarted)
246 this.owner.Refresh(
false);
248 if (this.owner.isCreated)
250 if (thing.Evalue(656) > 0)
252 thing.blessedState = BlessedState.Cursed;
254 if (thing.blessedState <= BlessedState.Cursed)
256 this.owner.Say(
"equipCursed", this.owner,
null,
null);
257 this.owner.PlaySound(
"curse3", 1f,
true);
260 if (slot.elementId == 37 &&
this.owner.HasElement(1209, 1))
262 this.owner.Say(
"tail_covered", this.owner,
null,
null);
268 public void AddBodyPart(
int ele,
Thing thing =
null)
274 index = this.slots.Count
278 if (this.slotMainHand ==
null)
280 this.slotMainHand = item;
282 else if (this.slotOffHand ==
null)
284 this.slotOffHand = item;
289 this.slotRange = item;
291 this.slots.Add(item);
295 public void RefreshBodyParts()
297 foreach (
BodySlot bodySlot
in this.slots)
299 int elementId = bodySlot.elementId;
302 if (this.slotMainHand ==
null)
304 this.slotMainHand = bodySlot;
306 else if (this.slotOffHand ==
null)
308 this.slotOffHand = bodySlot;
313 this.slotRange = bodySlot;
319 public void RemoveBodyPart(
int ele)
321 int num = this.slots.FindIndex((
BodySlot a) => a.elementId == ele);
324 BodySlot bodySlot = this.slots[num];
325 if (bodySlot.thing !=
null)
327 this.Unequip(bodySlot,
true);
329 if (this.slotMainHand == bodySlot)
331 this.slotMainHand =
null;
333 if (this.slotOffHand == bodySlot)
335 this.slotOffHand =
null;
337 if (this.slotRange == bodySlot)
339 this.slotRange =
null;
341 this.slots.RemoveAt(num);
346 public BodySlot GetSlot(
Thing t,
bool onlyEmpty =
false,
bool secondSlot =
false)
348 BodySlot slot = this.GetSlot(t.category.slot,
true, secondSlot);
355 return this.GetSlot(t.category.slot,
false, secondSlot);
361 public BodySlot GetSlot(
int elementId,
bool onlyEmpty =
true,
bool secondSlot =
false)
364 foreach (
BodySlot bodySlot
in this.slots)
366 if (elementId == bodySlot.elementId && (!onlyEmpty || bodySlot.thing ==
null))
368 if (!secondSlot || !flag)
379 public Thing GetEquippedThing(
int elementId)
381 foreach (
BodySlot bodySlot
in this.slots)
383 if (bodySlot.elementId == elementId && bodySlot.thing !=
null)
385 return bodySlot.thing;
392 public int GetWeight(
bool armorOnly =
false)
395 foreach (
BodySlot bodySlot
in this.slots)
397 if (bodySlot.thing !=
null && (!armorOnly || (bodySlot.elementId != 44 && bodySlot.elementId != 45)))
399 num += bodySlot.thing.ChildrenAndSelfWeight;
406 public int GetAttackIndex(
Thing t)
409 foreach (
BodySlot bodySlot
in this.slots)
411 if (bodySlot.thing !=
null && bodySlot.elementId == 35 && bodySlot.thing.source.offense.Length >= 2)
413 if (bodySlot.thing == t)
424 public int GetMeleeDistance()
426 int num = this.owner.Evalue(666);
432 foreach (
BodySlot bodySlot
in this.slots)
434 if (bodySlot.elementId == 35 && bodySlot.thing !=
null && bodySlot.thing.Evalue(666) > num)
436 num = bodySlot.thing.Evalue(666);
443 public AttackStyle GetAttackStyle()
447 foreach (
BodySlot bodySlot
in this.slots)
449 if (bodySlot.elementId == 35 && bodySlot.thing !=
null)
451 if (bodySlot.thing.IsMeleeWeapon)
463 return AttackStyle.TwoWield;
467 return AttackStyle.Shield;
471 return AttackStyle.TwoHand;
473 return AttackStyle.Default;
477 public int GetAttackStyleElement(AttackStyle style)
479 if (style == AttackStyle.TwoHand)
483 if (style != AttackStyle.TwoWield)
492 internal static bool <IsEquippable>g__CannotEquip|11_0(ref
CharaBody.<>c__DisplayClass11_0 A_0)
496 Msg.Say(
"cannnotEquip", A_0.slot.element.GetName().ToLower(),
null,
null,
null);
505 public List<BodySlot> slots =
new List<BodySlot>();