Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Props Class Reference
Inheritance diagram for Props:
EClass PropsInstalled PropsRoaming PropsStocked

Public Member Functions

void Init ()
 
void Add (Card t)
 
void Remove (Card t)
 
void OnNumChange (Card c, int a)
 
bool ShouldListAsResource (Thing t)
 
Thing GetAvailableThing (string id, int idMat)
 
ThingStack ListThingStack (Recipe.Ingredient ing, StockSearchMode searchMode)
 
List< ThingListThingsInCategory (SourceCategory.Row cat)
 
Dictionary< string, ThingStackListThingStacksInCategory (SourceCategory.Row cat)
 
Thing Find< T > ()
 
Thing FindEmptyContainer< T > ()
 
Thing FindEmptyContainer< T > (Thing target)
 
Thing Find (int uid)
 
Thing FindShared (string id)
 
Thing Find (string id, string idMat)
 
Thing Find (string id, int idMat=-1, int refVal=-1, bool shared=false)
 
int GetNum (string id, bool onlyShared=false)
 
void Validate ()
 

Static Public Member Functions

static int GetNumStockedAndRoaming (string id)
 
- Static Public Member Functions inherited from EClass
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Public Attributes

PropSet all = new PropSet()
 
Dictionary< string, PropSetcardMap = new Dictionary<string, PropSet>()
 
Dictionary< string, PropSetCategorycategoryMap = new Dictionary<string, PropSetCategory>()
 
Dictionary< string, PropSetraceMap = new Dictionary<string, PropSet>()
 
Dictionary< string, PropSetworkMap = new Dictionary<string, PropSet>()
 
TraitManager traits = new TraitManager()
 
List< Thingthings = new List<Thing>()
 
List< Thingcontainers = new List<Thing>()
 
int maxWeight = 100
 
int weight
 

Properties

virtual bool IsStocked [get]
 
virtual bool IsRoaming [get]
 
virtual bool IsInstalled [get]
 
virtual PlaceState state [get]
 
List< ThingThings [get]
 
int Count [get]
 
- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Private Member Functions

void ListThingStacksInCategory (SourceCategory.Row cat, Dictionary< string, ThingStack > stacks, Thing t)
 

Additional Inherited Members

- Static Public Attributes inherited from EClass
static Core core
 

Detailed Description

Definition at line 6 of file Props.cs.

Member Function Documentation

◆ Add()

void Props.Add ( Card  t)
inline

Definition at line 63 of file Props.cs.

