Catch gear break event

This commit is contained in:
2025-06-29 02:00:22 +03:00
parent dea890d541
commit 5064f607b5
5 changed files with 52 additions and 34 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
bin/
obj/

View File

@ -10,23 +10,10 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7a23d6a2-8a03-45c3-b4f4-ba70e6386a3d" name="Changes" comment=""> <list default="true" id="7a23d6a2-8a03-45c3-b4f4-ba70e6386a3d" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" /> <change afterPath="$PROJECT_DIR$/GearToLife/GearToLife/Patches/KnifePatch.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/encodings.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/indexLayout.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/projectSettingsUpdater.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLifeModSystem.cs" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLifeModSystem.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife.sln" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/GearToLife.sln" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLife.csproj" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLifeModSystem.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/GearToLife/Properties/launchSettings.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/GearToLife/assets/geartolife/lang/en.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/GearToLife/modinfo.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/ZZCakeBuild/CakeBuild.csproj" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/ZZCakeBuild/Program.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/build.ps1" afterDir="false" />
<change afterPath="$PROJECT_DIR$/GearToLife/build.sh" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -39,6 +26,12 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/0c42f62c19174521b2d3845ff1c760a82400/7e/d3044f89/ItemTemporalGearPatches.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/0c42f62c19174521b2d3845ff1c760a82400/80/2430a869/TemporalLifeModSystem.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/185df8fd8a7e41f3aa8086976f138a921db000/b4/8111d97a/ModSystem.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/ae66fe3dcb4e4d08b5173bd19fa1fd242b7200/b7/cc8f3c36/EntityBehaviorTemporalStabilityAffected.cs" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 0 "associatedIndex": 0
}]]></component> }]]></component>
@ -127,7 +120,7 @@
<updated>1751123667023</updated> <updated>1751123667023</updated>
<workItem from="1751123668534" duration="26000" /> <workItem from="1751123668534" duration="26000" />
<workItem from="1751128070781" duration="223000" /> <workItem from="1751128070781" duration="223000" />
<workItem from="1751129068738" duration="1611000" /> <workItem from="1751129068738" duration="11848000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -0,0 +1,9 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEntityBehaviorTemporalStabilityAffected_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fae66fe3dcb4e4d08b5173bd19fa1fd242b7200_003Fb7_003Fcc8f3c36_003FEntityBehaviorTemporalStabilityAffected_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AItemTemporalGearPatches_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0c42f62c19174521b2d3845ff1c760a82400_003F7e_003Fd3044f89_003FItemTemporalGearPatches_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AModSystem_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F185df8fd8a7e41f3aa8086976f138a921db000_003Fb4_003F8111d97a_003FModSystem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATemporalLifeModSystem_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0c42f62c19174521b2d3845ff1c760a82400_003F80_003F2430a869_003FTemporalLifeModSystem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="D:\VintageStory\Lib\0Harmony.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Users\Den\RiderProjects\GearToLife\TemporalLife.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>

View File

@ -1,26 +1,23 @@
using Vintagestory.API.Client; using HarmonyLib;
using Vintagestory.API.Server;
using Vintagestory.API.Config;
using Vintagestory.API.Common; using Vintagestory.API.Common;
namespace GearToLife; namespace GearToLife;
public class GearToLifeModSystem : ModSystem public class GearToLifeModSystem : ModSystem
{ {
// Called on server and client private Harmony patcher;
// Useful for registering block/entity classes on both sides
public override void Start(ICoreAPI api) public override void Start(ICoreAPI api)
{ {
Mod.Logger.Notification("Hello from template mod: " + api.Side); if (!Harmony.HasAnyPatches(Mod.Info.ModID))
{
patcher = new Harmony(Mod.Info.ModID);
patcher.PatchCategory(Mod.Info.ModID);
}
} }
public override void StartServerSide(ICoreServerAPI api) public override void Dispose()
{ {
Mod.Logger.Notification("Hello from template mod server side: " + Lang.Get("geartolife:hello")); patcher?.UnpatchAll(Mod.Info.ModID);
}
public override void StartClientSide(ICoreClientAPI api)
{
Mod.Logger.Notification("Hello from template mod client side: " + Lang.Get("geartolife:hello"));
} }
} }

View File

@ -0,0 +1,21 @@
using HarmonyLib;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.GameContent;
namespace GearToLife.Patches;
[HarmonyPatchCategory("geartolife")]
internal static class KnifePatch
{
[HarmonyPostfix()]
[HarmonyPatch(typeof(ItemKnife), "OnHeldInteractStop")]
public static void AfterBreakingGear(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
{
if (byEntity.Attributes.GetBool("isInsertGear") && secondsUsed >= 1.95f)
{
// Пример события
byEntity.Ignite();
}
}
}