Skip to content

Commit

Permalink
feat: add nerditem and nerdphysicsprop, and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanrk committed Oct 2, 2024
1 parent e024104 commit 9aefea8
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
33 changes: 33 additions & 0 deletions Behaviours/NerdPhysicsProp.cs
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);
}
}
}
}
34 changes: 34 additions & 0 deletions CustomScriptableObject/NerdItem.cs
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);
}
}
}
3 changes: 2 additions & 1 deletion DingusThings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void Awake()
return;
}

// load patch
// load patches
Harmony.CreateAndPatchAll(typeof(TerminalPatch));
Harmony.CreateAndPatchAll(typeof(SeedPatch));

Expand All @@ -79,6 +79,7 @@ private void Awake()
LifebuoyBarSoapItem.Register();
InstantNoodlePackItem.Register();
KeyboardItem.Register();
NerdItem.Register();

Logger.LogInfo($"{PluginString} has loaded!");
}
Expand Down
2 changes: 1 addition & 1 deletion DingusThings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyName>milodinosaur.DingusThings</AssemblyName>
<Product>DingusThings</Product>
<!-- Change to whatever version you're currently on. -->
<Version>1.4.5</Version>
<Version>1.5.0</Version>
</PropertyGroup>

<!-- Project Properties -->
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ Yet another Lethal Company custom scrap pack
Steam Gift Card
</td>
<td>
Model made by me, sounds and images by Valve
Model made by me
<br/><br/>
Sounds and images by Valve
</td>
</tr>
<tr>
Expand Down Expand Up @@ -65,6 +67,16 @@ Yet another Lethal Company custom scrap pack
Keyboard sounds by Pinguwow, Mikacchi, LunaIc3, Agamgunz, Kayeo, and me
</td>
</tr>
<tr>
<td>
Nerd
</td>
<td>
Model made by me
<br/><br/>
Voice by Richietxy
</td>
</tr>
</table>

Assets: https://github.com/ryantanrk/DingusThings-Assets
Expand Down

0 comments on commit 9aefea8

Please sign in to comment.