64 {
65 if (all.Contains(t))
66 {
67 Debug.Log(t.props);
68 Debug.Log(t.parent);
69 Debug.Log(things.Contains(t) + "/" + cardMap.ContainsKey(t.id));
70 Debug.LogError(t?.ToString() + " alreadin in " + this);
71 return;
72 }
73 if (t.props != null)
74 {
75 t.props.Remove(t);
76 }
77 t.props = this;
78 t.placeState = state;
79 if (t.isChara)
80 {
81 raceMap.GetOrCreate(t.Chara.race.id).Add(t);
82 return;
83 }
84 foreach (Thing thing in t.things)
85 {
86 if (t.placeState != 0)
87 {
88 EClass._map.Stocked.Add(thing);
89 }
90 }
91 weight += t.Num;
92 all.Add(t);
93 things.Add(t.Thing);
94 cardMap.GetOrCreate(t.id).Add(t);
95 if (t.sourceCard.origin != null)
96 {
97 cardMap.GetOrCreate(t.sourceCard.origin.id).Add(t);
98 }
99 categoryMap[t.category.id].Add(t);
100 if (!t.Thing.source.workTag.IsEmpty())
101 {
102 workMap.GetOrCreate(t.Thing.source.workTag).Add(t);
103 }
104 if (t.IsContainer)
105 {
107 }
108 traits.OnAddCard(t);
109 if (t.isDeconstructing)
110 {
112 }
113 }
void Add(Act a, string s="")
Definition: ActPlan.cs:11
CardRow origin
Definition: CardRow.cs:49
string id
Definition: CardRow.cs:7
Props props
Definition: Card.cs:47
virtual Chara Chara
Definition: Card.cs:1946
string id
Definition: Card.cs:31
ICardParent parent
Definition: Card.cs:51
PlaceState placeState
Definition: Card.cs:79
bool isDeconstructing
Definition: Card.cs:418
ThingContainer things
Definition: Card.cs:34
virtual bool isChara
Definition: Card.cs:1959
virtual Thing Thing
Definition: Card.cs:1934
virtual CardRow sourceCard
Definition: Card.cs:2007
int Num
Definition: Card.cs:154
SourceCategory.Row category
Definition: Card.cs:1925
bool IsContainer
Definition: Card.cs:1965
SourceRace.Row race
Definition: Chara.cs:449
Definition: EClass.cs:5
static Map _map
Definition: EClass.cs:18
PropsManager props
Definition: Map.cs:91
PropsStocked Stocked
Definition: Map.cs:121
new void Add(Card c)
Definition: PropSet.cs:7
List< Card > deconstructing
Definition: PropsManager.cs:12
virtual PlaceState state
Definition: Props.cs:35
int weight
Definition: Props.cs:27
TraitManager traits
Definition: Props.cs:18
Dictionary< string, PropSet > raceMap
Definition: Props.cs:14
void Add(Card t)
Definition: Props.cs:63
List< Thing > things
Definition: Props.cs:20
Dictionary< string, PropSet > cardMap
Definition: Props.cs:10
void Remove(Card t)
Definition: Props.cs:115
List< Thing > containers
Definition: Props.cs:22
Dictionary< string, PropSet > workMap
Definition: Props.cs:16
Dictionary< string, PropSetCategory > categoryMap
Definition: Props.cs:12
PropSet all
Definition: Props.cs:8
Definition: Thing.cs:8
SourceThing.Row source
Definition: Thing.cs:11
void OnAddCard(Card c)
Definition: TraitManager.cs:16

References EClass._map, ActPlan.List.Add(), PropSet.Add(), Add(), all, cardMap, categoryMap, Card.Chara, containers, Debug, PropsManager.deconstructing, Card.id, Card.isChara, TraitManager.OnAddCard(), Card.parent, Card.props, Map.props, Chara.race, raceMap, Remove(), state, Map.Stocked, Card.things, things, traits, weight, and workMap.

Referenced by Add(), Card.AddThing(), PropsManager.OnCardAddedToZone(), and PropsManager.OnSetPlaceState().

◆ Find() [1/3]

Thing Props.Find ( int  uid)
inline

Definition at line 357 of file Props.cs.

358 {
359 foreach (Thing thing in Things)
360 {
361 if (thing.uid == uid)
362 {
363 return thing;
364 }
365 }
366 return null;
367 }
int uid
Definition: Card.cs:118
List< Thing > Things
Definition: Props.cs:37

References Things, and Card.uid.

Referenced by TaskBuild._CanPerformTask(), DropdownGrid.BuildIngredients(), QuestCrafter.CanUpdateOnTalk(), FactionBranch.DailyOutcome(), Find(), FindShared(), FactionBranch.GetMailBoxPos(), Zone.GetSpawnPos(), ListThingStack(), Zone_Nymelle.OnBeforeSimulate(), Recipe.Ingredient.RefreshThing(), AI_Idle.Run(), and MeetingManager.SetRoom().

◆ Find() [2/3]

Thing Props.Find ( string  id,
int  idMat = -1,
int  refVal = -1,
bool  shared = false 
)
inline

Definition at line 379 of file Props.cs.

380 {
381 PropSet propSet = cardMap.TryGetValue(id);
382 if (propSet != null)
383 {
384 foreach (Card item in propSet)
385 {
386 if ((!shared || item.parent is Thing { IsSharedContainer: not false }) && (idMat == -1 || item.material.id == idMat) && (refVal == -1 || item.refVal == refVal))
387 {
388 return item as Thing;
389 }
390 }
391 }
392 return null;
393 }
Definition: Card.cs:11

References cardMap, and item.

◆ Find() [3/3]

