-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathParkitectModManager.cs
332 lines (289 loc) · 6.78 KB
/
ParkitectModManager.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Linq;
public class ParkitectModManager : MonoBehaviour
{
[SerializeField]
public Mod mod = new Mod();
[SerializeField]
public List<ParkitectObject> ParkitectObjects = new List<ParkitectObject>();
public ParkitectObject asset = null;
// Use this for initialization
public void ValidateSelected()
{
if (!ParkitectObjects.Contains(asset))
{
asset = null;
}
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
[Serializable]
public class Mod
{
public string name = "New Parkitect Mod";
public string discription = "New Parkitect Mod";
}
[Serializable]
public class ParkitectObject
{
//Basic
public enum ObjType
{
none,
_,
deco,
wall,
trashbin,
seating,
lamp,
fence,
FlatRide,
Shop,
PathStyle,
CoasterCar
}
public GameObject gameObject;
public string inGameName;
public ObjType type = ObjType.none;
public float price;
//Recolorable
public bool recolorable;
public Color color1 = new Color(0.95f, 0, 0);
public Color color2 = new Color(0.32f, 1, 0);
public Color color3 = new Color(0.110f, 0.059f, 1f);
public Color color4 = new Color(1, 0, 1);
public enum Shaders
{
Diffuse,
Specular,
None
}
public Shaders Shader;
//Deco
public bool snapCenter = true;
public bool snap;
public bool grid;
public float heightDelta;
public string category;
public float gridSubdivision = 1;
//Flat-Rides
public float Excitement;
public float Intensity;
public float Nausea;
public float XSize = 1;
public float ZSize = 1;
public Vector3 closedAngleRetraints;
public List<Waypoint> waypoints = new List<Waypoint>();
//--Animation
public RideAnimation Animation = new RideAnimation();
private Phase phase;
//Boundingbox
public List<BoundingBox> BoundingBoxes = new List<BoundingBox>();
//Shop
[SerializeField]
public Shop shop = new Shop();
//Path
public enum PathType { Normal, Queue, Employee }
public PathType pathType;
public Texture2D PathTexture;
//Coaster Car
public string CoasterName = "Steel Coaster";
public GameObject frontCar;
}
[Serializable]
[ExecuteInEditMode]
public class RideAnimation
{
[SerializeField]
public List<motor> motors = new List<motor>();
[SerializeField]
public List<Phase> phases = new List<Phase>();
[SerializeField]
public Phase currentPhase;
int phaseNum;
[SerializeField]
public bool animating;
public void Animate()
{
foreach (motor m in motors)
{
m.Enter();
}
if (phases.Count <= 0)
{
animating = false;
foreach (motor m in motors)
{
m.Reset();
}
foreach (MultipleRotations R in motors.OfType<MultipleRotations>().ToList())
{
R.Reset();
}
return;
}
foreach (motor m in motors)
{
m.Enter();
}
animating = true;
phaseNum = 0;
currentPhase = phases[phaseNum];
currentPhase.running = true;
currentPhase.Enter();
currentPhase.Run();
}
void NextPhase()
{
currentPhase.Exit();
currentPhase.running = false;
phaseNum++;
if (phases.Count > phaseNum)
{
currentPhase = phases[phaseNum];
currentPhase.running = true;
currentPhase.Enter();
currentPhase.Run();
return;
}
animating = false;
foreach (motor m in motors.OfType<Rotator>().ToList())
{
m.Enter();
}
foreach (Rotator m in motors.OfType<Rotator>().ToList())
{
m.axis.localRotation = m.originalRotationValue;
}
foreach (RotateBetween m in motors.OfType<RotateBetween>().ToList())
{
m.axis.localRotation = m.originalRotationValue;
}
foreach (Mover m in motors.OfType<Mover>().ToList())
{
m.axis.localPosition = m.originalRotationValue;
}
currentPhase = null;
}
public void Run()
{
if (currentPhase != null)
{
currentPhase.Run();
if (!currentPhase.running)
{
NextPhase();
}
}
}
}
[ExecuteInEditMode]
[Serializable]
public class Phase
{
[SerializeField]
public List<RideAnimationEvent> Events = new List<RideAnimationEvent>();
public bool running = false;
bool done = false;
public void Enter()
{
foreach (RideAnimationEvent RAE in Events)
{
RAE.Enter();
}
}
public Phase ShallowCopy()
{
return (Phase)this.MemberwiseClone();
}
public void Run()
{
foreach (RideAnimationEvent RAE in Events)
{
RAE.Run();
}
done = true;
foreach (RideAnimationEvent RAE in Events)
{
if (!RAE.done)
{
running = true;
done = false;
break;
}
}
if (done)
{
running = false;
}
}
public void Exit()
{
foreach (RideAnimationEvent RAE in Events)
{
RAE.Exit();
}
}
}
[ExecuteInEditMode]
[Serializable]
public class RideAnimationEvent : ScriptableObject
{
public bool done = false;
public bool showSettings;
public bool isPlaying;
public Color ColorIdentifier;
public virtual string EventName { set; get; }
public virtual void DrawGUI()
{
}
public virtual void Enter()
{
isPlaying = true;
}
public virtual void Run()
{
}
public virtual void Exit()
{
isPlaying = false;
done = false;
}
}
[Serializable]
public class motor : ScriptableObject
{
public bool showSettings;
public string Identifier = "";
public Color ColorIdentifier;
public virtual string EventName { set; get; }
public void Awake()
{
ColorIdentifier = new Color(UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f));
}
public virtual void DrawGUI()
{
#if UNITY_EDITOR
ColorIdentifier = EditorGUILayout.ColorField("Color ", ColorIdentifier);
#endif
}
public virtual void Enter()
{
}
public virtual void Reset()
{
}
}