version 1.0
This commit is contained in:
51
.idea/.idea.GearToLife/.idea/workspace.xml
generated
51
.idea/.idea.GearToLife/.idea/workspace.xml
generated
@ -10,10 +10,15 @@
|
|||||||
</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$/GearToLife/GearToLife/Patches/KnifePatch.cs" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/GearToLife/GearToLife/ModConfig.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="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 beforePath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.GearToLife/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/GearToLife.sln.DotSettings.user" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife.sln.DotSettings.user" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLife.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLife.csproj" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLifeModSystem.cs" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLifeModSystem.cs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLifeModSystem.cs" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife/GearToLife/GearToLifeModSystem.cs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/Patches/KnifePatch.cs" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife/GearToLife/Patches/TemporalGearPatches.cs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/assets/geartolife/lang/en.json" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/modicon.png" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife/GearToLife/modicon.png" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/GearToLife/GearToLife/modinfo.json" beforeDir="false" afterPath="$PROJECT_DIR$/GearToLife/GearToLife/modinfo.json" 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" />
|
||||||
@ -29,12 +34,15 @@
|
|||||||
<component name="HighlightingSettingsPerFile">
|
<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/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/0c42f62c19174521b2d3845ff1c760a82400/80/2430a869/TemporalLifeModSystem.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/185df8fd8a7e41f3aa8086976f138a921db000/59/b0654600/EnumAppSide.cs" root0="SKIP_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/185df8fd8a7e41f3aa8086976f138a921db000/b4/8111d97a/ModSystem.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/185df8fd8a7e41f3aa8086976f138a921db000/c7/55ed9fec/EnumChatType.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/ae66fe3dcb4e4d08b5173bd19fa1fd242b7200/b7/cc8f3c36/EntityBehaviorTemporalStabilityAffected.cs" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/ae66fe3dcb4e4d08b5173bd19fa1fd242b7200/b7/cc8f3c36/EntityBehaviorTemporalStabilityAffected.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectColorInfo"><![CDATA[{
|
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
|
||||||
"associatedIndex": 0
|
<component name="ProjectColorInfo">{
|
||||||
}]]></component>
|
"associatedIndex": 0
|
||||||
|
}</component>
|
||||||
<component name="ProjectId" id="2z92eve49DLISsGqp57P4sab7TN" />
|
<component name="ProjectId" id="2z92eve49DLISsGqp57P4sab7TN" />
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
@ -43,9 +51,12 @@
|
|||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
".NET Launch Settings Profile.GearToLife: Client.executor": "Run",
|
".NET Launch Settings Profile.GearToLife: Client.executor": "Run",
|
||||||
|
".NET Launch Settings Profile.GearToLife: Server.executor": "Run",
|
||||||
|
".NET Project.CakeBuild.executor": "Run",
|
||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
|
||||||
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"git-widget-placeholder": "master",
|
"git-widget-placeholder": "master",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
@ -56,7 +67,7 @@
|
|||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RunManager" selected=".NET Launch Settings Profile.GearToLife: Client">
|
<component name="RunManager" selected=".NET Project.CakeBuild">
|
||||||
<configuration name="CakeBuild" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="CakeBuild" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="" />
|
<option name="EXE_PATH" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@ -120,16 +131,42 @@
|
|||||||
<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="11848000" />
|
<workItem from="1751129068738" duration="12452000" />
|
||||||
|
<workItem from="1751184684862" duration="604000" />
|
||||||
|
<workItem from="1751194709803" duration="1551000" />
|
||||||
|
<workItem from="1751723280140" duration="17500000" />
|
||||||
</task>
|
</task>
|
||||||
|
<task id="LOCAL-00001" summary="Catch gear break event">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1751151622907</created>
|
||||||
|
<option name="number" value="00001" />
|
||||||
|
<option name="presentableId" value="LOCAL-00001" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1751151622907</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="2" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
|
||||||
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
|
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
|
||||||
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
<option name="TAB_STATES">
|
||||||
|
<map>
|
||||||
|
<entry key="MAIN">
|
||||||
|
<value>
|
||||||
|
<State />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||||
|
<MESSAGE value="Catch gear break event" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Catch gear break event" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<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">
|
<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_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_003AEnumChatType_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F185df8fd8a7e41f3aa8086976f138a921db000_003Fc7_003F55ed9fec_003FEnumChatType_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_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_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/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>
|
||||||
|
@ -61,4 +61,8 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="assets\geartolife\lang\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,23 +1,115 @@
|
|||||||
using HarmonyLib;
|
using System;
|
||||||
|
using HarmonyLib;
|
||||||
using Vintagestory.API.Common;
|
using Vintagestory.API.Common;
|
||||||
|
using Vintagestory.API.Config;
|
||||||
|
using Vintagestory.API.Server;
|
||||||
|
|
||||||
namespace GearToLife;
|
namespace GearToLife;
|
||||||
|
|
||||||
public class GearToLifeModSystem : ModSystem
|
public class GearToLifeModSystem : ModSystem
|
||||||
{
|
{
|
||||||
private Harmony patcher;
|
private Harmony Patcher { get; set; }
|
||||||
|
private static ModConfig Config { get; set; }
|
||||||
|
|
||||||
public override void Start(ICoreAPI api)
|
public override void StartServerSide(ICoreServerAPI api)
|
||||||
{
|
{
|
||||||
if (!Harmony.HasAnyPatches(Mod.Info.ModID))
|
if (Harmony.HasAnyPatches(Mod.Info.ModID)) return;
|
||||||
|
|
||||||
|
Patcher = new Harmony(Mod.Info.ModID);
|
||||||
|
Patcher.PatchCategory(Mod.Info.ModID);
|
||||||
|
|
||||||
|
api.Event.PlayerDeath += OnPlayerDeath;
|
||||||
|
api.Event.PlayerRespawn += OnPlayerRespawn;
|
||||||
|
|
||||||
|
api.ChatCommands
|
||||||
|
.Create("lives")
|
||||||
|
.WithDescription("Show your current remaining lives.")
|
||||||
|
.RequiresPrivilege("chat")
|
||||||
|
.HandleWith(OnLivesCommand);
|
||||||
|
|
||||||
|
TryToLoadConfig(api);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TryToLoadConfig(ICoreServerAPI api)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
patcher = new Harmony(Mod.Info.ModID);
|
Config = api.LoadModConfig<ModConfig>("GearToLifeConfig.json") ?? new ModConfig();
|
||||||
patcher.PatchCategory(Mod.Info.ModID);
|
api.StoreModConfig(Config, "GearToLifeConfig.json");
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Mod.Logger.Error(Lang.Get("geartolife:logs.config_load_error"));
|
||||||
|
Mod.Logger.Error(e);
|
||||||
|
Config = new ModConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TextCommandResult OnLivesCommand(TextCommandCallingArgs args)
|
||||||
|
{
|
||||||
|
if (args.Caller.Player is not IServerPlayer player)
|
||||||
|
{
|
||||||
|
return TextCommandResult.Error("Command requires server player.", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return TextCommandResult.Success(Lang.Get("geartolife:command_response.lives", GetLives(player)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Notify(IServerPlayer player, string key, params object[] args)
|
||||||
|
{
|
||||||
|
player.SendMessage(GlobalConstants.GeneralChatGroup, Lang.Get
|
||||||
|
(
|
||||||
|
key, args
|
||||||
|
), EnumChatType.Notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GetLives(IServerPlayer player)
|
||||||
|
{
|
||||||
|
return player.WorldData.GetModData("geartolife:lives", Config.InitialLivesAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetLives(IServerPlayer player, int value)
|
||||||
|
{
|
||||||
|
player.WorldData.SetModData("geartolife:lives", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddLife(IServerPlayer player)
|
||||||
|
{
|
||||||
|
var newLives = GetLives(player) + Config.LivesPerGear;
|
||||||
|
|
||||||
|
if (newLives >= Config.MaxLivesAmount && Config.MaxLivesAmount != -1)
|
||||||
|
{
|
||||||
|
newLives = Config.MaxLivesAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLives(player, newLives);
|
||||||
|
Notify(player, "geartolife:lives.added", newLives);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnPlayerDeath(IServerPlayer player, DamageSource damageSource)
|
||||||
|
{
|
||||||
|
var lives = GetLives(player);
|
||||||
|
if (lives <= 0) return;
|
||||||
|
|
||||||
|
SetLives(player, lives - 1);
|
||||||
|
|
||||||
|
if (GetLives(player) > 0)
|
||||||
|
{
|
||||||
|
Notify(player, "geartolife:lives.lost", GetLives(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnPlayerRespawn(IServerPlayer player)
|
||||||
|
{
|
||||||
|
if (GetLives(player) > 0) return;
|
||||||
|
|
||||||
|
player.WorldData.CurrentGameMode = EnumGameMode.Spectator;
|
||||||
|
player.BroadcastPlayerData();
|
||||||
|
Notify(player, "geartolife:respawn.spectator", GetLives(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
patcher?.UnpatchAll(Mod.Info.ModID);
|
Patcher?.UnpatchAll(Mod.Info.ModID);
|
||||||
}
|
}
|
||||||
}
|
}
|
8
GearToLife/GearToLife/ModConfig.cs
Normal file
8
GearToLife/GearToLife/ModConfig.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace GearToLife;
|
||||||
|
|
||||||
|
public class ModConfig
|
||||||
|
{
|
||||||
|
public int InitialLivesAmount = 1;
|
||||||
|
public int MaxLivesAmount = -1;
|
||||||
|
public int LivesPerGear = 1;
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
30
GearToLife/GearToLife/Patches/TemporalGearPatches.cs
Normal file
30
GearToLife/GearToLife/Patches/TemporalGearPatches.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using Vintagestory.API.Common;
|
||||||
|
using Vintagestory.API.Common.Entities;
|
||||||
|
using Vintagestory.API.Config;
|
||||||
|
using Vintagestory.API.Server;
|
||||||
|
using Vintagestory.GameContent;
|
||||||
|
|
||||||
|
namespace GearToLife.Patches;
|
||||||
|
|
||||||
|
[HarmonyPatchCategory("geartolife")]
|
||||||
|
internal static class TemporalGearPatches
|
||||||
|
{
|
||||||
|
[HarmonyPostfix()]
|
||||||
|
[HarmonyPatch(typeof(ItemTemporalGear), "OnHeldInteractStop")]
|
||||||
|
public static void AfterUsingGear(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
byEntity.World.Side != EnumAppSide.Server ||
|
||||||
|
byEntity is not EntityPlayer entityPlayer ||
|
||||||
|
entityPlayer.World.PlayerByUid(entityPlayer.PlayerUID) is not IServerPlayer player ||
|
||||||
|
secondsUsed < 3.45
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GearToLifeModSystem.AddLife(player);
|
||||||
|
}
|
||||||
|
}
|
7
GearToLife/GearToLife/assets/geartolife/lang/de.json
Normal file
7
GearToLife/GearToLife/assets/geartolife/lang/de.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"lives.added": "Deine Anzahl an Leben ist jetzt {0}.",
|
||||||
|
"lives.lost": "Du bist tot. Es gibt noch Leben: {0}.",
|
||||||
|
"respawn.spectator": "Du hast deine physische Form verloren. Du bist jetzt nur noch ein Beobachter.",
|
||||||
|
"command_response.lives": "Verbleibende Leben: {0}.",
|
||||||
|
"logs.config_load_error": "Konfiguration konnte nicht geladen werden! Stattdessen werden die Standardeinstellungen geladen."
|
||||||
|
}
|
@ -1,3 +1,7 @@
|
|||||||
{
|
{
|
||||||
"hello": "hello world!"
|
"lives.added": "Now your number of lives is {0}.",
|
||||||
}
|
"lives.lost": "You're dead. Lives left: {0}.",
|
||||||
|
"respawn.spectator": "You have lost your physical form. You are now merely a spectator.",
|
||||||
|
"command_response.lives": "Lives remaining: {0}.",
|
||||||
|
"logs.config_load_error": "Could not load config! Loading default settings instead."
|
||||||
|
}
|
||||||
|
7
GearToLife/GearToLife/assets/geartolife/lang/ru.json
Normal file
7
GearToLife/GearToLife/assets/geartolife/lang/ru.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"lives.added": "Теперь твое количество жизней: {0}.",
|
||||||
|
"lives.lost": "Ты погиб. Жизней осталось: {0}.",
|
||||||
|
"respawn.spectator": "Ты утратил физическую оболочку. Теперь ты лишь наблюдатель.",
|
||||||
|
"command_response.lives": "Осталось жизней: {0}.",
|
||||||
|
"logs.config_load_error": "Не удалось загрузить конфигурацию! Вместо этого загружаются настройки по умолчанию."
|
||||||
|
}
|
7
GearToLife/GearToLife/assets/geartolife/lang/uk.json
Normal file
7
GearToLife/GearToLife/assets/geartolife/lang/uk.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"lives.added": "Тепер твоя кількість життів: {0}.",
|
||||||
|
"lives.lost": "Ти загинув. Життів залишилося: {0}.",
|
||||||
|
"respawn.spectator": "Ти втратив фізичну оболонку. Тепер ти лише спостерігач.",
|
||||||
|
"command_response.lives": "Залишилося життя: {0}.",
|
||||||
|
"logs.config_load_error": "Не вдалося завантажити конфігурацію! Завантажуються налаштування за замовчуванням."
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 40 KiB |
@ -5,8 +5,8 @@
|
|||||||
"authors": [
|
"authors": [
|
||||||
"Dencher12"
|
"Dencher12"
|
||||||
],
|
],
|
||||||
"description": "Now when using a gear, one life is restored if there is such a limitation on the server",
|
"description": "Using the temporal gear gives lives, spending all lives results in final death.",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": ""
|
"game": ""
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user