Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HotItemEQSet.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4
5public class HotItemEQSet : HotAction
6{
7 public class Item
8 {
9 public Card container;
10
11 public int invX;
12
13 public int invY;
14 }
15
16 [JsonProperty]
17 public List<int> ids = new List<int>();
18
19 public override string Id => "EQSet";
20
21 public override bool CanChangeIconColor => true;
22
23 public override string TextTip
24 {
25 get
26 {
27 string text = base.text.IsEmpty("EQSet".lang()) + TextHotkey() + Environment.NewLine;
28 foreach (int i in ids)
29 {
30 Thing thing = EClass.pc.things.Find((Thing t) => t.uid == i);
31 text += ((thing == null) ? "missingEQ".lang() : thing.Name);
32 text += Environment.NewLine;
33 }
34 return text.TrimEnd(Environment.NewLine.ToCharArray());
35 }
36 }
37
39 {
40 ids.Clear();
41 foreach (BodySlot slot in EClass.pc.body.slots)
42 {
43 if (slot.elementId != 44 && slot.thing != null)
44 {
45 ids.Add(slot.thing.uid);
46 }
47 }
48 SE.Equip();
49 return this;
50 }
51
52 public override void Perform()
53 {
54 for (int j = 0; j < 2; j++)
55 {
56 Dictionary<int, Thing> dictionary = new Dictionary<int, Thing>();
57 foreach (BodySlot slot2 in EClass.pc.body.slots)
58 {
59 if (slot2.elementId != 44 && slot2.thing != null && slot2.thing.blessedState >= BlessedState.Normal)
60 {
61 dictionary.Add(slot2.thing.c_equippedSlot - 1, slot2.thing);
62 EClass.pc.body.Unequip(slot2.thing, refresh: false);
63 }
64 }
65 Card card = null;
66 foreach (int i in ids)
67 {
68 Thing thing = EClass.pc.things.Find((Thing t) => t.uid == i && !t.isEquipped);
69 if (thing == null)
70 {
71 continue;
72 }
73 BodySlot slot = EClass.pc.body.GetSlot(thing, onlyEmpty: true);
74 if (slot == null || thing == slot.thing)
75 {
76 continue;
77 }
78 Card parentCard = thing.parentCard;
79 int invX = thing.invX;
80 int invY = thing.invY;
81 EClass.pc.body.Equip(thing, slot, msg: false);
82 if (dictionary.ContainsKey(slot.index))
83 {
84 Thing thing2 = dictionary[slot.index];
85 if (thing2.uid != thing.uid)
86 {
87 parentCard.AddThing(thing2);
88 card = parentCard;
89 thing2.invX = invX;
90 thing2.invY = invY;
91 dictionary.Remove(slot.index);
92 }
93 }
94 }
95 if (card == null)
96 {
97 continue;
98 }
99 foreach (Thing value in dictionary.Values)
100 {
101 if (!value.isEquipped && !card.things.IsFull(value))
102 {
103 card.AddThing(value);
104 }
105 }
106 }
107 SE.Equip();
109 }
110
111 public override void OnShowContextMenu(UIContextMenu m)
112 {
113 base.OnShowContextMenu(m);
114 m.AddButton("updateEQ", delegate
115 {
116 Register();
117 });
118 }
119}
BlessedState
Definition: BlessedState.cs:2
int index
Definition: BodySlot.cs:10
int elementId
Definition: BodySlot.cs:6
Thing thing
Definition: BodySlot.cs:8
Definition: Card.cs:11
int c_equippedSlot
Definition: Card.cs:912
int invY
Definition: Card.cs:1831
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:2901
string Name
Definition: Card.cs:2013
int uid
Definition: Card.cs:118
ThingContainer things
Definition: Card.cs:34
int invX
Definition: Card.cs:1819
BlessedState blessedState
Definition: Card.cs:262
Card parentCard
Definition: Card.cs:99
void Unequip(Thing thing, bool refresh=true)
Definition: CharaBody.cs:49
List< BodySlot > slots
Definition: CharaBody.cs:8
bool Equip(Thing thing, BodySlot slot=null, bool msg=true)
Definition: CharaBody.cs:182
BodySlot GetSlot(Thing t, bool onlyEmpty=false, bool secondSlot=false)
Definition: CharaBody.cs:341
CharaBody body
Definition: Chara.cs:91
Definition: EClass.cs:5
static Chara pc
Definition: EClass.cs:14
string text
Definition: HotAction.cs:10
override void OnShowContextMenu(UIContextMenu m)
override void Perform()
Definition: HotItemEQSet.cs:52
HotItemEQSet Register()
Definition: HotItemEQSet.cs:38
override bool CanChangeIconColor
Definition: HotItemEQSet.cs:21
override string Id
Definition: HotItemEQSet.cs:19
List< int > ids
Definition: HotItemEQSet.cs:17
override string TextTip
Definition: HotItemEQSet.cs:24
string TextHotkey()
Definition: HotItem.cs:50
static void Refresh()
Definition: LayerChara.cs:16
Thing Find(int uid)
Definition: Thing.cs:8
bool isEquipped
Definition: Thing.cs:17
void AddButton(Func< string > funcText, UnityAction action=null)