Skip to content

Commit

Permalink
Cleanup stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Jun 12, 2024
1 parent ef58734 commit e0916ef
Show file tree
Hide file tree
Showing 25 changed files with 90 additions and 91 deletions.
97 changes: 48 additions & 49 deletions Source/Assets/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,87 +8,86 @@ internal static class AssetManager
{
private static AssetBundle assetBundle;

public static GameObject aLiteralCube;
public static GameObject interactable;
public static GameObject keyboard;
public static GameObject settingsPanel;
public static GameObject volumeManager;
public static GameObject spectatorLight;
public static GameObject spectatorGhost;
public static GameObject enemyPrefab;

public static Material splashMaterial;
public static Material defaultRayMat;
public static Material alwaysOnTopMat;
#if DEBUG
public static GameObject Cube;
#endif
public static GameObject Interactable;
public static GameObject Keyboard;
public static GameObject SettingsPanel;
public static GameObject VolumeManager;
public static GameObject SpectatorLight;
public static GameObject SpectatorGhost;
public static GameObject EnemyPrefab;

public static Material SplashMaterial;
public static Material DefaultRayMat;
public static Material AlwaysOnTopMat;

public static InputActionAsset VRActions;
public static InputActionAsset TrackingActions;
public static InputActionAsset NullActions;

public static RemappableControls RemappableControls;

public static RuntimeAnimatorController localVrMetarig;
public static RuntimeAnimatorController remoteVrMetarig;
public static RuntimeAnimatorController LocalVrMetarig;
public static RuntimeAnimatorController RemoteVrMetarig;

public static Sprite githubImage;
public static Sprite kofiImage;
public static Sprite discordImage;
public static Sprite warningImage;
public static Sprite settingsImage;
public static Sprite GithubImage;
public static Sprite KofiImage;
public static Sprite DiscordImage;
public static Sprite WarningImage;
public static Sprite SettingsImage;

public static AudioClip doorLocked;
public static AudioClip DoorLocked;

public static bool LoadAssets()
{
assetBundle = AssetBundle.LoadFromMemory(Properties.Resources.lethalcompanyvr);

if (assetBundle == null)
{
Logger.LogError("Failed to load asset bundle!");
return false;
}

aLiteralCube = assetBundle.LoadAsset<GameObject>("ALiteralCube");
interactable = assetBundle.LoadAsset<GameObject>("VRInteractable");
keyboard = assetBundle.LoadAsset<GameObject>("NonNativeKeyboard");
settingsPanel = assetBundle.LoadAsset<GameObject>("Panel");
volumeManager = assetBundle.LoadAsset<GameObject>("Volume Manager");
enemyPrefab = assetBundle.LoadAsset<GameObject>("Flowerman");
spectatorLight = assetBundle.LoadAsset<GameObject>("Spectator Light");
spectatorGhost = assetBundle.LoadAsset<GameObject>("SpectatorGhost");
Cube = assetBundle.LoadAsset<GameObject>("ALiteralCube");
Interactable = assetBundle.LoadAsset<GameObject>("VRInteractable");
Keyboard = assetBundle.LoadAsset<GameObject>("NonNativeKeyboard");
SettingsPanel = assetBundle.LoadAsset<GameObject>("Panel");
VolumeManager = assetBundle.LoadAsset<GameObject>("Volume Manager");
EnemyPrefab = assetBundle.LoadAsset<GameObject>("Flowerman");
SpectatorLight = assetBundle.LoadAsset<GameObject>("Spectator Light");
SpectatorGhost = assetBundle.LoadAsset<GameObject>("SpectatorGhost");

VRActions = assetBundle.LoadAsset<InputActionAsset>("VRActions");
TrackingActions = assetBundle.LoadAsset<InputActionAsset>("TrackingActions");
NullActions = assetBundle.LoadAsset<InputActionAsset>("NullPlayerActions");

RemappableControls = assetBundle.LoadAsset<GameObject>("Remappable Controls").GetComponent<RemappableControls>();

splashMaterial = assetBundle.LoadAsset<Material>("Splash");
defaultRayMat = assetBundle.LoadAsset<Material>("Default Ray");
alwaysOnTopMat = assetBundle.LoadAsset<Material>("Always On Top");
RemappableControls =
assetBundle.LoadAsset<GameObject>("Remappable Controls").GetComponent<RemappableControls>();

SplashMaterial = assetBundle.LoadAsset<Material>("Splash");
DefaultRayMat = assetBundle.LoadAsset<Material>("Default Ray");
AlwaysOnTopMat = assetBundle.LoadAsset<Material>("Always On Top");

githubImage = assetBundle.LoadAsset<Sprite>("Github");
kofiImage = assetBundle.LoadAsset<Sprite>("Ko-Fi");
discordImage = assetBundle.LoadAsset<Sprite>("Discord");
warningImage = assetBundle.LoadAsset<Sprite>("Warning");
settingsImage = assetBundle.LoadAsset<Sprite>("lcsettings-icon-2");
GithubImage = assetBundle.LoadAsset<Sprite>("Github");
KofiImage = assetBundle.LoadAsset<Sprite>("Ko-Fi");
DiscordImage = assetBundle.LoadAsset<Sprite>("Discord");
WarningImage = assetBundle.LoadAsset<Sprite>("Warning");
SettingsImage = assetBundle.LoadAsset<Sprite>("lcsettings-icon-2");

localVrMetarig = assetBundle.LoadAsset<RuntimeAnimatorController>("metarig");
remoteVrMetarig = assetBundle.LoadAsset<RuntimeAnimatorController>("metarigOtherPlayers");
LocalVrMetarig = assetBundle.LoadAsset<RuntimeAnimatorController>("metarig");
RemoteVrMetarig = assetBundle.LoadAsset<RuntimeAnimatorController>("metarigOtherPlayers");

doorLocked = assetBundle.LoadAsset<AudioClip>("doorlocked");
DoorLocked = assetBundle.LoadAsset<AudioClip>("doorlocked");

if (RemappableControls == null || RemappableControls.controls == null)
{
Logger.LogError("Unity failed to deserialize some assets. Are you missing the FixPluginTypesSerialization mod?");
Logger.LogError(
"Unity failed to deserialize some assets. Are you missing the FixPluginTypesSerialization mod?");
return false;
}

return true;
}

public static InputActionAsset Input(string name)
{
return assetBundle.LoadAsset<InputActionAsset>(name);
}
}
4 changes: 2 additions & 2 deletions Source/Items/VRKnife.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public class VRKnife : VRItem<KnifeItem>
if (!IsLocal)
return;

