forked from arislancrescent/CS-SkylinesOverwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VehiclePrefabMapping.cs
89 lines (76 loc) · 2.91 KB
/
VehiclePrefabMapping.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
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 VehiclePrefabMapping
{
private Settings _settings;
private Helper _helper;
private Data _data;
private PrefabMapping<ushort> _mapping;
public VehiclePrefabMapping()
{
_settings = Settings.Instance;
_helper = Helper.Instance;
_data = Data.Instance;
_mapping = new PrefabMapping<ushort>();
}
public List<HashSet<ushort>> GetMapping(VehicleInfo vehicle)
{
int prefabID = vehicle.m_prefabDataIndex;
if (!_mapping.PrefabMapped(prefabID))
CategorizePrefab(vehicle);
return _mapping.GetMapping(prefabID);
}
private void CategorizePrefab(VehicleInfo vehicle)
{
VehicleAI ai = vehicle.m_vehicleAI;
int prefabID = vehicle.m_prefabDataIndex;
_mapping.AddMapping(prefabID, _data._Vehicles);
if (ai is CarTrailerAI)
return;
else if (ai is CarAI)
{
_mapping.AddMapping(prefabID, _data._Cars);
if (ai is HearseAI)
_mapping.AddMapping(prefabID, _data._Hearses);
else if (ai is GarbageTruckAI)
_mapping.AddMapping(prefabID, _data._GarbageTrucks);
else if (ai is FireTruckAI)
_mapping.AddMapping(prefabID, _data._FireTrucks);
else if (ai is PoliceCarAI)
_mapping.AddMapping(prefabID, _data._PoliceCars);
else if (ai is AmbulanceAI)
_mapping.AddMapping(prefabID, _data._Ambulances);
else if (ai is BusAI)
_mapping.AddMapping(prefabID, _data._Buses);
else
_mapping.AddMapping(prefabID, _data._CarOther);
}
else if (ai is TrainAI)
{
_mapping.AddMapping(prefabID, _data._Trains);
if (ai is MetroTrainAI)
_mapping.AddMapping(prefabID, _data._MetroTrains);
else if (ai is PassengerTrainAI)
_mapping.AddMapping(prefabID, _data._PassengerTrains);
else if (ai is CargoTrainAI)
_mapping.AddMapping(prefabID, _data._CargoTrains);
else
_mapping.AddMapping(prefabID, _data._TrainOther);
}
else if (ai is AircraftAI)
_mapping.AddMapping(prefabID, _data._Aircraft);
else if (ai is ShipAI)
_mapping.AddMapping(prefabID, _data._Ships);
else
_mapping.AddMapping(prefabID, _data._VehicleOther);
}
}
}