mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-03 17:38:30 +00:00
ship damage setting
This commit is contained in:
parent
f74254a522
commit
b4c18c9e3d
@ -13,11 +13,20 @@ public class DeathPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
/// <summary>
|
||||
/// don't take damage from impact in ship
|
||||
/// </summary>
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerResources), nameof(PlayerResources.OnImpact))]
|
||||
public static bool PlayerResources_OnImpact(PlayerResources __instance, ImpactData impact) =>
|
||||
// don't take damage from impact in ship
|
||||
!PlayerState.IsInsideShip();
|
||||
public static bool PlayerResources_OnImpact(PlayerResources __instance, ImpactData impact)
|
||||
{
|
||||
if (QSBCore.ShipDamage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return !PlayerState.IsInsideShip();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// don't insta-die from impact in ship
|
||||
@ -26,6 +35,11 @@ public class DeathPatches : QSBPatch
|
||||
[HarmonyPatch(typeof(HighSpeedImpactSensor), nameof(HighSpeedImpactSensor.HandlePlayerInsideShip))]
|
||||
public static bool HighSpeedImpactSensor_HandlePlayerInsideShip(HighSpeedImpactSensor __instance)
|
||||
{
|
||||
if (QSBCore.ShipDamage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var shipCenter = Locator.GetShipTransform().position + Locator.GetShipTransform().up * 2f;
|
||||
var distanceFromShip = Vector3.Distance(__instance._body.GetPosition(), shipCenter);
|
||||
if (distanceFromShip > 8f)
|
||||
|
@ -56,6 +56,7 @@ public class QSBCore : ModBehaviour
|
||||
Application.version.Split('.').Take(3).Join(delimiter: ".");
|
||||
public static bool DLCInstalled => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned;
|
||||
public static bool IncompatibleModsAllowed { get; private set; }
|
||||
public static bool ShipDamage { get; private set; }
|
||||
public static GameVendor GameVendor { get; private set; } = GameVendor.None;
|
||||
public static bool IsStandalone => GameVendor is GameVendor.Epic or GameVendor.Steam;
|
||||
public static IProfileManager ProfileManager => IsStandalone
|
||||
@ -242,6 +243,7 @@ public class QSBCore : ModBehaviour
|
||||
{
|
||||
DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
|
||||
IncompatibleModsAllowed = config.GetSettingsValue<bool>("incompatibleModsAllowed");
|
||||
ShipDamage = config.GetSettingsValue<bool>("shipDamage");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
@ -2,6 +2,7 @@
|
||||
"enabled": true,
|
||||
"settings": {
|
||||
"defaultServerIP": "localhost",
|
||||
"incompatibleModsAllowed": false
|
||||
"incompatibleModsAllowed": false,
|
||||
"shipDamage": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user