interactionTarget = Instantiate(AssetManager.interactable, VRSession.Instance.MainCamera.transform);
interactionTarget = Instantiate(AssetManager.Interactable, VRSession.Instance.MainCamera.transform);
interactionTarget.transform.localPosition = new Vector3(0, 0, 0.5f);
interactionTarget.transform.localScale = Vector3.one * 0.3f;
interactionTarget.AddComponent<KnifeInteractor>();
interactionTarget.AddComponent<Rigidbody>().isKinematic = true;

knifeCollider = Instantiate(AssetManager.interactable, transform);
knifeCollider = Instantiate(AssetManager.Interactable, transform);
knifeCollider.transform.localPosition = new Vector3(0, 0, 7.25f);
knifeCollider.transform.localScale = new Vector3(1.2f, 3, 12.9f);

Expand Down
2 changes: 1 addition & 1 deletion Source/Networking/VRNetPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void Awake()
BuildVRRig();

// Create spectating player
playerGhost = Instantiate(AssetManager.spectatorGhost, VRSession.Instance.transform);
playerGhost = Instantiate(AssetManager.SpectatorGhost, VRSession.Instance.transform);
playerGhost.name = $"Spectating Player: {PlayerController.playerUsername}";

usernameBillboard = playerGhost.GetComponentInChildren<Canvas>().transform;
Expand Down
6 changes: 3 additions & 3 deletions Source/Patches/PlayerControllerPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static void UpdatePrefix(PlayerControllerB __instance)
return;

if (__instance.isPlayerControlled)
__instance.playerBodyAnimator.runtimeAnimatorController = AssetManager.localVrMetarig;
__instance.playerBodyAnimator.runtimeAnimatorController = AssetManager.LocalVrMetarig;
}

