Skip to content

Commit 7fb33bd

Browse files
committed
initial commit
0 parents  commit 7fb33bd

File tree

6 files changed

+157
-0
lines changed

6 files changed

+157
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin/
2+
obj/
3+
4+
.idea/

NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
5+
</packageSources>
6+
</configuration>

OneShot.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32014.148
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneShot", "OneShot\OneShot.csproj", "{D00AD040-E353-4148-9458-C2EFC61FC52E}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{D00AD040-E353-4148-9458-C2EFC61FC52E}.Release|Any CPU.ActiveCfg = Release|Any CPU
14+
{D00AD040-E353-4148-9458-C2EFC61FC52E}.Release|Any CPU.Build.0 = Release|Any CPU
15+
EndGlobalSection
16+
GlobalSection(SolutionProperties) = preSolution
17+
HideSolutionNode = FALSE
18+
EndGlobalSection
19+
GlobalSection(ExtensibilityGlobals) = postSolution
20+
SolutionGuid = {26A9C8D9-CD9E-4907-B1D7-AE6B516433C9}
21+
EndGlobalSection
22+
EndGlobal

OneShot/Main.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using BepInEx;
2+
using HarmonyLib;
3+
using HarmonyLib.Tools;
4+
using Interfaces;
5+
using UnityEngine;
6+
7+
namespace OneShot
8+
{
9+
[BepInPlugin(ModName, ModGUID, ModVersion)]
10+
public class Main : BaseUnityPlugin
11+
{
12+
public const string ModName = "OneShot";
13+
public const string ModAuthor = "Septikai";
14+
public const string ModGUID = "me.septikai.OneShot";
15+
public const string ModVersion = "1.0.0";
16+
internal Harmony Harmony;
17+
internal void Awake()
18+
{
19+
// Creating new harmony instance
20+
Harmony = new Harmony(ModGUID);
21+
22+
// Applying patches
23+
Harmony.PatchAll();
24+
Logger.LogInfo($"{ModName} successfully loaded! Made by {ModAuthor}");
25+
}
26+
}
27+
28+
[HarmonyPatch(typeof(VersionNumberTextMesh), nameof(VersionNumberTextMesh.Start))]
29+
public class VersionNumberTextMeshPatch
30+
{
31+
public static void Postfix(VersionNumberTextMesh __instance)
32+
{
33+
__instance.textMesh.text += $"\n<color=red>{Main.ModName} v{Main.ModVersion} by {Main.ModAuthor}</color>";
34+
}
35+
}
36+
37+
[HarmonyPatch(typeof(Weapon), nameof(Weapon.ammo), MethodType.Setter)]
38+
public class AmmoPatchSetter
39+
{
40+
[HarmonyPostfix]
41+
public static void OneAmmo(Weapon __instance, float value)
42+
{
43+
var playerCount = LobbyController.instance.GetPlayerCount();
44+
if (playerCount != 1) return;
45+
if (__instance.type.Contains(Weapon.WeaponType.Particle)) return;
46+
if (value != __instance.maxAmmo) __instance.networkAmmo.Value = 0;
47+
}
48+
}
49+
50+
[HarmonyPatch(typeof(ForceField), nameof(ForceField.Damage))]
51+
public class ForceFieldDamagePatch
52+
{
53+
[HarmonyPostfix]
54+
public static void OneUseBlades(ForceField __instance, Collision2D other)
55+
{
56+
var playerCount = LobbyController.instance.GetPlayerCount();
57+
if (playerCount != 1) return;
58+
var component = other.gameObject.GetComponent<IDamageable>();
59+
if (component.GetType().IsSubclassOf(typeof(Weapon))) return;
60+
var blades = UnityEngine.Object.FindObjectsOfType<ParticleBlade>();
61+
if (blades == null) return;
62+
foreach (var blade in blades)
63+
{
64+
if (blade.particleField.forceField.GetInstanceID() != __instance.GetInstanceID()) continue;
65+
blade.Disintegrate();
66+
}
67+
}
68+
}
69+
70+
[HarmonyPatch(typeof(RailShot), nameof(RailShot.ReflectShot))]
71+
public class ShotReflectionPatch
72+
{
73+
[HarmonyPostfix]
74+
public static void OneReflect(RaycastHit2D hit)
75+
{
76+
var playerCount = LobbyController.instance.GetPlayerCount();
77+
if (playerCount != 1) return;
78+
var forceField = hit.collider.gameObject.GetComponent<ForceField>();
79+
var blades = UnityEngine.Object.FindObjectsOfType<ParticleBlade>();
80+
if (blades == null) return;
81+
foreach (var blade in blades)
82+
{
83+
if (blade.particleField.forceField.GetInstanceID() != forceField.GetInstanceID())
84+
{
85+
continue;
86+
}
87+
blade.Disintegrate();
88+
}
89+
}
90+
}
91+
92+
}

OneShot/OneShot.csproj

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<DebugType>embedded</DebugType>
9+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
10+
11+
<Description>A SpiderHeck mod where enemies only take one hit to kill but every weapon can only be used once</Description>
12+
<Version>1.0.0</Version>
13+
<RootNamespace>OneShot</RootNamespace>
14+
</PropertyGroup>
15+
16+
<PropertyGroup>
17+
<GameVersion>0.86.2-r.0</GameVersion>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<PackageReference Include="BepInEx.Unity" Version="6.0.0-be.556" PrivateAssets="all" />
22+
<PackageReference Include="SpiderHeck.GameLibs" Version="$(GameVersion)" PrivateAssets="all" />
23+
24+
<PackageReference Include="UnityEngine.Modules" Version="2020.3.13" PrivateAssets="all" />
25+
</ItemGroup>
26+
27+
<Target Name="Copy" AfterTargets="Build" Condition="'$(SpiderHeck)' != ''">
28+
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(SpiderHeck)\BepInEx\plugins\" UseSymboliclinksIfPossible="true" />
29+
</Target>
30+
31+
</Project>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# OneShot
2+
A SpiderHeck mod where every weapon can only be used once

0 commit comments

Comments
 (0)