-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJobsUtils.cs
95 lines (80 loc) · 3.16 KB
/
JobsUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using ICities;
using ColossalFramework;
using UnityEngine;
namespace CS_EmploymentDetailsExtender
{
public static class JobsUtils
{
private static readonly DistrictManager dm = Singleton<DistrictManager>.instance;
/* TODO : replace by dynamic ingame values */
public static readonly Color32[] educationLevelColors = new Color32[] {
new Color32(241, 136, 136, 255),
new Color32(251, 212, 0, 255),
new Color32(141, 149, 55, 255),
new Color32(131, 213, 141, 255)
};
/* TODO : replace by dynamic ingame values (and if possible localized) */
public static readonly String[] educationLevelNames = new String[] {
"Uneducated",
"Educated",
"Well Educated",
"Highly Educated"
};
public static string GetEmploymentLabel(int educationLevel)
{
DistrictEducationData ded = GetEducationData(educationLevel);
int percent = GetPercentEmployed(educationLevel);
return percent + "% (" + (ded.m_finalEligibleWorkers - ded.m_finalUnemployed) + "/" + ded.m_finalEligibleWorkers + ")";
}
public static int GetEmploymentMaxValue(int educationLevel)
{
DistrictEducationData ded = GetEducationData(educationLevel);
return (int)ded.m_finalEligibleWorkers;
}
public static int GetEmploymentCurrentValue(int educationLevel)
{
DistrictEducationData ded = GetEducationData(educationLevel);
return (int)(ded.m_finalEligibleWorkers - ded.m_finalUnemployed);
}
private static DistrictEducationData GetEducationData(int educationLevel)
{
District d = dm.m_districts.m_buffer[0];
DistrictEducationData ded = d.m_educated0Data;
switch (educationLevel)
{
case 0:
ded = d.m_educated0Data;
break;
case 1:
ded = d.m_educated1Data;
break;
case 2:
ded = d.m_educated2Data;
break;
case 3:
ded = d.m_educated3Data;
break;
}
return ded;
}
public static int GetPercentEmployed(int educationLevel)
{
return 100 - GetPercentUnemployed(educationLevel);
}
public static float GetPercentEmployedF(int educationLevel)
{
return 1f - GetPercentUnemployedF(educationLevel);
}
public static int GetPercentUnemployed(int educationLevel)
{
float num = GetPercentUnemployedF(educationLevel);
return Mathf.Clamp(Mathf.RoundToInt(num * 100f), 0, 100);
}
public static float GetPercentUnemployedF(int educationLevel)
{
DistrictEducationData ded = GetEducationData(educationLevel);
return (float)ded.m_finalUnemployed / (float)ded.m_finalEligibleWorkers;
}
}
}