mirror of
https://github.com/TheJordanDev/PEAK-JordanMod.git
synced 2026-10-17 08:05:25 +02:00
0.1.2 | Added: BagsForEveryone
This commit is contained in:
@@ -8,3 +8,8 @@
|
|||||||
# v0.1.1 | Throw passport anywhere patch
|
# v0.1.1 | Throw passport anywhere patch
|
||||||
|
|
||||||
- Added PassportPatch.cs and registerd it as GlobalPatch in Plugin.cs
|
- 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.
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<!-- This is the display name of your mod. Example: BepInEx Template -->
|
<!-- This is the display name of your mod. Example: BepInEx Template -->
|
||||||
<AssemblyTitle>JordanMod</AssemblyTitle>
|
<AssemblyTitle>JordanMod</AssemblyTitle>
|
||||||
<!-- This is the version number of your mod. -->
|
<!-- This is the version number of your mod. -->
|
||||||
<Version>0.1.1</Version>
|
<Version>0.1.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -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)];
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/JordanMod/patches/BagsForEveryonePatch.cs
Normal file
41
src/JordanMod/patches/BagsForEveryonePatch.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user