-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewHands.cs
More file actions
109 lines (92 loc) · 3.75 KB
/
NewHands.cs
File metadata and controls
109 lines (92 loc) · 3.75 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
using HutongGames.PlayMaker;
using MSCLoader;
using System.IO;
using UnityEngine;
namespace Expanded_Clothes
{
public class NewHands : MonoBehaviour
{
private Texture2D handNormal, handNormalTattoo, Jacket, Coverall, JacketTattoo, CoverallTattoo;
private GameObject handplayer;
private SkinnedMeshRenderer handRenderer;
private FsmBool hasTattoo;
private FsmInt Clothing;
public void Start()
{
var Instance = Expanded_Clothes.Instance;
var clothingFSM = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera/FPSCamera/Clothing")?.GetComponent<PlayMakerFSM>();
Clothing = clothingFSM.FsmVariables.GetFsmInt("Type");
var db = GameObject.Find("PlayerDatabase");
hasTattoo = PlayMakerExtensions.GetPlayMaker(db, "Simulation").FsmVariables.GetFsmBool("Tattoo");
handplayer = GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera/FPSCamera/MiddleFinger/Pivot/hand/hand_rigged");
handRenderer = handplayer.GetComponent<SkinnedMeshRenderer>();
string assetsPath = ModLoader.GetModAssetsFolder(Instance);
AssetBundle ab = LoadAssets.LoadBundle("Expanded_Clothes.Assets.exclothes.unity3d");
if (File.Exists(assetsPath + "/hands/handNormal.png"))
{
handNormal = LoadAssets.LoadTexture(Instance, "hands/handNormal.png");
}
else
{
handNormal = ab.LoadAsset<Texture2D>("handNormal.png");
}
// handTattoo
if (File.Exists(assetsPath + "/hands/handTattoo.png"))
{
handNormalTattoo = LoadAssets.LoadTexture(Instance, "hands/handTattoo.png");
}
else
{
handNormalTattoo = ab.LoadAsset<Texture2D>("handTattoo.png");
}
// Jacket
if (File.Exists(assetsPath + "/hands/Jacket.png"))
{
Jacket = LoadAssets.LoadTexture(Instance, "hands/Jacket.png");
}
else
{
Jacket = ab.LoadAsset<Texture2D>("Jacket.png");
}
// Coverall
if (File.Exists(assetsPath + "/hands/Coverall.png"))
{
Coverall = LoadAssets.LoadTexture(Instance, "hands/Coverall.png");
}
else
{
Coverall = ab.LoadAsset<Texture2D>("Coverall.png");
}
// JacketTattoo
if (File.Exists(assetsPath + "/hands/JacketTattoo.png"))
{
JacketTattoo = LoadAssets.LoadTexture(Instance, "hands/JacketTattoo.png");
}
else
{
JacketTattoo = ab.LoadAsset<Texture2D>("JacketTattoo.png");
}
// CoverallTattoo
if (File.Exists(assetsPath + "/hands/CoverallTattoo.png"))
{
CoverallTattoo = LoadAssets.LoadTexture(Instance, "hands/CoverallTattoo.png");
}
else
{
CoverallTattoo = ab.LoadAsset<Texture2D>("CoverallTattoo.png");
}
ab.Unload(false);
}
private void Update()
{
Texture2D targetTex = null;
int type = Clothing.Value;
bool tattoo = hasTattoo.Value;
if (type == 1) targetTex = tattoo ? JacketTattoo : Jacket;
else if (type == 2) targetTex = tattoo ? CoverallTattoo : Coverall;
else targetTex = tattoo ? handNormalTattoo : handNormal;
if (handRenderer.sharedMaterial.GetTexture("_MainTex") != targetTex)
handRenderer.sharedMaterial.SetTexture("_MainTex", targetTex);
}
}
}