This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
forked from bloodypenguin/Skylines-MetroOverhaulMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReverseEngineerStationCustomizations.cs
51 lines (48 loc) · 2.31 KB
/
ReverseEngineerStationCustomizations.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
using ColossalFramework;
using MetroOverhaul.Extensions;
using MetroOverhaul.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using static MetroOverhaul.StationTrackCustomizations;
namespace MetroOverhaul
{
public class ReverseEngineerStationCustomizations
{
public MetroStationCustomizerUI m_UI { get; set; }
public StationTrackCustomizations TrackCustomization { get; }
public BuildingInfo BuildingPrefab { get; set; }
public bool AllTracks { get; set; }
private readonly ushort m_BuildingID;
private readonly Building m_Building;
private readonly ushort m_SegmentID;
private readonly NetSegment m_Segment;
public ReverseEngineerStationCustomizations(MetroStationCustomizerUI ui, int buildingID, ushort segmentID)
{
m_UI = ui;
m_BuildingID = (ushort)buildingID;
m_Building = Singleton<BuildingManager>.instance.m_buildings.m_buffer[m_BuildingID];
BuildingPrefab = m_Building.Info;
m_SegmentID = segmentID;
if (m_SegmentID > 0)
m_Segment = Singleton<NetManager>.instance.m_segments.m_buffer[m_SegmentID];
AllTracks = segmentID == 0;
TrackCustomization = new StationTrackCustomizations()
{
Horizontal = RestoreCustomizations(MetroStationTrackAlterType.Horizontal, m_Building.m_happiness),
Vertical = RestoreCustomizations(MetroStationTrackAlterType.Vertical, m_Building.m_health),
Length = RestoreCustomizations(MetroStationTrackAlterType.Length, m_Building.m_children),
Depth = RestoreCustomizations(MetroStationTrackAlterType.Depth, m_Building.m_childHealth),
Rotation = RestoreCustomizations(MetroStationTrackAlterType.Rotation, m_Building.m_seniors),
Curve = RestoreCustomizations(MetroStationTrackAlterType.Curve, m_Building.m_seniorHealth),
TrackType = (StationTrackType)(m_Building.m_teens)
};
}
private int RestoreCustomizations(MetroStationTrackAlterType trackAlterType, byte cachedValue)
{
return (int)(m_UI.SliderDataDict[trackAlterType].Min + (cachedValue * m_UI.SliderDataDict[trackAlterType].Step));
}
}
}