Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SpiderRemover : CommandArgumentConverter<Spider, ChatCommandContext
public override Spider Parse(ChatCommandContext ctx, string input)
{
var spiders = SpiderUtil.ClosestSpiders(ctx.Event.SenderCharacterEntity, Radius);
var em = Core.Server.EntityManager;
var em = Core.EntityManager;

foreach (var spider in spiders)
{
Expand Down
11 changes: 4 additions & 7 deletions GiveDrop.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using BepInEx.Logging;
using ProjectM.Scripting;
using Stunlock.Core;
using Unity.Entities;
using VAMP;
using VAMP.Utilities;
using Exception = System.Exception;

namespace SpiderKiller;
Expand All @@ -15,13 +14,11 @@ public static bool AddItemToInventory(Entity recipient, PrefabGUID guid, int amo
{
try
{
ServerGameManager serverGameManager =
Core.Server.GetExistingSystemManaged<ServerScriptMapper>()._ServerGameManager;
var inventoryResponse = serverGameManager.TryAddInventoryItem(recipient, guid, amount);
var inventoryResponse = ItemUtil.AddItemToInventory(recipient, guid, amount, out var _);
#if DEBUG
_log.LogMessage($"AddItemToInventory: {inventoryResponse.Success}");
_log.LogMessage($"AddItemToInventory: {inventoryResponse}");
#endif
return inventoryResponse.Success;
return inventoryResponse;
}
catch (Exception e)
{
Expand Down
60 changes: 30 additions & 30 deletions Patches/DateTimeSystem_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using UnityEngine;
using Stunlock.Core;
using VAMP;
using VAMP.Data;

namespace SpiderKiller.Patches;

Expand All @@ -38,29 +39,29 @@ public class DateTimeSystem_Patch

private static readonly HashSet<PrefabGUID> BlockedPrefabGUIDs = new HashSet<PrefabGUID>
{
new PrefabGUID(-764515001), // CHAR_Spider_Baneling
new PrefabGUID(-1004061470), // CHAR_Spider_Baneling_Summon
new PrefabGUID(342127250), // CHAR_Spider_Broodmother
new PrefabGUID(-581295882), // CHAR_Spider_Forest
new PrefabGUID(574276383), // CHAR_Spider_Forestling
new PrefabGUID(2136899683), // CHAR_Spider_Melee
new PrefabGUID(-725251219), // CHAR_Spider_Melee_GateBoss_Summon
new PrefabGUID(2119230788), // CHAR_Spider_Melee_Summon
new PrefabGUID(-548489519), // CHAR_Spider_Queen_VBlood
new PrefabGUID(-943858353), // CHAR_Spider_Queen_VBlood_GateBoss_Major
new PrefabGUID(2103131615), // CHAR_Spider_Range
new PrefabGUID(1974733695), // CHAR_Spider_Range_Summon
new PrefabGUID(1078424589), // CHAR_Spider_Spiderling
new PrefabGUID(1767714956), // CHAR_Spider_Spiderling_VerminNest
new PrefabGUID(-18289884) // CHAR_Spiderling_Summon
Prefabs.CHAR_Spider_Baneling,
Prefabs.CHAR_Spider_Baneling_Summon,
Prefabs.CHAR_Spider_Broodmother,
Prefabs.CHAR_Spider_Forest,
Prefabs.CHAR_Spider_Forestling,
Prefabs.CHAR_Spider_Melee,
Prefabs.CHAR_Spider_Melee_GateBoss_Summon,
Prefabs.CHAR_Spider_Melee_Summon,
Prefabs.CHAR_Spider_Queen_VBlood,
Prefabs.CHAR_Spider_Queen_VBlood_GateBoss_Major,
Prefabs.CHAR_Spider_Range,
Prefabs.CHAR_Spider_Range_Summon,
Prefabs.CHAR_Spider_Spiderling,
Prefabs.CHAR_Spider_Spiderling_VerminNest,
Prefabs.CHAR_Spiderling_Summon
};

private static readonly HashSet<PrefabGUID> ReplacementPrefabGUIDs = new HashSet<PrefabGUID>
{
new PrefabGUID(-744966291), // CHAR_Cursed_Mosquito
new PrefabGUID(-218175217), // CHAR_Cursed_Wolf
new PrefabGUID(-2072914343), // CHAR_Critter_Rat
new PrefabGUID(-559819989) // CHAR_Cursed_Bear_Standard
Prefabs.CHAR_Cursed_Mosquito,
Prefabs.CHAR_Cursed_Wolf,
Prefabs.CHAR_Critter_Rat,
Prefabs.CHAR_Cursed_Bear_Standard
};

public static void Prefix(DateTimeSystem __instance)
Expand All @@ -75,17 +76,17 @@ public static void Prefix(DateTimeSystem __instance)
}

_noUpdateBefore = DateTime.Now.AddSeconds(Settings.CULL_WAIT_TIME.Value);
if (!Plugin.HasInitialized) return;
EntityManager em = Core.Server.EntityManager;
EntityQuery querySpawnRegion = Core.Server.EntityManager.CreateEntityQuery(new EntityQueryDesc
if (!Core.hasInitialized) return;
EntityManager em = Core.EntityManager;
EntityQuery querySpawnRegion = em.CreateEntityQuery(new EntityQueryDesc
{
All = new[] { ComponentType.ReadOnly<SpawnRegion>() },
Any = new[] { ComponentType.ReadOnly<SpawnRegionSpawnSlotEntry>(), ComponentType.ReadOnly<SpawnGroupBuffer>() },
Options = EntityQueryOptions.IncludeDisabled
});
foreach (Entity spawnRegion in querySpawnRegion.ToEntityArray(Allocator.Temp))
{
if (Core.Server.EntityManager.TryGetBuffer<SpawnRegionSpawnSlotEntry>(spawnRegion, out var spawnSlotEntries))
if (em.TryGetBuffer<SpawnRegionSpawnSlotEntry>(spawnRegion, out var spawnSlotEntries))
{
for (int i = 0; i < spawnSlotEntries.Length; i++)
{
Expand All @@ -95,23 +96,23 @@ public static void Prefix(DateTimeSystem __instance)
Plugin.LogInstance.LogMessage($"[spawnSlotEntries] current {entry.Entity.GetPrefabGuidNameString()} has spawned?: {entry.HasSpawned}");
#endif
var prefabGUID = ReplacementPrefabGUIDs.ElementAt(UnityEngine.Random.Range(0, ReplacementPrefabGUIDs.Count));
var prefabEntity = EntityQueryHelper.QueryEntityWithPrefabGUID(Core.Server.EntityManager, prefabGUID.GuidHash);
var prefabEntity = EntityQueryHelper.QueryEntityWithPrefabGUID(em, prefabGUID.GuidHash);

if (prefabEntity == Entity.Null) continue;
#if DEBUG
Plugin.LogInstance.LogMessage($"[spawnSlotEntries] with {prefabGUID.GetNamefromPrefabGuid()}");
#endif
entry.Entity = Core.Server.EntityManager.Instantiate(prefabEntity);
entry.Entity = em.Instantiate(prefabEntity);
spawnSlotEntries[i] = entry;
}
}

if (!Core.Server.EntityManager.TryGetBuffer<SpawnGroupBuffer>(spawnRegion, out var spawnGroupBuffer))
if (!em.TryGetBuffer<SpawnGroupBuffer>(spawnRegion, out var spawnGroupBuffer))
continue;

foreach (var group in spawnGroupBuffer)
{
if (!Core.Server.EntityManager.TryGetBuffer<SpawnGroup_SpawnTableBuffer>(group.SpawnGroup,
if (!em.TryGetBuffer<SpawnGroup_SpawnTableBuffer>(group.SpawnGroup,
out var spawnTableBuffer)) continue;

for (int i = 0; i < spawnTableBuffer.Length; i++)
Expand Down Expand Up @@ -143,8 +144,7 @@ public static void Prefix(DateTimeSystem __instance)
var player = em.GetEntityByEntityIndex(playerIndex);
if (Settings.CULL_QUEEN.Value)
{
var dayNightCycle = Core.Server.GetExistingSystemManaged<ServerScriptMapper>()._ServerGameManager
.DayNightCycle;
var dayNightCycle = Core.ServerGameManager.DayNightCycle;
var now = dayNightCycle.GameDateTimeNow;
double dayDurationInSeconds = dayNightCycle.DayDurationInSeconds;
double secondsPerInGameHour = dayDurationInSeconds / 24;
Expand Down Expand Up @@ -226,7 +226,7 @@ private static void KillSpider(Entity spider, Entity player)
DoNotDestroy = false
};
var deathReason = new DeathReason();
DeathUtilities.Kill(Core.Server.EntityManager, spider, dead, deathEvent, deathReason);
DeathUtilities.Kill(Core.EntityManager, spider, dead, deathEvent, deathReason);
// Destroys the entity without giving any drops
// DestroyUtility.CreateDestroyEvent(Core.Server.EntityManager, spider, DestroyReason.Default, DestroyDebugReason.None);
}
Expand Down
17 changes: 0 additions & 17 deletions Patches/InitializationPatches.cs

This file was deleted.

11 changes: 4 additions & 7 deletions Patches/InitializePlayer_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@ public static void OnUserConnected_Patch(ServerBootstrapSystem __instance, NetCo
try
{
//RespawnAi(Entity fromCharacter, RespawnAiDebugEvent clientEvent);

var userIndex = Core.Server.GetExistingSystemManaged<ServerBootstrapSystem>()
._NetEndPointToApprovedUserIndex[netConnectionId];
var serverClient = Core.Server.GetExistingSystemManaged<ServerBootstrapSystem>()
._ApprovedUsersLookup[userIndex];
var userIndex = __instance._NetEndPointToApprovedUserIndex[netConnectionId];
var serverClient = __instance._ApprovedUsersLookup[userIndex];
var userEntity = serverClient.UserEntity;
var user = Core.Server.EntityManager.GetComponentData<User>(userEntity);
var user = Core.EntityManager.GetComponentData<User>(userEntity);
var player = user.LocalCharacter.GetEntityOnServer();

if (Settings.ENABLE_UNGORA_UNLOCK.Value) // unlock Ungora progression if enabled
{
UnlockVBlood debugEvent = new UnlockVBlood();
debugEvent.VBlood = new PrefabGUID(-548489519);
UnlockProgressionDebugEvent evt = new UnlockProgressionDebugEvent();
DebugEventsSystem debugEventsSystem = Core.Server.GetExistingSystemManaged<DebugEventsSystem>();
DebugEventsSystem debugEventsSystem = Core.SystemService.DebugEventsSystem;

evt.PrefabGuid = new PrefabGUID(574648849);
debugEventsSystem.UnlockProgression(
Expand Down
3 changes: 2 additions & 1 deletion Patches/SpawnUnit_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using HarmonyLib;
using ProjectM;
using Unity.Entities;
using VAMP;

namespace SpiderKiller.Patches;

Expand Down Expand Up @@ -38,7 +39,7 @@ static bool Prefix(Entity stationEntity, PrefabGUID prefabGuid, float3 spawnBase
// Check if the PrefabGUID is in the blocked list
return !BlockedPrefabGUIDs.Contains(prefabGuid);
#if DEBUG
String name = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>()._PrefabLookupMap.GetName(prefabGuid);
string name = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>()._PrefabLookupMap.GetName(prefabGuid);
Plugin.LogInstance.LogMessage($"Blocked spawning of PrefabGUID: {prefabGuid} name: {name}");
#endif
}
Expand Down
11 changes: 5 additions & 6 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
namespace SpiderKiller;

[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInDependency("VAMP")]
[BepInDependency("gg.deca.VampireCommandFramework", BepInDependency.DependencyFlags.SoftDependency)]
public class Plugin : BasePlugin
{
public static Harmony Harmony;

public static bool HasInitialized = false;
public static ManualLogSource LogInstance { get; private set; }

public override void Load()
Expand All @@ -26,17 +26,18 @@ public override void Load()
if (Application.productName == "VRising")
{
Log.LogWarning("This plugin is a server-only plugin!");
return;
}

VAMP.Events.OnCoreLoaded += Initialize;
}

public static void Initialize()
private static void Initialize()
{
if (Application.productName == "VRising")
{
return;
}
if (HasInitialized)
return;

LogInstance.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");

Expand All @@ -49,8 +50,6 @@ public static void Initialize()
{
LogInstance.LogInfo("This mod has extra admin commands. Install VampireCommandFramework to use them.");
}

HasInitialized = true;
}

public override bool Unload()
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Updated to 1.1 version of V Rising.

## Installation (Manual)

* Install [BepInEx](https://github.com/CrimsonMods/BepInEx/releases)
* Install [BepInEx](https://thunderstore.io/c/v-rising/p/BepInEx/BepInExPack_V_Rising/)
* Install [VAMP](https://thunderstore.io/c/v-rising/p/skytech6/VAMP/)
* (optional) Install [VampireCommandFramework](https://github.com/decaprime/VampireCommandFramework/releases) into (VRising server folder)/BepInEx/plugins
* (optional) Install [VampireCommandFramework](https://thunderstore.io/c/v-rising/p/deca/VampireCommandFramework/) into (VRising server folder)/BepInEx/plugins
* (optional) Install [ServerLaunchFix](https://v-rising.thunderstore.io/package/Mythic/ServerLaunchFix/) into (VRising server folder)/BepInEx/plugins
* Extract _**KillSpiders.dll**_ into (VRising server folder)/BepInEx/plugins

Expand Down
6 changes: 3 additions & 3 deletions SpiderKiller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" IncludeAssets="compile" />
<PackageReference Include="BepInEx.Core" Version="6.0.0-be.735" IncludeAssets="compile" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.1.0" />
<PackageReference Include="VRising.Unhollowed.Client" Version="1.1.7.9169101" />
<PackageReference Include="VRising.VAMP" Version="0.3.4" />
<PackageReference Include="VRising.VampireCommandFramework" Version="0.10.0" />
<PackageReference Include="VRising.UnhollowedX.Client" Version="1.0.8" />
<PackageReference Include="VRising.VAMP" Version="1.0.0" />
<PackageReference Include="VRising.VampireCommandFramework" Version="0.10.2" />
</ItemGroup>
<!-- <Target Name="PostBuild" AfterTargets="PostBuildEvent">-->
<!-- <Exec Command='copy "C:\Users\bryan\Documents\modding projects\.net\Projects\VRisingKillSpiders\bin\Debug\net6.0\SpiderKiller.dll" "C:\Program Files (x86)\Steam\steamapps\common\VRisingDedicatedServer\BepInEx\plugins"' />-->
Expand Down