Elin Decompiled Documentation EA 23.233 Nightly Patch 1
Loading...
Searching...
No Matches
Party.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4using UnityEngine;
5
6public class Party : EClass
7{
8 [JsonProperty]
9 public int uidLeader;
10
11 [JsonProperty]
12 public List<int> uidMembers = new List<int>();
13
14 public List<Chara> _members;
15
16 public RefChara refLeader = new RefChara();
17
18 public List<Chara> members
19 {
20 get
21 {
22 if (_members != null)
23 {
24 return _members;
25 }
26 return SetMembers();
27 }
28 }
29
31 {
32 get
33 {
35 }
36 set
37 {
38 refLeader.Set(ref uidLeader, value);
39 }
40 }
41
42 public List<Chara> SetMembers()
43 {
44 _members = new List<Chara>();
45 HashSet<int> hashSet = new HashSet<int>();
46 foreach (int uidMember in uidMembers)
47 {
48 if (!hashSet.Contains(uidMember))
49 {
50 hashSet.Add(uidMember);
51 members.Add(RefChara.Get(uidMember));
52 }
53 }
54 return _members;
55 }
56
57 public void AddMemeber(Chara c, bool showMsg = false)
58 {
59 if (c.party == this)
60 {
61 return;
62 }
63 if (!c.IsGlobal)
64 {
65 Debug.LogError("exception: " + c?.ToString() + " is not global chara");
66 }
67 members.Add(c);
68 uidMembers.Add(c.uid);
69 c.party = this;
70 c.isSale = false;
71 c.SetBool(18, enable: false);
72 if (c.homeBranch != null)
73 {
77 if (c.homeBranch.owner.map != null)
78 {
79 c.homeBranch.owner.map.props.sales.Remove(c);
80 }
81 }
82 if (showMsg)
83 {
84 Msg.Say("party_join", c.Name);
85 SE.Play("party_join");
86 }
88 }
89
90 public Chara Find(string id)
91 {
92 foreach (Chara member in members)
93 {
94 if (member.id == id)
95 {
96 return member;
97 }
98 }
99 return null;
100 }
101
102 public void RemoveMember(Chara c)
103 {
104 if (c.host != null)
105 {
106 ActRide.Unride(c.host, c.host.parasite == c);
107 }
108 members.Remove(c);
109 uidMembers.Remove(c.uid);
110 c.party = null;
111 c.c_wasInPcParty = false;
112 c.SetDirtySpeed();
113 if (c.homeBranch != null)
114 {
117 }
119 }
120
121 public void Replace(Chara c, int index)
122 {
123 members.Remove(c);
124 uidMembers.Remove(c.uid);
125 members.Insert(index, c);
126 uidMembers.Insert(index, c.uid);
127 }
128
129 public void SetLeader(Chara c)
130 {
131 leader = c;
132 }
133
134 public Element GetPartySkill(int ele)
135 {
136 return GetBestSkill(ele);
137 }
138
139 public void ModExpPartySkill(int ele, int a)
140 {
141 }
142
143 public Element GetBestSkill(int ele)
144 {
145 Element element = Element.Create(ele);
146 foreach (Chara member in members)
147 {
148 if (member.IsAliveInCurrentZone && member.Evalue(ele) > element.Value)
149 {
150 element = member.elements.GetElement(ele);
151 }
152 }
153 return element;
154 }
155
156 public bool IsCriticallyWounded(bool includePc = false)
157 {
158 foreach (Chara member in members)
159 {
160 if ((!includePc || !member.IsPC) && member.IsCriticallyWounded())
161 {
162 return true;
163 }
164 }
165 return false;
166 }
167
168 public int EvalueBest(int ele)
169 {
170 int num = 0;
171 foreach (Chara member in members)
172 {
173 if (member.Evalue(ele) > num)
174 {
175 num = member.Evalue(ele);
176 }
177 }
178 return num;
179 }
180
181 public int EvalueTotal(int ele, Func<Chara, bool> funcIf = null)
182 {
183 int num = 0;
184 foreach (Chara member in members)
185 {
186 if (funcIf == null || funcIf(member))
187 {
188 num += member.Evalue(ele);
189 }
190 }
191 return num;
192 }
193
194 public bool HasElement(int ele, bool excludePC = false)
195 {
196 foreach (Chara member in members)
197 {
198 if ((!excludePC || !member.IsPC) && member.HasElement(ele))
199 {
200 return true;
201 }
202 }
203 return false;
204 }
205
206 public int Count()
207 {
208 int num = 0;
209 foreach (Chara member in members)
210 {
211 if (!member.isDead)
212 {
213 num++;
214 }
215 }
216 return num;
217 }
218}
static void Unride(Chara host, Chara mount, bool talk=true)
Definition: ActRide.cs:102
void SetBool(int id, bool enable)
Definition: BaseCard.cs:20
ElementContainerCard elements
Definition: Card.cs:41
string id
Definition: Card.cs:35
bool HasElement(int ele, int req=1)
Definition: Card.cs:5845
string Name
Definition: Card.cs:2125
int uid
Definition: Card.cs:122
int Evalue(int ele)
Definition: Card.cs:2559
Definition: Chara.cs:10
override bool IsAliveInCurrentZone
Definition: Chara.cs:559
void SetDirtySpeed()
Definition: Chara.cs:1845
bool IsCriticallyWounded(bool includeRide=false)
Definition: Chara.cs:1175
void RefreshWorkElements(ElementContainer parent=null)
Definition: Chara.cs:8849
override bool IsPC
Definition: Chara.cs:610
Chara host
Definition: Chara.cs:33
override bool IsGlobal
Definition: Chara.cs:608
Party party
Definition: Chara.cs:43
Chara parasite
Definition: Chara.cs:30
FactionBranch homeBranch
Definition: Chara.cs:1064
bool isDead
Definition: Chara.cs:387
Definition: EClass.cs:5
Element GetElement(string alias)
static Element Create(int id, int v=0)
Definition: ELEMENT.cs:1100
void RefreshEfficiency()
PolicyManager policies
ElementContainerZone elements
PropsManager props
Definition: Map.cs:91
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
Definition: Party.cs:7
Element GetBestSkill(int ele)
Definition: Party.cs:143
int uidLeader
Definition: Party.cs:9
bool HasElement(int ele, bool excludePC=false)
Definition: Party.cs:194
Chara Find(string id)
Definition: Party.cs:90
Element GetPartySkill(int ele)
Definition: Party.cs:134
List< Chara > _members
Definition: Party.cs:14
int EvalueTotal(int ele, Func< Chara, bool > funcIf=null)
Definition: Party.cs:181
RefChara refLeader
Definition: Party.cs:16
List< Chara > SetMembers()
Definition: Party.cs:42
List< int > uidMembers
Definition: Party.cs:12
void Replace(Chara c, int index)
Definition: Party.cs:121
void RemoveMember(Chara c)
Definition: Party.cs:102
int Count()
Definition: Party.cs:206
bool IsCriticallyWounded(bool includePc=false)
Definition: Party.cs:156
Chara leader
Definition: Party.cs:31
void ModExpPartySkill(int ele, int a)
Definition: Party.cs:139
List< Chara > members
Definition: Party.cs:19
int EvalueBest(int ele)
Definition: Party.cs:168
void AddMemeber(Chara c, bool showMsg=false)
Definition: Party.cs:57
void SetLeader(Chara c)
Definition: Party.cs:129
List< Card > sales
Definition: PropsManager.cs:14
static Chara Get(int uid)
Definition: RefChara.cs:36
Chara GetAndCache(int uid)
Definition: RefChara.cs:5
void Set(ref int val, Chara c)
Definition: RefChara.cs:30
static void SetDirty()
Map map
Definition: Zone.cs:60