-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add nerditem and nerdphysicsprop, and bump version
- Loading branch information
Showing
5 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using UnityEngine; | ||
|
||
namespace DingusThings.Behaviours | ||
{ | ||
internal class NerdPhysicsProp : PhysicsProp | ||
{ | ||
private readonly 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 = "Nerd"; | ||
if (bundle == null) | ||
{ | ||
DingusThings.Logger.LogError($"{itemName}: Sound failed to play."); | ||
return; | ||
} | ||
AudioClip audioClip = bundle.LoadAsset<AudioClip>("Assets/DingusThings/Sounds/akchually.ogg"); | ||
AudioSource audioSource = GetComponent<AudioSource>(); | ||
audioSource.PlayOneShot(audioClip, 1F); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using DingusThings.Behaviours; | ||
using LethalLib.Modules; | ||
using UnityEngine; | ||
|
||
namespace DingusThings.CustomScriptableObject | ||
{ | ||
internal class NerdItem | ||
{ | ||
public static void Register() | ||
{ | ||
string itemName = "Nerd"; | ||
AssetBundle? bundle = DingusThings.Bundle; | ||
if (bundle == null) | ||
{ | ||
DingusThings.Logger.LogError(itemName + " failed to load."); | ||
return; | ||
} | ||
/// Nerd | ||
int rarity = 40; | ||
Item item = bundle.LoadAsset<Item>("Assets/DingusThings/Items/Nerd.asset"); | ||
item.toolTips = ["Ackchually: [LMB]"]; | ||
NerdPhysicsProp nerdPhysicsProp = item.spawnPrefab.AddComponent<NerdPhysicsProp>(); | ||
nerdPhysicsProp.grabbable = true; | ||
nerdPhysicsProp.grabbableToEnemies = true; | ||
nerdPhysicsProp.isInFactory = true; | ||
nerdPhysicsProp.itemProperties = item; | ||
|
||
// register prefab | ||
NetworkPrefabs.RegisterNetworkPrefab(item.spawnPrefab); | ||
Utilities.FixMixerGroups(item.spawnPrefab); | ||
Items.RegisterScrap(item, rarity, Levels.LevelTypes.All); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters