-
Notifications
You must be signed in to change notification settings - Fork 2
/
PAScaleManager.cs
59 lines (56 loc) · 2.79 KB
/
PAScaleManager.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
using ColossalFramework;
using EManagersLib;
using MoveIt;
using UnityEngine;
namespace PropAnarchy {
public sealed partial class PAManager : SingletonLite<PAManager> {
public const float minScale = 0.2f;
public const float maxScale = 5.0f;
public const float scaleStep = 0.2f;
public static uint m_currentPropID = 0;
public static void IncrementPropSize() {
float scale;
EPropInstance[] props = EPropManager.m_props.m_buffer;
PropTool propTool = ToolsModifierControl.GetCurrentTool<PropTool>();
uint propID = m_currentPropID;
if (!(propTool is null) && propTool.m_mode == PropTool.Mode.Single && Cursor.visible && propID > 1) {
scale = props[propID].m_scale + scaleStep;
props[propID].m_scale = scale > maxScale ? maxScale : scale;
} else if ((MoveItTool.ToolState == MoveItTool.ToolStates.Default) &&
UIToolOptionPanel.instance.isVisible && Action.selection.Count > 0) {
foreach (Instance instance in Action.selection) {
if (instance is MoveableProp && !instance.id.IsEmpty) {
propID = instance.id.GetProp32();
if (propID > 0) {
scale = props[propID].m_scale + scaleStep;
props[propID].m_scale = scale > maxScale ? maxScale : scale;
EPropManager.UpdateProp(propID);
}
}
}
}
}
public static void DecrementPropSize() {
float scale;
EPropInstance[] props = EPropManager.m_props.m_buffer;
PropTool propTool = ToolsModifierControl.GetCurrentTool<PropTool>();
uint propID = m_currentPropID;
if (!(propTool is null) && propTool.m_mode == PropTool.Mode.Single && Cursor.visible && propID > 1) {
scale = props[propID].m_scale - scaleStep;
props[propID].m_scale = scale < minScale ? minScale : scale;
} else if ((MoveItTool.ToolState == MoveItTool.ToolStates.Default) &&
UIToolOptionPanel.instance.isVisible && Action.selection.Count > 0) {
foreach (Instance instance in Action.selection) {
if (instance is MoveableProp && !instance.id.IsEmpty) {
propID = instance.id.GetProp32();
if (propID > 0) {
scale = props[propID].m_scale - scaleStep;
props[propID].m_scale = scale < minScale ? minScale : scale;
EPropManager.UpdateProp(propID);
}
}
}
}
}
}
}