-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPQSCityEx.cs
84 lines (65 loc) · 2.09 KB
/
PQSCityEx.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
/* LICENSE
* This source code is copyrighted.
* All rights reserved.
* Copyright © Ryan Irecki 2013
*/
using UnityEngine;
namespace Kerbtown
{
internal class PQSCityEx : PQSCity
{
public StaticObject StaticObjectRef;
void OnEnable()
{
// Repeat this action once every second, rather than every frame in OnUpdateFinished().
InvokeRepeating("CalcVisibilityActivity", 0, 1);
}
void OnDisable()
{
CancelInvoke("CalcVisibilityActivity");
}
public void CalcVisibilityActivity()
{
// TODO Decide on implementation and remove this code.
if (StaticObjectRef == null || StaticObjectRef.ModuleList == null) return;
if (sphere == null || sphere.target == null) return;
foreach (var mod in StaticObjectRef.ModuleList)
{
if (mod.KeepAlive) continue;
mod.ModuleComponent.enabled =
(Vector3.Distance(sphere.target.transform.position, transform.position) <
StaticObjectRef.VisRange);
//print(mod.ModuleComponent.name + ", " + mod.ModuleComponent.enabled);
}
}
public new void OnSphereActive()
{
if (!modEnabled) return;
base.OnSphereActive();
}
public new void OnSphereInactive()
{
if (!modEnabled)
return;
// Do not disable if the player has decided this is a permanent object.
if (StaticObjectRef != null && StaticObjectRef.IsSpaceActive) return;
base.OnSphereInactive();
}
public new void OnSphereReset()
{
if (!modEnabled) return;
base.OnSphereReset();
}
public new void OnSphereStart()
{
if (!modEnabled) return;
base.OnSphereStart();
}
public new void OnUpdateFinished()
{
if (!modEnabled)
return;
base.OnUpdateFinished();
}
}
}