-
Notifications
You must be signed in to change notification settings - Fork 1
/
FlashlightMod.cs
122 lines (115 loc) · 4.42 KB
/
FlashlightMod.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
using TheForest.Items.World;
using TheForest.Utils;
using UnityEngine;
namespace PlayerUpgradePoints
{
class FlashlightMod : BatteryBasedLight
{
public override void SetIntensity(float intensity)
{
if (UpgradePointsMod.instance.specialUpgrades[37].bought)
{
_mainLight.intensity = intensity*2;
}
else
{
_mainLight.intensity = intensity;
}
float num = intensity / 2f;
if (intensity < 0.3f)
{
num = intensity / 3f;
}
if (num > 0.5f)
{
num = 0.5f;
}
if (UpgradePointsMod.instance.specialUpgrades[37].bought)
{
num *= 3;
}
if ((bool)_fillLight)
{
_fillLight.intensity = num;
}
}
protected override void Update()
{
if (!BoltNetwork.isRunning || (BoltNetwork.isRunning && (bool)base.entity && base.entity.isAttached && base.entity.isOwner))
{
if (UpgradePointsMod.instance.specialUpgrades[37].bought)
{
LocalPlayer.Stats.BatteryCharge -= _batterieCostPerSecond * Time.deltaTime/4;
}
else
{
LocalPlayer.Stats.BatteryCharge -= _batterieCostPerSecond * Time.deltaTime;
}
if (LocalPlayer.Stats.BatteryCharge > 50f)
{
SetIntensity(_highBatteryIntensity);
}
else if (LocalPlayer.Stats.BatteryCharge < 20f)
{
if (LocalPlayer.Stats.BatteryCharge < 10f)
{
if (LocalPlayer.Stats.BatteryCharge < 5f)
{
if (LocalPlayer.Stats.BatteryCharge < 3f && Time.time > _animCoolDown && !_skipNoBatteryRoutine)
{
LocalPlayer.Animator.SetBool("noBattery", true);
_animCoolDown = Time.time + (float)Random.Range(30, 60);
base.Invoke("resetBatteryBool", 1.5f);
}
if (LocalPlayer.Stats.BatteryCharge <= 0f)
{
LocalPlayer.Stats.BatteryCharge = 0f;
if (_skipNoBatteryRoutine)
{
SetEnabled(false);
}
else
{
TorchLowerLightEvenMore();
if (!_doingStash)
{
base.StartCoroutine("stashNoBatteryRoutine");
}
_doingStash = true;
}
}
else
{
SetEnabled(true);
}
}
else
{
TorchLowerLightMore();
SetEnabled(true);
}
}
else
{
TorchLowerLight();
SetEnabled(true);
}
}
if (BoltNetwork.isRunning)
{
if (UpgradePointsMod.instance.specialUpgrades[37].bought)
{
base.state.BatteryTorchIntensity = _mainLight.intensity*2;
}
else
{
base.state.BatteryTorchIntensity = _mainLight.intensity;
}
base.state.BatteryTorchEnabled = _mainLight.enabled;
base.state.BatteryTorchColor = _mainLight.color;
}
}
TheForestQualitySettings.UserSettings.ApplyQualitySetting(_mainLight, LightShadows.Hard);
}
}
}