From e676e1b2449f8da4f1618ab91ee1e11b5d284b9b Mon Sep 17 00:00:00 2001 From: ryantanrk Date: Mon, 3 Jun 2024 14:20:10 +0800 Subject: [PATCH] add steam gift behavior --- Behaviours/MyHeartPhysicsProp.cs | 2 +- Behaviours/SteamGiftPhysicsProp.cs | 40 ++++++++++++++++++++++++------ README.md | 6 ++--- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Behaviours/MyHeartPhysicsProp.cs b/Behaviours/MyHeartPhysicsProp.cs index 6b2cd93..deb5ef1 100644 --- a/Behaviours/MyHeartPhysicsProp.cs +++ b/Behaviours/MyHeartPhysicsProp.cs @@ -19,7 +19,7 @@ public override void ItemActivate(bool used, bool buttonDown = true) _lastTriggeredTime = Time.time; AssetBundle? bundle = DingusThings.Bundle; string itemName = "My Heart"; - if (bundle == null) + if (bundle == null) { DingusThings.Logger.LogError($"{itemName}: Sound failed to play."); return; diff --git a/Behaviours/SteamGiftPhysicsProp.cs b/Behaviours/SteamGiftPhysicsProp.cs index 9598afb..16ac167 100644 --- a/Behaviours/SteamGiftPhysicsProp.cs +++ b/Behaviours/SteamGiftPhysicsProp.cs @@ -1,26 +1,50 @@ -using UnityEngine; +using Unity.Netcode; +using UnityEngine; namespace DingusThings.Behaviours { internal class SteamGiftPhysicsProp : PhysicsProp { + private void ChangeTooltip() + { + if (base.IsOwner) + { + HUDManager.Instance.ChangeControlTip(2, scrapValue <= 0 ? "ALREADY REDEEMED" : "Redeem : [ LMB ]"); + } + } + public override void ItemActivate(bool used, bool buttonDown = true) { + if (scrapValue <= 0) return; + base.ItemActivate(used, buttonDown); if (buttonDown) { AssetBundle? bundle = DingusThings.Bundle; string itemName = "Steam Gift Card"; - if (bundle == null) + + // find a terminal + Terminal terminal = FindFirstObjectByType(); + if (terminal != null) { - DingusThings.Logger.LogError($"{itemName}: Sound failed to play."); - return; - } + // add scrap value to terminal + terminal.groupCredits = terminal.groupCredits + scrapValue; + + // set scrap value to 0 + SetScrapValue(0); + ChangeTooltip(); - AudioClip audioClip = bundle.LoadAsset("Assets/DingusThings/Sounds/steam_achievement.ogg"); - AudioSource audioSource = GetComponent(); - audioSource.PlayOneShot(audioClip, 1F); + if (bundle == null) + { + DingusThings.Logger.LogError($"{itemName}: Sound failed to play."); + return; + } + + AudioClip audioClip = bundle.LoadAsset("Assets/DingusThings/Sounds/steam_achievement.ogg"); + AudioSource audioSource = GetComponent(); + audioSource.PlayOneShot(audioClip, 1F); + } } } } diff --git a/README.md b/README.md index 7a142f5..90bb93c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # DingusThings -Yet another Lethal Company scrap pack +Yet another Lethal Company custom scrap pack -**This scrap pack currently has:** +**This scrap pack includes:** @@ -28,7 +28,7 @@ Yet another Lethal Company scrap pack Steam Gift Card
- Models made by me, sounds and material by Valve + Model made by me, sounds and images by Valve