Thing Props.Find ( string  id,
string  idMat 
)
inline

Definition at line 374 of file Props.cs.

375 {
376 return Find(id, idMat.IsEmpty() ? (-1) : EClass.sources.materials.alias[idMat].id);
377 }
static SourceManager sources
Definition: EClass.cs:42
Thing Find(int uid)
Definition: Props.cs:357
SourceMaterial materials

References Find(), SourceManager.materials, and EClass.sources.

◆ Find< T >()

Thing Props.Find< T > ( )
inline
Type Constraints
T :Trait 

Definition at line 321 of file Props.cs.

321 : Trait
322 {
323 foreach (Thing thing in Things)
324 {
325 if (thing.trait is T)
326 {
327 return thing;
328 }
329 }
330 return null;
331 }
Trait trait
Definition: Card.cs:49
Definition: Trait.cs:7

References Things, and Card.trait.

◆ FindEmptyContainer< T >() [1/2]

Thing Props.FindEmptyContainer< T > ( )
inline
Type Constraints
T :Trait 

Definition at line 333 of file Props.cs.

333 : Trait
334 {
335 foreach (Thing thing in Things)
336 {
337 if (thing.trait is T && !thing.things.IsFull())
338 {
339 return thing;
340 }
341 }
342 return null;
343 }
bool IsFull(int y=0)

References ThingContainer.IsFull(), Card.things, Things, and Card.trait.

◆ FindEmptyContainer< T >() [2/2]

Thing Props.FindEmptyContainer< T > ( Thing  target)
inline
Type Constraints
T :Trait 

Definition at line 345 of file Props.cs.

345 : Trait
346 {
347 foreach (Thing thing in Things)
348 {
349 if (thing.trait is T && !thing.things.IsFull(target))
350 {
351 return thing;
352 }
353 }
354 return null;
355 }

References ThingContainer.IsFull(), Card.things, Things, and Card.trait.

◆ FindShared()

Thing Props.FindShared ( string  id)
inline

Definition at line 369 of file Props.cs.

370 {
371 return Find(id, -1, -1, shared: true);
372 }

References Find().

◆ GetAvailableThing()

Thing Props.GetAvailableThing ( string  id,
int  idMat 
)
inline

Definition at line 187 of file Props.cs.

188 {
189 PropSet propSet = cardMap.TryGetValue(id);
190 if (propSet == null)
191 {
192 return null;
193 }
194 foreach (Card item in propSet)
195 {
196 if (item.idMaterial == idMat)
197 {
198 return item as Thing;
199 }
200 }
201 return null;
202 }

References cardMap, and item.

◆ GetNum()

int Props.GetNum ( string  id,
bool  onlyShared = false 
)
inline

Definition at line 395 of file Props.cs.

396 {
397 int num = 0;
398 foreach (Card item in cardMap.GetOrCreate(id))
399 {
400 if (!onlyShared || (item.parentThing != null && item.parentThing.IsSharedContainer))
401 {
402 num += item.Num;
403 }
404 }
405 return num;
406 }

References cardMap, and item.

Referenced by FactionBranch.CountPasture(), and GetNumStockedAndRoaming().

◆ GetNumStockedAndRoaming()

static int Props.GetNumStockedAndRoaming ( string  id)
inlinestatic

Definition at line 408 of file Props.cs.

409 {
410 return EClass._map.Stocked.cardMap.GetOrCreate(id).num + EClass._map.Roaming.GetNum(id);
411 }
PropsRoaming Roaming
Definition: Map.cs:125
int GetNum(string id, bool onlyShared=false)
Definition: Props.cs:395

References EClass._map, cardMap, GetNum(), Map.Roaming, and Map.Stocked.

◆ Init()

void Props.Init ( )
inline

Definition at line 41 of file Props.cs.

42 {
43 if (categoryMap.Count > 0)
44 {
45 return;
46 }
47 foreach (SourceCategory.Row row in EClass.sources.categories.rows)
48 {
49 categoryMap.Add(row.id, new PropSetCategory
50 {
51 source = row
52 });
53 }
54 foreach (PropSetCategory value in categoryMap.Values)
55 {
56 if (value.source.parent != null)
57 {
58 value.parent = categoryMap[value.source.parent.id];
59 }
60 }
61 }
SourceCategory.Row source
SourceCategory categories

References SourceManager.categories, categoryMap, PropSetCategory.source, and EClass.sources.

Referenced by PropsManager.Init().

◆ ListThingsInCategory()

List< Thing > Props.ListThingsInCategory ( SourceCategory::Row  cat)
inline

Definition at line 283 of file Props.cs.

284 {
285 List<Thing> list = new List<Thing>();
286 foreach (Thing thing in Things)
287 {
288 if (thing.category.IsChildOf(cat))
289 {
290 list.Add(thing);
291 }
292 }
293 return list;
294 }

References Card.category, and Things.

Referenced by LayerResource.ShowThings().

◆ ListThingStack()

ThingStack Props.ListThingStack ( Recipe::Ingredient  ing,
StockSearchMode  searchMode 
)
inline

Definition at line 204 of file Props.cs.

205 {
206 string id2 = ing.id;
207 int idMat = -1;
208 string tag = (ing.tag.IsEmpty() ? null : ing.tag);
209 ThingStack stack = new ThingStack
210 {
211 val = idMat
212 };
213 _ = EClass.pc.pos.cell.room;
214 if (ing.useCat)
215 {
216 FindCat(id2);
217 foreach (string item in ing.idOther)
218 {
219 FindCat(item);
220 }
221 stack.list.Sort(UIList.SortMode.ByCategory);
222 return stack;
223 }
224 Find(id2);
225 foreach (string item2 in ing.idOther)
226 {
227 Find(item2);
228 }
229 stack.list.Sort(UIList.SortMode.ByCategory);
230 return stack;
231 void Find(string id)
232 {
233 bool isOrigin = EClass.sources.cards.map[id].isOrigin;
234 EClass.pc.things.Foreach(delegate(Thing t)
235 {
236 if (!t.isEquipped && (!(t.id != id) || (isOrigin && t.source._origin == id)))
237 {
238 TryAdd(t);
239 }
240 });
242 {
243 foreach (Card item3 in cardMap.GetOrCreate(id))
244 {
245 if (!(item3.parent is Thing thing) || (thing.c_lockLv == 0 && thing.trait.CanUseContent))
246 {
247 TryAdd(item3.Thing);
248 }
249 }
250 }
251 }
252 void FindCat(string id)
253 {
255 EClass.pc.things.Foreach(delegate(Thing t)
256 {
257 if (!t.isEquipped && t.category.IsChildOf(cat.id) && !t.IsExcludeFromCraft())
258 {
259 stack.Add(t);
260 }
261 });
263 {
264 foreach (Thing thing2 in things)
265 {
266 Card obj = thing2.parent as Card;
267 if (obj != null && obj.c_lockLv == 0 && thing2.category.IsChildOf(cat.id) && !thing2.IsExcludeFromCraft())
268 {
269 stack.Add(thing2);
270 }
271 }
272 }
273 }
274 void TryAdd(Thing t)
275 {
276 if ((tag == null || t.Thing.material.tag.Contains(tag)) && (idMat == -1 || t.material.id == idMat) && !t.IsExcludeFromCraft())
277 {
278 stack.Add(t.Thing);
279 }
280 }
281 }
SourceMaterial.Row material
Definition: Card.cs:1927
bool IsExcludeFromCraft()
Definition: Card.cs:2389
int c_lockLv
Definition: Card.cs:924
Point pos
Definition: Card.cs:55
Room room
Definition: Cell.cs:102
bool enable
Definition: CoreDebug.cs:285
static Zone _zone
Definition: EClass.cs:20
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
Cell cell
Definition: Point.cs:51
List< string > idOther
Definition: Recipe.cs:35
string tag
Definition: Recipe.cs:32
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
SourceCard cards
void Foreach(Action< Thing > action, bool onlyAccessible=true)
void Add(Thing t)
Definition: ThingStack.cs:13
List< Thing > list
Definition: ThingStack.cs:5
bool isEquipped
Definition: Thing.cs:17
Definition: UIList.cs:9
SortMode
Definition: UIList.cs:27
bool IsPCFaction
Definition: Zone.cs:464

