-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirty.cs
More file actions
168 lines (134 loc) · 5.96 KB
/
Dirty.cs
File metadata and controls
168 lines (134 loc) · 5.96 KB
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
using HutongGames.PlayMaker;
using MSCLoader;
using System.Collections;
using UnityEngine;
namespace Expanded_Clothes
{
internal class Dirty : MonoBehaviour
{
private const float MaxDirtness = 100f;
private const float SecondsToDirtyFromClothes = 30f * 60f;
private const float SecondsToDirtyClothesFromPlayer = 30f * 60f;
public float JacketDirty;
public float CoverallDirty;
public FsmFloat playerDirtness;
public FsmInt clothingType;
private FsmFloat playerSweat;
private PlayMakerFSM bodyTempFsm;
private FsmFloat bodyheatAdd;
private GameObject PLAYER;
public string infoJacket;
public string infoCoverall;
private void Start()
{
var hud = GameObject.Find("GUI/HUD").transform.GetChild(8);
hud.gameObject.SetActive(true);
hud.localPosition = new Vector3(-11.5f, 6f, 0f);
var jail = GameObject.Find("GUI/HUD").transform.GetChild(12);
jail.localPosition = new Vector3(-11.5f, 5.6f, 0f);
PLAYER = GameObject.Find("PLAYER");
playerDirtness = FsmVariables.GlobalVariables.GetFsmFloat("PlayerDirtiness");
playerSweat = FsmVariables.GlobalVariables.GetFsmFloat("PlayerSweat");
var clothingFsm = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera/FPSCamera/Clothing").GetComponent<PlayMakerFSM>();
clothingType = clothingFsm != null ? clothingFsm.FsmVariables.GetFsmInt("Type") : null;
bodyTempFsm = GameObject.Find("PLAYER/BodyTemp").GetComponent<PlayMakerFSM>();
bodyheatAdd = bodyTempFsm.FsmVariables.GetFsmFloat("BodyheatAdd");
if (SaveLoad.ValueExists(Expanded_Clothes.Instance, "EC_jacket_dirty"))
{
JacketDirty = SaveLoad.ReadValue<float>(Expanded_Clothes.Instance, $"EC_jacket_dirty");
CoverallDirty = SaveLoad.ReadValue<float>(Expanded_Clothes.Instance, $"EC_coverall_dirty");
}
StartCoroutine(DirtyPlayerTick());
var Gifu = GameObject.Find("GIFU(750/450psi)");
var GifuPoopTrigger = new GameObject("GifuPoopTrigger");
BoxCollider col = GifuPoopTrigger.AddComponent<BoxCollider>();
col.isTrigger = true;
GifuPoopTrigger.transform.SetParent(Gifu.transform.Find("LOD"));
GifuPoopTrigger.transform.localPosition = new Vector3(-0.09006908f, 0.6110867f, -5.554031f);
GifuPoopTrigger.transform.localEulerAngles = new Vector3(0f, 90f, 0f);
GifuPoopTrigger.transform.localScale = new Vector3(2f, 1.5f, 1.6f);
GifuPoopTrigger.AddComponent<GifuPoop>();
}
private void Update()
{
if (JacketDirty <= 50)
infoJacket = "clean";
if (JacketDirty >= 50 && JacketDirty <= 70)
infoJacket = "slightly stained";
if (JacketDirty >= 70)
infoJacket = "extremely dirty";
if (CoverallDirty <= 50)
infoCoverall = "clean";
if (CoverallDirty >= 50 && CoverallDirty <= 70)
infoCoverall = "slightly stained";
if (CoverallDirty >= 70)
infoCoverall = "extremely dirty";
int type = clothingType.Value;
if (type == 1)
ApplyDirtyExchange(ref JacketDirty);
else if (type == 2)
ApplyDirtyExchange(ref CoverallDirty);
ApplySweatToPlayerDirtiness();
ApplyHeat(type);
}
private void ApplyDirtyExchange(ref float clothesDirty)
{
float delta = Time.deltaTime;
float p = Mathf.Clamp(playerDirtness.Value, 0f, MaxDirtness);
float c = Mathf.Clamp(clothesDirty, 0f, MaxDirtness);
float sweat = playerSweat != null ? playerSweat.Value : 0f;
float clothesFromPlayerMult = (sweat > 20f) ? 10f : 1f;
if (p > c)
{
float rate = (MaxDirtness / SecondsToDirtyClothesFromPlayer) * clothesFromPlayerMult;
c = Mathf.MoveTowards(c, p, rate * delta);
}
if (c > p)
{
float rate = MaxDirtness / SecondsToDirtyFromClothes;
p = Mathf.MoveTowards(p, c, rate * delta);
playerDirtness.Value = p;
}
clothesDirty = c;
}
private void ApplyHeat(int type)
{
float baseHeat = type == 1 ? 0.5f : type == 2 ? 1.8f : 0.025f;
float dirt = type == 1 ? JacketDirty : type == 2 ? CoverallDirty : 0f;
dirt = Mathf.Clamp(dirt, 0f, 100f);
float heatMult = Mathf.Lerp(1f, 0.4f, dirt / 100f);
bodyheatAdd.Value = baseHeat * heatMult;
/*if (type == 1 || type == 2)
{
if (dirt >= 70f)
{
float t = Mathf.InverseLerp(70f, 100f, dirt);
float sweat = Mathf.Lerp(0f, 30f, t);
playerSweat.Value = sweat;
}
}*/ //TODO: reworking sweat system
}
private void ApplySweatToPlayerDirtiness()
{
float sweat = playerSweat.Value;
if (sweat > 20f)
{
float addPerSec = Mathf.Lerp(0.02f, 0.08f, Mathf.InverseLerp(20f, 100f, sweat));
playerDirtness.Value = Mathf.Clamp(playerDirtness.Value + addPerSec * Time.deltaTime, 0f, MaxDirtness);
}
}
private IEnumerator DirtyPlayerTick()
{
var wait = new WaitForSeconds(180f);
while (true)
{
yield return wait;
if (playerDirtness.Value >= 70f)
{
string variant = (Random.value < 0.5f) ? "shit02" : "shit03";
MasterAudio.PlaySound3DAndForget("Shit", PLAYER.transform, false, 1f, null, 0f, variant);
}
}
}
}
}