Skip to content

Commit

Permalink
add steam gift behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanrk committed Jun 3, 2024
1 parent 64955f3 commit e676e1b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Behaviours/MyHeartPhysicsProp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 32 additions & 8 deletions Behaviours/SteamGiftPhysicsProp.cs
Original file line number Diff line number Diff line change
@@ -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<Terminal>();
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<AudioClip>("Assets/DingusThings/Sounds/steam_achievement.ogg");
AudioSource audioSource = GetComponent<AudioSource>();
audioSource.PlayOneShot(audioClip, 1F);
if (bundle == null)
{
DingusThings.Logger.LogError($"{itemName}: Sound failed to play.");
return;
}

AudioClip audioClip = bundle.LoadAsset<AudioClip>("Assets/DingusThings/Sounds/steam_achievement.ogg");
AudioSource audioSource = GetComponent<AudioSource>();
audioSource.PlayOneShot(audioClip, 1F);
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:**

<table>
<tr>
Expand All @@ -28,7 +28,7 @@ Yet another Lethal Company scrap pack
Steam Gift Card
</td>
<td>
Models made by me, sounds and material by Valve
Model made by me, sounds and images by Valve
</td>
</tr>
</table>
Expand Down

0 comments on commit e676e1b

Please sign in to comment.