Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HomeResourceWorth.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using Newtonsoft.Json;
4using UnityEngine;
5
7{
8 [JsonProperty]
9 public int bestRank;
10
11 public override bool IsAvailable => false;
12
13 public void UpdateRank()
14 {
16 if (bestRank == 0)
17 {
18 bestRank = rank;
19 }
20 if (rank < bestRank)
21 {
22 bestRank = rank;
23 EClass.Sound.Play((rank <= 50) ? "clap3" : ((rank <= 100) ? "clap2" : "clap1"));
25 }
26 }
27
28 public override void Refresh()
29 {
30 base.Refresh();
31 UpdateRank();
32 }
33
34 public int GetPrice(Thing t, bool top = false)
35 {
36 int num = t.GetPrice(CurrencyType.Money, sell: false, PriceType.Tourism);
37 if (t.noSell)
38 {
39 num /= 50;
40 }
41 if (top && branch.policies.IsActive(2821))
42 {
43 num = (int)((long)num * (long)(150 + (int)Mathf.Sqrt(branch.Evalue(2821)) * 5) / 100);
44 }
45 return num;
46 }
47
48 public override int GetDestValue()
49 {
50 List<Thing> list = ListHeirloom();
51 int num = 0;
52 foreach (Thing item in list)
53 {
54 num += GetPrice(item, list[0] == item);
55 }
56 return num;
57 }
58
59 public List<Thing> ListHeirloom()
60 {
61 List<Thing> list = new List<Thing>();
62 List<Thing> list2 = new List<Thing>();
63 HashSet<string> hashSet = new HashSet<string>();
64 int[] array = new int[EClass._map.SizeXZ];
65 long num = 0L;
66 int num2 = branch.Evalue(2814);
67 int num3 = branch.Evalue(2823);
68 List<Thing> list3 = EClass._map.things.Where((Thing t) => t.IsInstalled && t.HasTag(CTAG.tourism)).ToList();
69 foreach (Thing item in list3)
70 {
71 item.sortVal = GetPrice(item);
72 }
73 list3.Sort((Thing a, Thing b) => b.sortVal - a.sortVal);
74 foreach (Thing item2 in list3)
75 {
76 bool flag = item2.trait is TraitFigure;
77 if (flag)
78 {
79 if (array[item2.pos.index] != 0)
80 {
81 continue;
82 }
83 array[item2.pos.index]++;
84 }
85 string text = "";
86 int num4 = 1;
87 if (flag)
88 {
89 text = "figure_" + item2.c_idRefCard;
90 num4 = 2;
91 }
92 else
93 {
94 text = item2.id + "_" + item2.idSkin;
95 }
96 if (!hashSet.Contains(text))
97 {
98 int num5 = item2.sortVal * num4;
99 if (num3 > 0)
100 {
101 num5 = num5 * (110 + (int)Mathf.Sqrt(num3) * 4) / 100;
102 }
103 num += num5;
104 hashSet.Add(text);
105 }
106 else if (num2 > 0)
107 {
108 int num6 = item2.sortVal * num4 / Mathf.Max(20, 30 - (int)Mathf.Sqrt(num2));
109 if (num6 > 0)
110 {
111 num += num6;
112 }
113 }
114 }
115 foreach (Thing thing in EClass._map.things)
116 {
117 if (thing.IsInstalled && (thing.IsFurniture || thing.trait is TraitToolMusic))
118 {
119 list2.Add(thing);
120 }
121 }
122 int num7 = branch.Evalue(3780) + branch.Evalue(3781) + branch.Evalue(3782) + branch.Evalue(3783) + branch.Evalue(3784);
123 num = (100 + num) * (100 + num7 * 15) / 100;
124 branch.tourism = (int)num;
125 list2.Sort((Thing a, Thing b) => GetPrice(b) - GetPrice(a));
126 for (int i = 0; i < branch.NumHeirloom && i < list2.Count; i++)
127 {
128 list.Add(list2[i]);
129 }
130 return list;
131 }
132
133 public override void WriteNote(UINote n)
134 {
135 n.Clear();
136 n.AddHeader(base.Name);
137 n.AddTopic("TopicLeft", "vCurrent".lang(), value.ToFormat() ?? "");
138 n.AddTopic("TopicLeft", "tourism_value".lang(), branch.tourism.ToFormat() ?? "");
139 n.Space();
140 n.AddHeader("HeaderTopic", "heirloom_list".lang(branch.NumHeirloom.ToString() ?? ""));
141 n.Space(1);
142 List<Thing> list = ListHeirloom();
143 for (int i = 0; i < list.Count; i++)
144 {
145 Thing thing = list[i];
146 n.AddText(i + 1 + ": " + thing.Name + (EClass.debug.showExtra ? ((object)GetPrice(thing, i == 0)) : ""));
147 }
148 n.Build();
149 }
150}
CTAG
Definition: CTAG.cs:2
CurrencyType
Definition: CurrencyType.cs:2
PriceType
Definition: PriceType.cs:2
FactionBranch branch
bool noSell
Definition: Card.cs:802
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:6449
string Name
Definition: Card.cs:2013
bool IsFurniture
Definition: Card.cs:2111
bool HasTag(CTAG tag)
Definition: Card.cs:2455
Point pos
Definition: Card.cs:55
int sortVal
Definition: Card.cs:97
Trait trait
Definition: Card.cs:49
bool IsInstalled
Definition: Card.cs:2241
int idSkin
Definition: Card.cs:346
string c_idRefCard
Definition: Card.cs:1637
bool showExtra
Definition: CoreDebug.cs:167
Definition: EClass.cs:5
static Game game
Definition: EClass.cs:8
static Map _map
Definition: EClass.cs:18
static CoreDebug debug
Definition: EClass.cs:48
static SoundManager Sound
Definition: EClass.cs:46
int Evalue(int ele)
PolicyManager policies
SpatialManager spatials
Definition: Game.cs:152
override void Refresh()
override bool IsAvailable
List< Thing > ListHeirloom()
override void WriteNote(UINote n)
override int GetDestValue()
int GetPrice(Thing t, bool top=false)
int SizeXZ
Definition: Map.cs:133
List< Thing > things
Definition: Map.cs:49
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
int index
Definition: Point.cs:49
bool IsActive(int id, int days=-1)
string GetRankText(Zone z)
RankedZoneManager ranks
Definition: Thing.cs:8
Definition: UINote.cs:6
void Clear()
Definition: UINote.cs:35
UIItem AddHeader(string text, Sprite sprite=null)
Definition: UINote.cs:79
UIItem AddTopic(string id, string text, string value=null)
Definition: UINote.cs:144
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
void Build()
Definition: UINote.cs:49