References EClass._zone, Card.Add(), Card.c_lockLv, cardMap, SourceManager.cards, SourceManager.categories, Card.category, Point.cell, EClass.debug, CoreDebug.enable, Find(), ThingContainer.Foreach(), Card.id, SourceCategory.Row.id, Thing.isEquipped, Card.IsExcludeFromCraft(), Zone.IsPCFaction, item, ThingStack.list, SourceCard.map, Card.material, Card.parent, EClass.pc, Card.pos, Cell.room, Thing.source, EClass.sources, Card.Thing, Card.things, and things.

Referenced by QuestTrackCraft.GetDetail(), Recipe.IsCraftable(), DropdownGrid.ListIngredients(), UIRecipeInfo.RefreshList(), DropdownGrid.TrySelect(), and ButtonGrid.WriteReqMat().

◆ ListThingStacksInCategory() [1/2]

Dictionary< string, ThingStack > Props.ListThingStacksInCategory ( SourceCategory::Row  cat)
inline

Definition at line 296 of file Props.cs.

297 {
298 Dictionary<string, ThingStack> dictionary = new Dictionary<string, ThingStack>();
299 foreach (Thing thing in Things)
300 {
301 ListThingStacksInCategory(cat, dictionary, thing);
302 }
303 return dictionary;
304 }
Dictionary< string, ThingStack > ListThingStacksInCategory(SourceCategory.Row cat)
Definition: Props.cs:296

References ListThingStacksInCategory(), and Things.

Referenced by ListThingStacksInCategory().

◆ ListThingStacksInCategory() [2/2]

void Props.ListThingStacksInCategory ( SourceCategory::Row  cat,
Dictionary< string, ThingStack stacks,
Thing  t 
)
inlineprivate

Definition at line 306 of file Props.cs.

307 {
308 if (EClass.sources.categories.map[t.source.category].IsChildOf(cat))
309 {
310 ThingStack thingStack = stacks.TryGetValue(t.id);
311 if (thingStack == null)
312 {
313 thingStack = new ThingStack();
314 stacks.Add(t.id, thingStack);
315 }
316 thingStack.count += t.Num;
317 thingStack.list.Add(t);
318 }
319 }

References ActPlan.List.Add(), SourceManager.categories, Card.id, ThingStack.list, Card.Num, Thing.source, and EClass.sources.

◆ OnNumChange()

void Props.OnNumChange ( Card  c,
int  a 
)
inline

Definition at line 160 of file Props.cs.

161 {
162 if (!c.isChara)
163 {
164 weight += a;
165 categoryMap[c.category.id].OnChangeNum(a);
166 cardMap[c.id].OnChangeNum(a);
167 if (!c.Thing.source.workTag.IsEmpty())
168 {
169 workMap[c.Thing.source.workTag].OnChangeNum(a);
170 }
171 }
172 }

References cardMap, Card.category, categoryMap, Card.id, Card.isChara, Thing.source, Card.Thing, weight, and workMap.

Referenced by Card.ModNum().

◆ Remove()

void Props.Remove ( Card  t)
inline

Definition at line 115 of file Props.cs.

116 {
117 t.props = null;
118 t.placeState = PlaceState.roaming;
119 if (t.isChara)
120 {
121 raceMap[t.Chara.race.id].Remove(t);
122 return;
123 }
124 foreach (Thing thing in t.things)
125 {
126 if (thing.props != null)
127 {
128 thing.props.Remove(thing);
129 }
130 }
131 if (!all.Contains(t))
132 {
133 Debug.LogError(t?.ToString() + " isn't in " + this);
134 return;
135 }
136 weight -= t.Num;
137 all.Remove(t);
138 things.Remove(t.Thing);
139 cardMap[t.id].Remove(t);
140 if (t.sourceCard.origin != null)
141 {
142 cardMap[t.sourceCard.origin.id].Remove(t);
143 }
144 categoryMap[t.category.id].Remove(t);
145 if (!t.Thing.source.workTag.IsEmpty())
146 {
147 workMap[t.Thing.source.workTag].Remove(t);
148 }
149 if (t.IsContainer)
150 {
151 containers.Remove(t.Thing);
152 }
154 if (t.isDeconstructing)
155 {
157 }
158 }
PlaceState
Definition: PlaceState.cs:2
new void Remove(Card c)
Definition: PropSet.cs:13
void OnRemoveCard(Card c)
Definition: TraitManager.cs:38