/// <summary>
Expand Down Expand Up @@ -365,9 +365,9 @@ private static void UpdatePrefix(PlayerControllerB __instance)
{
var networkPlayer = __instance.GetComponent<VRNetPlayer>();
if (networkPlayer != null)
__instance.playerBodyAnimator.runtimeAnimatorController = AssetManager.remoteVrMetarig;
__instance.playerBodyAnimator.runtimeAnimatorController = AssetManager.RemoteVrMetarig;
// Used to restore the original metarig if a VR player leaves and a non-vr players join in their place
else if (__instance.playerBodyAnimator.runtimeAnimatorController == AssetManager.remoteVrMetarig)
else if (__instance.playerBodyAnimator.runtimeAnimatorController == AssetManager.RemoteVrMetarig)
__instance.playerBodyAnimator.runtimeAnimatorController = __instance.playersManager.otherClientsAnimatorController;
}
}
Expand Down
14 changes: 7 additions & 7 deletions Source/Patches/UIPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private static void InitMenuScene(Canvas canvas)
/// </summary>
private static void InitializeKeyboard(Canvas canvas)
{
var keyboard = Object.Instantiate(AssetManager.keyboard).GetComponent<NonNativeKeyboard>();
var keyboard = Object.Instantiate(AssetManager.Keyboard).GetComponent<NonNativeKeyboard>();

keyboard.transform.SetParent(canvas.transform, false);
keyboard.transform.localPosition = new Vector3(0, -470, -40);
Expand Down Expand Up @@ -183,9 +183,9 @@ private static void InjectIntroScreen()
var kofiImage = kofiButtonObject.AddComponent<Image>();
var discordImage = discordButtonObject.AddComponent<Image>();

githubImage.sprite = AssetManager.githubImage;
kofiImage.sprite = AssetManager.kofiImage;
discordImage.sprite = AssetManager.discordImage;
githubImage.sprite = AssetManager.GithubImage;
kofiImage.sprite = AssetManager.KofiImage;
discordImage.sprite = AssetManager.DiscordImage;

var githubButton = githubButtonObject.AddComponent<Button>();
var kofiButton = kofiButtonObject.AddComponent<Button>();
Expand Down Expand Up @@ -308,15 +308,15 @@ private static void InjectSettingsScreen()
var settingsButton = settingsObject.AddComponent<Button>();
var settingsButtonColors = settingsButton.colors;

settingsImage.sprite = AssetManager.settingsImage;
settingsImage.sprite = AssetManager.SettingsImage;
settingsButtonColors.highlightedColor = new Color(0.8f, 0.8f, 0.8f);
settingsButtonColors.pressedColor = new Color(0.7f, 0.7f, 0.7f);
settingsButtonColors.fadeDuration = 0.1f;

settingsButton.colors = settingsButtonColors;

// Insert settings panel
var settingsPanel = Object.Instantiate(AssetManager.settingsPanel, container.transform);
var settingsPanel = Object.Instantiate(AssetManager.SettingsPanel, container.transform);

settingsPanel.transform.localPosition = Vector3.zero;
settingsPanel.transform.localEulerAngles = Vector3.zero;
Expand Down Expand Up @@ -360,7 +360,7 @@ private static void InjectDebugScreen()
picture.transform.SetSiblingIndex(0);
picture.transform.localScale = Vector3.one * 0.4f;
picture.transform.localPosition = new Vector3(196, 59, 1);
picture.sprite = AssetManager.warningImage;
picture.sprite = AssetManager.WarningImage;

modDebugPanel.SetActive(!VRSession.InVR || Plugin.Config.IntroScreenSeen.Value);

Expand Down
4 changes: 2 additions & 2 deletions Source/Physics/Interactions/BreakerBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static void OnCreateBreakerBox(BreakerBox __instance)
return;

var door = __instance.transform.Find("Mesh/PowerBoxDoor");
var doorInteractableObject = Object.Instantiate(AssetManager.interactable, door);
var doorInteractableObject = Object.Instantiate(AssetManager.Interactable, door);
doorInteractableObject.transform.localPosition = new Vector3(-0.8f, 0, -0.7f);
doorInteractableObject.transform.localScale = new Vector3(1.5f, 0.2f, 2.1f);

Expand All @@ -83,7 +83,7 @@ private static void OnCreateBreakerBox(BreakerBox __instance)
for (var i = 1; i <= 5; i++)
{
var @switch = __instance.transform.Find($"Mesh/BreakerSwitch{i}");
var switchInteractableObject = Object.Instantiate(AssetManager.interactable, @switch);
var switchInteractableObject = Object.Instantiate(AssetManager.Interactable, @switch);
switchInteractableObject.transform.localEulerAngles = new Vector3(0, 45, 0);
switchInteractableObject.transform.localScale = Vector3.one * 0.1f;

Expand Down
2 changes: 1 addition & 1 deletion Source/Physics/Interactions/ChargeStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static ChargeStation Create()
var charger = FindObjectOfType<ItemCharger>();
charger.name = "ChargingStationTrigger";

var interactable = Instantiate(AssetManager.interactable, charger.gameObject.transform);
var interactable = Instantiate(AssetManager.Interactable, charger.gameObject.transform);
var station = interactable.AddComponent<ChargeStation>();

interactable.transform.localScale = Vector3.one * 0.7f;
Expand Down
2 changes: 1 addition & 1 deletion Source/Physics/Interactions/CompanyBell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static void OnItemDeskActivate()
var bellObject = GameObject.Find("BellDinger/Trigger");
bellObject.name = "CompanyBellTrigger";

var bellInteractableObject = Object.Instantiate(AssetManager.interactable, bellObject.transform);
var bellInteractableObject = Object.Instantiate(AssetManager.Interactable, bellObject.transform);

bellInteractableObject.transform.localPosition = new Vector3(-0.135f, -0.06f, 0);
bellInteractableObject.transform.localScale = Vector3.one * 0.5f;
Expand Down
6 changes: 3 additions & 3 deletions Source/Physics/Interactions/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public bool OnButtonPress(VRInteractor interactor)
lockpicker.PlaceOnDoor(door, lockpicker.placeOnLockPicker1);
}
else
door.doorLockSFX.PlayOneShot(AssetManager.doorLocked);
door.doorLockSFX.PlayOneShot(AssetManager.DoorLocked);

return true;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ private static void InitializeDoorInteractor(DoorLock __instance)
// Make sure default ray based interaction no longer works for this door
__instance.gameObject.name = "DoorInteractable";

var interactableObject = Object.Instantiate(AssetManager.interactable, __instance.transform);
var interactableObject = Object.Instantiate(AssetManager.Interactable, __instance.transform);
interactableObject.transform.localPosition = position;
interactableObject.transform.localEulerAngles = rotation;
interactableObject.transform.localScale = scale * (__instance.isDoorOpened ? 4f : 1f);
Expand All @@ -221,7 +221,7 @@ private static void InitializeLockPickerInteractor(LockPicker __instance)
// Do **not** yet disable the ray based interactor. Only disable when placed on door!
__instance.gameObject.name = "LockPicker";

var interactableObject = Object.Instantiate(AssetManager.interactable, __instance.transform);
var interactableObject = Object.Instantiate(AssetManager.Interactable, __instance.transform);
interactableObject.transform.localScale = new Vector3(2f, 4f, 2.5f);
interactableObject.AddComponent<LockPickerInteractable>();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Physics/Interactions/Face.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static Face Create()
if (Plugin.Config.DisableFaceInteractions.Value)
return null;

var interactableObject = Instantiate(AssetManager.interactable, VRSession.Instance.MainCamera.transform);
var interactableObject = Instantiate(AssetManager.Interactable, VRSession.Instance.MainCamera.transform);
interactableObject.transform.localPosition = new Vector3(0, -0.1f, 0.1f);
interactableObject.transform.localScale = new Vector3(0.225f, 0.2f, 0.225f);

Expand Down
2 changes: 1 addition & 1 deletion Source/Physics/Interactions/HangarLever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static void OnInteractTriggerStart(InteractTrigger __instance)

__instance.gameObject.name = "LeverSwitchInteractable";

var interactableObject = Object.Instantiate(AssetManager.interactable, __instance.transform);
var interactableObject = Object.Instantiate(AssetManager.Interactable, __instance.transform);

interactableObject.transform.localPosition = new Vector3(0.0044f, -0.0513f, 0.2529f);
interactableObject.transform.localScale = new Vector3(0.0553f, 0.1696f, 0.0342f);
Expand Down
4 changes: 2 additions & 2 deletions Source/Physics/Interactions/MonitorButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static void Create()
cameraSwitchButtonObject.transform.localPosition = new Vector3(-1.3456f, -1.1547f, -1.1147f);
cameraSwitchButtonObject.transform.localEulerAngles = new Vector3(0, 82, 270);

var onOffInteractableObject = Instantiate(AssetManager.interactable, cameraOnButtonObject.transform.GetChild(0));
var switchInteractableObject = Instantiate(AssetManager.interactable, cameraSwitchButtonObject.transform.GetChild(0));
var onOffInteractableObject = Instantiate(AssetManager.Interactable, cameraOnButtonObject.transform.GetChild(0));
var switchInteractableObject = Instantiate(AssetManager.Interactable, cameraSwitchButtonObject.transform.GetChild(0));

onOffInteractableObject.transform.localEulerAngles = switchInteractableObject.transform.localEulerAngles = new Vector3(0, 10, 0);
onOffInteractableObject.transform.localScale = switchInteractableObject.transform.localScale = new Vector3(0.5f, 1, 0.5f);
Expand Down
2 changes: 1 addition & 1 deletion Source/Physics/Interactions/Muffler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static Muffler Create()
if (Plugin.Config.DisableMuffleInteraction.Value)
return null;

var interactableObject = Instantiate(AssetManager.interactable, VRSession.Instance.MainCamera.transform);
var interactableObject = Instantiate(AssetManager.Interactable, VRSession.Instance.MainCamera.transform);
interactableObject.transform.localPosition = new Vector3(0, -0.1f, 0.1f);
interactableObject.transform.localScale = new Vector3(0.1f, 0.05f, 0.1f);

Expand Down
4 changes: 2 additions & 2 deletions Source/Physics/Interactions/ShipDoorButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static void Create()
var openDoorButtonObject = GameObject.Find("HangarDoorButtonPanel/StartButton");
var closeDoorButtonObject = GameObject.Find("HangarDoorButtonPanel/StopButton");

var openDoorInteractableObject = Instantiate(AssetManager.interactable, openDoorButtonObject.transform.GetChild(0));
var closeDoorInteractableObject = Instantiate(AssetManager.interactable, closeDoorButtonObject.transform.GetChild(0));
var openDoorInteractableObject = Instantiate(AssetManager.Interactable, openDoorButtonObject.transform.GetChild(0));
var closeDoorInteractableObject = Instantiate(AssetManager.Interactable, closeDoorButtonObject.transform.GetChild(0));

openDoorInteractableObject.transform.localPosition = new Vector3(-0.04f, 0, -0.11f);
openDoorInteractableObject.transform.localScale = new Vector3(0.3f, 1, 0.5f);
Expand Down
2 changes: 1 addition & 1 deletion Source/Physics/Interactions/ShipHorn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static void OnShipHornInitialized(ShipAlarmCord __instance)

__instance.gameObject.name = "ShipHornPullInteractable";

var interactableObject = Object.Instantiate(AssetManager.interactable, __instance.transform);
var interactableObject = Object.Instantiate(AssetManager.Interactable, __instance.transform);

interactableObject.transform.localPosition = new Vector3(0, 0, -0.28f);
interactableObject.transform.localScale = Vector3.one * 0.33f;
Expand Down
2 changes: 1 addition & 1 deletion Source/Physics/Interactions/ShipLever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static ShipLever Create()
if (VRSession.InVR)
{
var leverObject = startMatch.leverAnimatorObject.gameObject;
var interactable = Instantiate(AssetManager.interactable, leverObject.transform);
var interactable = Instantiate(AssetManager.Interactable, leverObject.transform);

interactable.transform.localPosition = new Vector3(0.2327f, 0.0404f, 11.6164f);
interactable.transform.localScale = new Vector3(1, 1, 4);
Expand Down
Loading

0 comments on commit e0916ef

Please sign in to comment.