gaslight gatekeep girlboss :)
This commit is contained in:
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Valheim Dev",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"cwd": "C:/Program Files (x86)/Steam/steamapps/common/Valheim_dev",
|
||||
"program": "C:/Program Files (x86)/Steam/steamapps/common/Valheim_dev/valheim.exe",
|
||||
"console": "integratedTerminal",
|
||||
"args": [
|
||||
"-console"
|
||||
],
|
||||
"preLaunchTask": "build debug"
|
||||
},
|
||||
{
|
||||
"name": "Valheim Dev2",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"cwd": "C:/Program Files (x86)/Steam/steamapps/common/Valheim_dev2",
|
||||
"program": "C:/Program Files (x86)/Steam/steamapps/common/Valheim_dev2/valheim.exe",
|
||||
"console": "integratedTerminal",
|
||||
"args": [
|
||||
"-console"
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build debug",
|
||||
"command": "msbuild",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"${workspaceFolder}/GaslightArrin.sln",
|
||||
"/t:GaslightArrin",
|
||||
"/p:Configuration=Debug",
|
||||
"/p:Platform=\"Any CPU\""
|
||||
],
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "build release",
|
||||
"command": "msbuild",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"${workspaceFolder}/GaslightArrin.sln",
|
||||
"/t:GaslightArrin",
|
||||
"/p:Configuration=Release",
|
||||
"/p:Platform=\"Any CPU\""
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ExecutePrebuild>false</ExecutePrebuild>
|
||||
<ExecutePrebuild>True</ExecutePrebuild>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
+3
-2
@@ -1,9 +1,9 @@
|
||||
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33213.308
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GaslightArrin", "JotunnModStub\GaslightArrin.csproj", "{DEAF4438-8089-40ED-8175-398E1261D45B}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GaslightArrin", "GaslightArrin\GaslightArrin.csproj", "{DEAF4438-8089-40ED-8175-398E1261D45B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -23,3 +23,4 @@ Global
|
||||
SolutionGuid = {04FA40AF-91D5-4CE8-92ED-7530C8DF0D5E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using BepInEx;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EasyStackPlugin
|
||||
{
|
||||
[BepInPlugin(PluginGUID, PluginName, PluginVersion)]
|
||||
[BepInDependency(Jotunn.Main.ModGuid)]
|
||||
//[NetworkCompatibility(CompatibilityLevel.EveryoneMustHaveMod, VersionStrictness.Minor)]
|
||||
internal class EasyStackPlugin : BaseUnityPlugin
|
||||
{
|
||||
public const string PluginGUID = "com.ecaj.easystack";
|
||||
public const string PluginName = "EasyStack";
|
||||
public const string PluginVersion = "1.3.1";
|
||||
|
||||
private const string ArrinName = "arrin";
|
||||
private const string JaceName = "jace";
|
||||
private const float ReopenChance = 1f;
|
||||
private const float OpeningSoundChance = 1/20f;
|
||||
private const float OtherPlayerDistance = 10f;
|
||||
|
||||
private Harmony mHarmony;
|
||||
private static List<Door> DoorQueue = new List<Door>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mHarmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), PluginGUID);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
mHarmony?.UnpatchSelf();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Player.m_localPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < DoorQueue.Count; i++) {
|
||||
var door = DoorQueue[i];
|
||||
if (door == null) {
|
||||
DoorQueue.RemoveAt(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
var diff = door.transform.position - Player.m_localPlayer.transform.position;
|
||||
if (Player.m_localPlayer.GetPlayerName().ToLower() == ArrinName) {
|
||||
// Check if visible to camera
|
||||
var colliders = door.GetComponent<Piece>()?.GetAllColliders();
|
||||
var planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
|
||||
var visible = colliders != null && colliders.Any(collider => GeometryUtility.TestPlanesAABB(planes, collider.bounds));
|
||||
if (!visible && diff.magnitude > 6f) {
|
||||
// Only reopen if still closed
|
||||
if (door.m_nview.GetZDO().GetInt("state") == 0) {
|
||||
// Make sure no other players are nearby
|
||||
bool otherPlayersNearby = false;
|
||||
foreach (var player in Player.GetAllPlayers()) {
|
||||
if (player == null || player == Player.m_localPlayer) {
|
||||
continue;
|
||||
}
|
||||
if (Vector3.Distance(player.transform.position, door.transform.position) < OtherPlayerDistance) {
|
||||
otherPlayersNearby = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!otherPlayersNearby) {
|
||||
// Random 1/10 chance to actually play open sound
|
||||
var playCloseSound = Random.Range(0f, 1f) < OpeningSoundChance;
|
||||
var effects = door.m_openEffects;
|
||||
if (!playCloseSound) {
|
||||
door.m_openEffects = new EffectList();
|
||||
}
|
||||
// Open door :)
|
||||
var facing = Vector3.Dot(door.transform.forward, Player.m_localPlayer.transform.forward);
|
||||
door.m_nview.InvokeRPC("UseDoor", facing);
|
||||
if (!playCloseSound) {
|
||||
door.m_openEffects = effects;
|
||||
}
|
||||
}
|
||||
}
|
||||
DoorQueue.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
} else if (Player.m_localPlayer.GetPlayerName().ToLower() == JaceName) {
|
||||
// Check if facing away
|
||||
var facing = Vector3.Dot(diff.normalized, Player.m_localPlayer.transform.forward);
|
||||
if (facing < 0 && diff.magnitude > 2f) {
|
||||
// Close door
|
||||
if (door.m_nview.GetZDO().GetInt("state") != 0) {
|
||||
door.m_nview.InvokeRPC("UseDoor", 0);
|
||||
}
|
||||
DoorQueue.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Door), nameof(Door.Interact))]
|
||||
private class Door_Interact_Patch
|
||||
{
|
||||
private static void Postfix(Door __instance, Humanoid character, bool hold, bool alt, bool __result)
|
||||
{
|
||||
if (!__result) {
|
||||
return;
|
||||
}
|
||||
|
||||
var player = character as Player;
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool closed = __instance.m_nview.GetZDO().GetInt("state") == 0;
|
||||
// If Arrin
|
||||
if (player.GetPlayerName().ToLower() == ArrinName) {
|
||||
// If door is being closed
|
||||
if (closed) {
|
||||
// Random chance for door to reopen after closing
|
||||
if (Random.Range(0f, 1f) < ReopenChance) {
|
||||
if (!DoorQueue.Contains(__instance)) {
|
||||
DoorQueue.Add(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If Jace
|
||||
} else if (player.GetPlayerName().ToLower() == JaceName) {
|
||||
// If door is being opened, make sure it auto-closes
|
||||
if (!closed) {
|
||||
DoorQueue.Add(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\JotunnLib.2.10.0\build\JotunnLib.props" Condition="Exists('..\packages\JotunnLib.2.10.0\build\JotunnLib.props')" />
|
||||
<PropertyGroup>
|
||||
@@ -7,8 +7,8 @@
|
||||
<ProjectGuid>{DEAF4438-8089-40ED-8175-398E1261D45B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JotunnModStub</RootNamespace>
|
||||
<AssemblyName>JotunnModStub</AssemblyName>
|
||||
<RootNamespace>EasyStack</RootNamespace>
|
||||
<AssemblyName>EasyStack</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
@@ -115,4 +115,4 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\JotunnLib.2.10.0\build\JotunnLib.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\JotunnLib.2.10.0\build\JotunnLib.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -33,3 +33,4 @@ using System.Runtime.InteropServices;
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.3.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.1.0")]
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// JotunnModStub
|
||||
// a Valheim mod skeleton using Jötunn
|
||||
//
|
||||
// File: JotunnModStub.cs
|
||||
// Project: JotunnModStub
|
||||
|
||||
using BepInEx;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
|
||||
namespace EasyStackPlugin
|
||||
{
|
||||
[BepInPlugin(PluginGUID, PluginName, PluginVersion)]
|
||||
[BepInDependency(Jotunn.Main.ModGuid)]
|
||||
//[NetworkCompatibility(CompatibilityLevel.EveryoneMustHaveMod, VersionStrictness.Minor)]
|
||||
internal class EasyStackPlugin : BaseUnityPlugin
|
||||
{
|
||||
public const string PluginGUID = "com.itmae.easystack";
|
||||
public const string PluginName = "EasyStack";
|
||||
public const string PluginVersion = "1.3.1";
|
||||
|
||||
// Use this class to add your own localization to the game
|
||||
// https://valheim-modding.github.io/Jotunn/tutorials/localization.html
|
||||
public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Jotunn comes with its own Logger class to provide a consistent Log style for all mods using it
|
||||
Jotunn.Logger.LogInfo("ModStub has landed");
|
||||
|
||||
// To learn more about Jotunn's features, go to
|
||||
// https://valheim-modding.github.io/Jotunn/tutorials/overview.html
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user