References EClass._map, all, cardMap, categoryMap, Card.Chara, containers, Debug, PropsManager.deconstructing, Card.isChara, TraitManager.OnRemoveCard(), Card.props, Map.props, Chara.race, raceMap, PropSet.Remove(), Remove(), Card.things, things, traits, weight, and workMap.

Referenced by Add(), PropsManager.OnSetPlaceState(), Remove(), Card.RemoveThing(), and Card.SetPlaceState().

◆ ShouldListAsResource()

bool Props.ShouldListAsResource ( Thing  t)
inline

Definition at line 174 of file Props.cs.

175 {
176 if (!(t.parent is Card card))
177 {
178 return false;
179 }
180 if (card.isSale || !card.trait.CanUseContent)
181 {
182 return false;
183 }
184 return !t.c_isImportant;
185 }
bool c_isImportant
Definition: Card.cs:984

References Card.c_isImportant, card, and Card.parent.

Referenced by BuildMenu._Search(), UIDragGridIngredients.Refresh(), and BuildMenu.RefreshCategory().

◆ Validate()

void Props.Validate ( )
inline

Definition at line 413 of file Props.cs.

414 {
415 foreach (KeyValuePair<string, PropSet> item in cardMap)
416 {
417 int num = 0;
418 foreach (Card item2 in item.Value)
419 {
420 num += item2.Num;
421 }
422 if (num != item.Value.num)
423 {
424 Debug.LogError("prop num:" + item.Key + " " + item.Value.num + "/" + num);
425 }
426 }
427 }

References cardMap, Debug, item, and Card.Num.

Referenced by CoreDebug.ValidateData().

Member Data Documentation

◆ all

◆ cardMap

◆ categoryMap

Dictionary<string, PropSetCategory> Props.categoryMap = new Dictionary<string, PropSetCategory>()

◆ containers

◆ maxWeight

int Props.maxWeight = 100

Definition at line 25 of file Props.cs.

Referenced by LayerResource.OnInit().

◆ raceMap

Dictionary<string, PropSet> Props.raceMap = new Dictionary<string, PropSet>()

Definition at line 14 of file Props.cs.

Referenced by Add(), GameUpdater.SurfaceUpdater.FixedUpdate(), and Remove().

◆ things

List<Thing> Props.things = new List<Thing>()

Definition at line 20 of file Props.cs.

Referenced by Add(), Map.FindThing(), QuestDeliver.ListDestThing(), ListThingStack(), and Remove().

◆ traits

◆ weight

int Props.weight

Definition at line 27 of file Props.cs.

Referenced by Add(), LayerResource.OnInit(), OnNumChange(), and Remove().

◆ workMap

Dictionary<string, PropSet> Props.workMap = new Dictionary<string, PropSet>()

Definition at line 16 of file Props.cs.

Referenced by Add(), Map.FindThing(), OnNumChange(), and Remove().

Property Documentation

◆ Count

int Props.Count
get

Definition at line 39 of file Props.cs.

◆ IsInstalled

virtual bool Props.IsInstalled
get

Definition at line 33 of file Props.cs.

◆ IsRoaming

virtual bool Props.IsRoaming
get

Definition at line 31 of file Props.cs.

◆ IsStocked

virtual bool Props.IsStocked
get

Definition at line 29 of file Props.cs.

◆ state

virtual PlaceState Props.state
get

Definition at line 35 of file Props.cs.

Referenced by Add().

◆ Things


The documentation for this class was generated from the following file: