0.1.2 | Added: BagsForEveryone

This commit is contained in:
2026-03-07 02:04:22 +01:00
parent 42a6ff8928
commit 28dd03e9eb
4 changed files with 61 additions and 1 deletions

View File

@@ -8,3 +8,8 @@
# v0.1.1 | Throw passport anywhere patch
- Added PassportPatch.cs and registerd it as GlobalPatch in Plugin.cs
# v0.1.2 | Bags for Everyone
- Added BagsForEveryoneModule and BagsForEveryonePatch
- BagsForEveryonePatch adds a postfix to SingleItemSpawner.TrySpawnItems that checks if the spawner is the first one in the biome, and if so, it spawns extra bags based on the player count.

View File

@@ -8,7 +8,7 @@
<!-- This is the display name of your mod. Example: BepInEx Template -->
<AssemblyTitle>JordanMod</AssemblyTitle>
<!-- This is the version number of your mod. -->
<Version>0.1.1</Version>
<Version>0.1.2</Version>
</PropertyGroup>
<PropertyGroup>

View File

@@ -0,0 +1,14 @@
using System;
namespace JordanMod.Modules.BagsForEveryone;
[Module(Enabled = true)]
class BagsForEveryoneModule : Module
{
public override string ModuleName => "Bags for Everyone Module";
public override Type[] GetPatches()
{
return [typeof(BagsForEveryonePatch)];
}
}

View File

@@ -0,0 +1,41 @@
using AncestralMod;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
namespace JordanMod.Modules.BagsForEveryone;
public class BagsForEveryonePatch
{
[HarmonyPatch(typeof(SingleItemSpawner), "TrySpawnItems")]
[HarmonyPostfix]
static void Postfix(SingleItemSpawner __instance)
{
ForEachPlayer(__instance);
}
private static void ForEachPlayer(SingleItemSpawner spawner)
{
if (!Helper.IsMasterClient()) return;
bool isBackpackSPawner = spawner.transform.name == "Backpack_Spawner";
if (!isBackpackSPawner) return;
bool isFirstSpawner = spawner.transform.IsChildOf(GameObject.Find("Biome_1").transform);
if (!isFirstSpawner) return;
int playerCount = PhotonNetwork.PlayerList.Length - 1;
if (playerCount <= 0) return;
for (int i = 1; i <= playerCount; i++)
{
Vector3 spawnPosition = spawner.transform.position + Vector3.up * 0.1f + Vector3.right * i;
PhotonView component = PhotonNetwork.InstantiateItemRoom(spawner.prefab.name, spawnPosition, spawner.transform.rotation).GetComponent<PhotonView>();
if (spawner.isKinematic)
{
component.GetComponent<PhotonView>().RPC("SetKinematicRPC", RpcTarget.AllBuffered, true, component.transform.position, component.transform.rotation);
}
}
}
}