Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HomeResource.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
4{
5 public class CostList : List<Cost>
6 {
7 public string GetText()
8 {
9 string text = "";
10 using Enumerator enumerator = GetEnumerator();
11 while (enumerator.MoveNext())
12 {
13 Cost c = enumerator.Current;
14 text = text + (c.resource.Name + ":" + c.cost).TagColorGoodBad(() => c.resource.value >= c.cost, () => c.resource.value < c.cost) + " ";
15 }
16 return text;
17 }
18
19 public bool CanPay()
20 {
21 using (Enumerator enumerator = GetEnumerator())
22 {
23 while (enumerator.MoveNext())
24 {
25 Cost current = enumerator.Current;
26 if (current.resource.value < current.cost)
27 {
28 return false;
29 }
30 }
31 }
32 return true;
33 }
34
35 public void Pay()
36 {
37 using Enumerator enumerator = GetEnumerator();
38 while (enumerator.MoveNext())
39 {
40 Cost current = enumerator.Current;
41 current.resource.Mod(-current.cost);
42 }
43 }
44 }
45
46 public class Cost
47 {
48 public int cost;
49
51
52 public Cost(HomeResource _resource, int _cost)
53 {
54 resource = _resource;
55 cost = _cost;
56 }
57 }
58
59 public override void OnAdvanceDay()
60 {
62 }
63
64 public override void Mod(int a, bool popText = true)
65 {
66 if (a != 0)
67 {
68 value += a;
69 if (popText)
70 {
71 WidgetPopText.SayValue(base.Name, a, negative: false, base.Sprite);
72 }
73 }
74 }
75
76 public void AddResource(int a, ref string s)
77 {
78 if (a != 0)
79 {
80 value += a;
81 s = s + (base.Name + " " + a).TagColorGoodBad(() => a > 0) + ",";
82 }
83 }
84}
HomeResource resource
Definition: HomeResource.cs:50
Cost(HomeResource _resource, int _cost)
Definition: HomeResource.cs:52
override void Mod(int a, bool popText=true)
Definition: HomeResource.cs:64
override void OnAdvanceDay()
Definition: HomeResource.cs:59
void AddResource(int a, ref string s)
Definition: HomeResource.cs:76
static void SayValue(string name, int a, bool negative=false, Sprite sprite=null)