forked from arislancrescent/CS-SkylinesOverwatch
/
HumanPrefabMapping.cs
67 lines (55 loc) · 1.93 KB
/
HumanPrefabMapping.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
using System;
using System.Collections.Generic;
using System.Threading;
using ICities;
using ColossalFramework;
using ColossalFramework.Math;
using ColossalFramework.UI;
using UnityEngine;
namespace SkylinesOverwatch
{
public class HumanPrefabMapping
{
private Settings _settings;
private Helper _helper;
private Data _data;
private PrefabMapping<uint> _mapping;
public HumanPrefabMapping()
{
_settings = Settings.Instance;
_helper = Helper.Instance;
_data = Data.Instance;
_mapping = new PrefabMapping<uint>();
}
public List<HashSet<uint>> GetMapping(CitizenInfo human)
{
int prefabID = human.m_prefabDataIndex;
if (!_mapping.PrefabMapped(prefabID))
CategorizePrefab(human);
return _mapping.GetMapping(prefabID);
}
private void CategorizePrefab(CitizenInfo human)
{
CitizenAI ai = human.m_citizenAI;
int prefabID = human.m_prefabDataIndex;
/*
* Create a blank entry. This way, even if this prefab does not belong here
* for some bizarre reason, we will have a record of it. This eliminates
* the chance of a prefab getting evaluated more than once, ever.
*/
_mapping.AddEntry(prefabID);
if (ai is HumanAI)
{
_mapping.AddMapping(prefabID, _data._Humans);
if (ai is ResidentAI)
_mapping.AddMapping(prefabID, _data._Residents);
else if (ai is ServicePersonAI)
_mapping.AddMapping(prefabID, _data._ServicePersons);
else if (ai is TouristAI)
_mapping.AddMapping(prefabID, _data._Tourists);
else
_mapping.AddMapping(prefabID, _data._HumanOther);
}
}
}
}