-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAssets.cs
More file actions
236 lines (207 loc) · 11.5 KB
/
Assets.cs
File metadata and controls
236 lines (207 loc) · 11.5 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
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using CardsPlusPlugin.Cards;
using CardsPlusPlugin.Cards.Cyberpunk;
using Photon.Pun;
using UnityEngine;
namespace CardsPlusPlugin
{
internal class Assets
{
public static event Action OnFinishedLoadingAssets;
private static AssetBundle Bundle;
//
// DEBUG ASSETS
//
public static GameObject Arrow;
public static GameObject TestTurret;
//
// CARD ART
//
public static GameObject TurtleArt;
public static GameObject HareArt;
public static GameObject TerminatorArt;
public static GameObject SlowPokeArt;
public static GameObject PhantomArt;
public static GameObject QuickReflexesArt;
public static GameObject LowGravityArt;
public static GameObject SnakeAttackArt;
public static GameObject ExcaliburArt;
public static GameObject HotPotatoArt;
public static GameObject SmokeGrenadeArt;
public static GameObject AdwareArt;
public static GameObject ShortCircuitArt;
public static GameObject HamperArt;
public static GameObject ContagionArt;
public static GameObject BurnoutArt;
// Snake attack
public static GameObject SnakePrefab;
// Excalibur
public static GameObject SwordPrefab;
public static GameObject SwordExplosion;
// Hot potato
public static GameObject FlameArea;
// Smoke Grenade
public static GameObject SmokeObject;
public static GameObject SmokeEffect;
// Adware
public static GameObject AdwarePlayerSelector;
public static GameObject PopupPrefab;
public static GameObject HackedTargetEffect;
public static GameObject[] PopupContents;
public static GameObject AdwareCanvas;
// Cyberpunk
public static TMPro.TMP_FontAsset CyberFont;
public static Material GlitchShaderMaterialHolder;
public static ScreenBlurEffect ScreenBlurEffect;
public static GameObject GlitchedParticleEffect;
public static GameObject ElectricFrame;
public static GameObject QuickhackMenu;
public static GameObject RamMenu;
public static GameObject RamSlot;
public static Dictionary<QuickhackMenuOption.QuickhackType, GameObject> QuickHacks;
public static Dictionary<QuickhackMenuOption.QuickhackType, GameObject> QuickhackSelectors;
public static Dictionary<QuickhackMenuOption.QuickhackType, GameObject> QuickhackSelectionEffects;
static Assets()
{
UnboundLib.Unbound.Instance.StartCoroutine(LoadAssets());
}
public static IEnumerator LoadAssetBundleFromResources(bool doAsync, string bundleName, Assembly resourceAssembly)
{
if (resourceAssembly == null)
{
throw new ArgumentNullException("Parameter resourceAssembly can not be null.");
}
string resourceName = null;
try
{
resourceName = resourceAssembly.GetManifestResourceNames().Single(str => str.EndsWith(bundleName));
}
catch (Exception) { }
if (resourceName == null)
{
CardsPlus.LOGGER.LogError($"AssetBundle {bundleName} not found in assembly manifest");
yield break;
}
AssetBundleCreateRequest ret;
using (var stream = resourceAssembly.GetManifestResourceStream(resourceName))
{
if (doAsync)
{
ret = AssetBundle.LoadFromStreamAsync(stream);
yield return new WaitUntil(() => ret.isDone);
Bundle = ret.assetBundle;
}
else
{
Bundle = AssetBundle.LoadFromStream(stream);
}
}
}
private static IEnumerator LoadAssets()
{
CardsPlus.LOGGER.LogInfo("STARTED LOADING BUNDLE");
yield return LoadAssetBundleFromResources(false, "cardsplusart", typeof(CardsPlus).Assembly);
var debugBundle = Jotunn.Utils.AssetUtils.LoadAssetBundleFromResources("debugassets", typeof(CardsPlus).Assembly);
TestTurret = Bundle.LoadAsset<GameObject>("Test Turret");
Arrow = debugBundle.LoadAsset<GameObject>("Arrow");
CardsPlus.LOGGER.LogInfo("FINISHED LOADING BUNDLE");
TurtleArt = Bundle.LoadAsset<GameObject>("C_TheTurtle");
HareArt = Bundle.LoadAsset<GameObject>("C_TheHare");
TerminatorArt = Bundle.LoadAsset<GameObject>("C_Terminator");
SlowPokeArt = Bundle.LoadAsset<GameObject>("C_SlowPoke");
PhantomArt = Bundle.LoadAsset<GameObject>("C_Phantom");
QuickReflexesArt = Bundle.LoadAsset<GameObject>("C_QuickReflexes");
LowGravityArt = Bundle.LoadAsset<GameObject>("C_LowGravity");
ExcaliburArt = Bundle.LoadAsset<GameObject>("C_Excalibur");
SmokeGrenadeArt = Bundle.LoadAsset<GameObject>("C_SmokeGrenade");
AdwareArt = Bundle.LoadAsset<GameObject>("C_Adware");
SnakeAttackArt = Bundle.LoadAsset<GameObject>("C_SnakeAttack");
HotPotatoArt = Bundle.LoadAsset<GameObject>("C_HotPotato");
ElectricFrame = Bundle.LoadAsset<GameObject>("Short Circuit Frame");
ShortCircuitArt = Bundle.LoadAsset<GameObject>("C_ShortCircuit").AddComponent<CyberCardEffect>().gameObject;
HamperArt = Bundle.LoadAsset<GameObject>("C_Hamper").AddComponent<CyberCardEffect>().gameObject;
ContagionArt = Bundle.LoadAsset<GameObject>("C_Contagion").AddComponent<CyberCardEffect>().gameObject;
BurnoutArt = Bundle.LoadAsset<GameObject>("C_Burnout").AddComponent<CyberCardEffect>().gameObject;
SnakePrefab = Bundle.LoadAsset<GameObject>("Snake").AddComponent<SnakeFollow>().gameObject;
var snakeView = SnakePrefab.gameObject.AddComponent<PhotonView>();
snakeView.Synchronization = ViewSynchronization.UnreliableOnChange;
snakeView.OwnershipTransfer = OwnershipOption.Takeover;
snakeView.observableSearch = PhotonView.ObservableSearch.AutoFindAll;
var snakePhysics = SnakePrefab.gameObject.AddComponent<NetworkPhysicsObject>();
snakePhysics.sendFreq = 2;
snakePhysics.collisionThreshold = float.PositiveInfinity;
snakePhysics.playerColThreshold = float.PositiveInfinity;
snakePhysics.shakeAmount = 0;
snakePhysics.bulletPushMultiplier = 10;
snakePhysics.dmgAmount = 0;
snakePhysics.forceAmount = 0;
// Excalibur
SwordPrefab = Bundle.LoadAsset<GameObject>("Sword").AddComponent<SwordBehaviour>().gameObject;
SwordExplosion = Bundle.LoadAsset<GameObject>("ProtonExplosionYellow");
SwordPrefab.GetComponent<SwordBehaviour>().destroyParticles = SwordExplosion;
// Hot potato
FlameArea = Bundle.LoadAsset<GameObject>("FlameArea").AddComponent<HotPotatoFlame>().gameObject;
// Smoke Grenade
SmokeObject = Bundle.LoadAsset<GameObject>("Smoke Object").AddComponent<PhotonView>().gameObject;
SmokeEffect = Bundle.LoadAsset<GameObject>("Smoke Effect");
// Adware
AdwarePlayerSelector = Bundle.LoadAsset<GameObject>("Player Selector");
PopupPrefab = Bundle.LoadAsset<GameObject>("Popup Window");
HackedTargetEffect = Bundle.LoadAsset<GameObject>("HackedTargetEffect");
PopupContents = new GameObject[]
{
Bundle.LoadAsset<GameObject>("popup-body-1"),
Bundle.LoadAsset<GameObject>("popup-body-2"),
Bundle.LoadAsset<GameObject>("popup-body-3"),
Bundle.LoadAsset<GameObject>("popup-body-4"),
Bundle.LoadAsset<GameObject>("popup-body-5"),
Bundle.LoadAsset<GameObject>("popup-body-6"),
Bundle.LoadAsset<GameObject>("popup-body-7"),
Bundle.LoadAsset<GameObject>("popup-body-8"),
Bundle.LoadAsset<GameObject>("popup-body-9")
};
AdwareCanvas = Bundle.LoadAsset<GameObject>("Adware UI")
.AddComponent<PhotonView>().gameObject
.AddComponent<PhotonMagicInitializer>().gameObject;
// Cyberpunk
ScreenBlurEffect = Bundle.LoadAsset<GameObject>("BlurEffect").GetComponent<ScreenBlurEffect>();
GlitchedParticleEffect = Bundle.LoadAsset<GameObject>("GlitchedEffect");
GlitchShaderMaterialHolder = Bundle.LoadAsset<Material>("GlitchMaterial");
CyberFont = Bundle.LoadAsset<TMPro.TMP_FontAsset>("CyberwayRiders-lg97d");
QuickhackMenu = Bundle.LoadAsset<GameObject>("Quickhack Menu");
QuickHacks = new Dictionary<QuickhackMenuOption.QuickhackType, GameObject>
{
{ QuickhackMenuOption.QuickhackType.CONTAGION, Bundle.LoadAsset<GameObject>("Contagion") },
{ QuickhackMenuOption.QuickhackType.SHORT_CIRCUIT, Bundle.LoadAsset<GameObject>("Short Circuit") },
{ QuickhackMenuOption.QuickhackType.BURNOUT, Bundle.LoadAsset<GameObject>("Burnout") },
{ QuickhackMenuOption.QuickhackType.HAMPER, Bundle.LoadAsset<GameObject>("Hamper") },
{ QuickhackMenuOption.QuickhackType.REBOOT_OPTICS, Bundle.LoadAsset<GameObject>("Reboot Optics") }
};
QuickhackSelectors = new Dictionary<QuickhackMenuOption.QuickhackType, GameObject>
{
{ QuickhackMenuOption.QuickhackType.CONTAGION, Bundle.LoadAsset<GameObject>("ContagionSelector") },
{ QuickhackMenuOption.QuickhackType.SHORT_CIRCUIT, Bundle.LoadAsset<GameObject>("ShortCircuitSelector") },
{ QuickhackMenuOption.QuickhackType.BURNOUT, Bundle.LoadAsset<GameObject>("OverheatSelector") },
{ QuickhackMenuOption.QuickhackType.HAMPER, Bundle.LoadAsset<GameObject>("HamperSelector") },
{ QuickhackMenuOption.QuickhackType.REBOOT_OPTICS, Bundle.LoadAsset<GameObject>("RebootOpticsSelector") }
};
QuickhackSelectionEffects = new Dictionary<QuickhackMenuOption.QuickhackType, GameObject>
{
{ QuickhackMenuOption.QuickhackType.CONTAGION, Bundle.LoadAsset<GameObject>("ContagionExplosion") },
{ QuickhackMenuOption.QuickhackType.SHORT_CIRCUIT, Bundle.LoadAsset<GameObject>("ShortCircuitExplosion") },
{ QuickhackMenuOption.QuickhackType.BURNOUT, Bundle.LoadAsset<GameObject>("OverheatExplosion") },
{ QuickhackMenuOption.QuickhackType.HAMPER, Bundle.LoadAsset<GameObject>("HamperExplosion") },
{ QuickhackMenuOption.QuickhackType.REBOOT_OPTICS, Bundle.LoadAsset<GameObject>("RebootOpticsExplosion") }
};
RamMenu = Bundle.LoadAsset<GameObject>("RAM Menu");
RamSlot = Bundle.LoadAsset<GameObject>("RAM Slot");
OnFinishedLoadingAssets?.Invoke();
}
}
}