Skip to content

Commit

Permalink
feat: add cooldown to heart ItemActivate
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanrk committed Jun 2, 2024
1 parent 2a88870 commit 34a214e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Behaviours/MyHeartPhysicsProp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ namespace DingusThings.Behaviours
{
internal class MyHeartPhysicsProp : PhysicsProp
{
private float cooldown = 1.1f;

float _lastTriggeredTime;

public override void ItemActivate(bool used, bool buttonDown = true)
{
// if still under cooldown do not activate
if (Time.time - _lastTriggeredTime < cooldown) return;

base.ItemActivate(used, buttonDown);
if (buttonDown)
{
_lastTriggeredTime = Time.time;
AssetBundle? bundle = DingusThings.Bundle;
string itemName = "My Heart";
if (bundle == null)
Expand Down
1 change: 1 addition & 0 deletions DingusThings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private void Awake()

int iRarity = 30;
Item myHeartItem = Bundle.LoadAsset<Item>("Assets/DingusThings/Items/MyHeart.asset");
myHeartItem.toolTips = ["What she said : [ LMB ]"];
// add custom behavior
MyHeartPhysicsProp myHeartProp = myHeartItem.spawnPrefab.AddComponent<MyHeartPhysicsProp>();
myHeartProp.grabbable = true;
Expand Down

0 comments on commit 34a214e

Please sign in to comment.