mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-28 12:40:28 +00:00
allowing nova to kill players (#39)
This commit is contained in:
parent
356852706e
commit
c862ac79df
@ -1,4 +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/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QSB/@EntryIndexedValue">QSB</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QSB/@EntryIndexedValue">QSB</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Respawn/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Spawner/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Traveller/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Traveller/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
@ -1,5 +1,6 @@
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using OWML.ModHelper;
|
using OWML.ModHelper;
|
||||||
|
using QSB.TimeSync;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
<Compile Include="Messaging\MessageHandler.cs" />
|
<Compile Include="Messaging\MessageHandler.cs" />
|
||||||
<Compile Include="Messaging\MessageType.cs" />
|
<Compile Include="Messaging\MessageType.cs" />
|
||||||
<Compile Include="Messaging\QSBMessage.cs" />
|
<Compile Include="Messaging\QSBMessage.cs" />
|
||||||
<Compile Include="RespawnOnDeath.cs" />
|
<Compile Include="TimeSync\RespawnOnDeath.cs" />
|
||||||
<Compile Include="TransformSync\QuaternionHelper.cs" />
|
<Compile Include="TransformSync\QuaternionHelper.cs" />
|
||||||
<Compile Include="QSBBehaviour.cs" />
|
<Compile Include="QSBBehaviour.cs" />
|
||||||
<Compile Include="TimeSync\PreserveTimeScale.cs" />
|
<Compile Include="TimeSync\PreserveTimeScale.cs" />
|
||||||
|
@ -1,42 +1,42 @@
|
|||||||
using OWML.ModHelper.Events;
|
using System.Linq;
|
||||||
using System.Linq;
|
using OWML.ModHelper.Events;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace QSB
|
namespace QSB.TimeSync
|
||||||
{
|
{
|
||||||
class RespawnOnDeath : MonoBehaviour
|
public class RespawnOnDeath : MonoBehaviour
|
||||||
{
|
{
|
||||||
static RespawnOnDeath Instance;
|
private static RespawnOnDeath _instance;
|
||||||
|
|
||||||
SpawnPoint _shipSpawnPoint;
|
private SpawnPoint _shipSpawnPoint;
|
||||||
SpawnPoint _playerSpawnPoint;
|
private SpawnPoint _playerSpawnPoint;
|
||||||
OWRigidbody _shipBody;
|
private OWRigidbody _shipBody;
|
||||||
PlayerSpawner _playerSpawner;
|
private PlayerSpawner _playerSpawner;
|
||||||
FluidDetector _fluidDetector;
|
private FluidDetector _fluidDetector;
|
||||||
PlayerResources _playerResources;
|
private PlayerResources _playerResources;
|
||||||
ShipComponent[] _shipComponents;
|
private ShipComponent[] _shipComponents;
|
||||||
HatchController _hatchController;
|
private HatchController _hatchController;
|
||||||
ShipCockpitController _cockpitController;
|
private ShipCockpitController _cockpitController;
|
||||||
PlayerSpacesuit _spaceSuit;
|
private PlayerSpacesuit _spaceSuit;
|
||||||
|
|
||||||
void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
GlobalMessenger.AddListener("WakeUp", PlayerWokeUp);
|
GlobalMessenger.AddListener("WakeUp", PlayerWokeUp);
|
||||||
|
|
||||||
Instance = this;
|
_instance = this;
|
||||||
QSB.Helper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(Patches), nameof(Patches.PreFinishDeathSequence));
|
QSB.Helper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(Patches), nameof(Patches.PreFinishDeathSequence));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerWokeUp()
|
private void PlayerWokeUp()
|
||||||
{
|
{
|
||||||
var playerTransform = Locator.GetPlayerTransform();
|
var playerTransform = Locator.GetPlayerTransform();
|
||||||
_playerResources = Locator.GetPlayerTransform().GetComponent<PlayerResources>();
|
_playerResources = playerTransform.GetComponent<PlayerResources>();
|
||||||
_spaceSuit = Locator.GetPlayerTransform().GetComponentInChildren<PlayerSpacesuit>(true);
|
_spaceSuit = playerTransform.GetComponentInChildren<PlayerSpacesuit>(true);
|
||||||
_playerSpawner = FindObjectOfType<PlayerSpawner>();
|
_playerSpawner = FindObjectOfType<PlayerSpawner>();
|
||||||
_fluidDetector = Locator.GetPlayerCamera().GetComponentInChildren<FluidDetector>();
|
_fluidDetector = Locator.GetPlayerCamera().GetComponentInChildren<FluidDetector>();
|
||||||
|
|
||||||
var shipTransform = Locator.GetShipTransform();
|
var shipTransform = Locator.GetShipTransform();
|
||||||
if (shipTransform)
|
if (shipTransform != null)
|
||||||
{
|
{
|
||||||
_shipComponents = shipTransform.GetComponentsInChildren<ShipComponent>();
|
_shipComponents = shipTransform.GetComponentsInChildren<ShipComponent>();
|
||||||
_hatchController = shipTransform.GetComponentInChildren<HatchController>();
|
_hatchController = shipTransform.GetComponentInChildren<HatchController>();
|
||||||
@ -54,7 +54,7 @@ namespace QSB
|
|||||||
|
|
||||||
public void ResetShip()
|
public void ResetShip()
|
||||||
{
|
{
|
||||||
if (!_shipBody)
|
if (_shipBody == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -66,16 +66,16 @@ namespace QSB
|
|||||||
// Reset ship damage.
|
// Reset ship damage.
|
||||||
if (Locator.GetShipTransform())
|
if (Locator.GetShipTransform())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _shipComponents.Length; i++)
|
foreach (var shipComponent in _shipComponents)
|
||||||
{
|
{
|
||||||
_shipComponents[i].SetDamaged(false);
|
shipComponent.SetDamaged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Invoke(nameof(ExitShip), 0.01f);
|
Invoke(nameof(ExitShip), 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExitShip()
|
private void ExitShip()
|
||||||
{
|
{
|
||||||
_cockpitController.Invoke("ExitFlightConsole");
|
_cockpitController.Invoke("ExitFlightConsole");
|
||||||
_cockpitController.Invoke("CompleteExitFlightConsole");
|
_cockpitController.Invoke("CompleteExitFlightConsole");
|
||||||
@ -104,7 +104,7 @@ namespace QSB
|
|||||||
_spaceSuit.RemoveSuit(true);
|
_spaceSuit.RemoveSuit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpawnPoint GetSpawnPoint(bool isShip = false)
|
private SpawnPoint GetSpawnPoint(bool isShip = false)
|
||||||
{
|
{
|
||||||
return _playerSpawner
|
return _playerSpawner
|
||||||
.GetValue<SpawnPoint[]>("_spawnList")
|
.GetValue<SpawnPoint[]>("_spawnList")
|
||||||
@ -115,10 +115,19 @@ namespace QSB
|
|||||||
|
|
||||||
internal static class Patches
|
internal static class Patches
|
||||||
{
|
{
|
||||||
public static bool PreFinishDeathSequence()
|
public static bool PreFinishDeathSequence(DeathType deathType)
|
||||||
{
|
{
|
||||||
Instance.ResetShip();
|
DebugLog.Screen("Death by " + deathType);
|
||||||
Instance.ResetPlayer();
|
QSB.Helper.Console.WriteLine("Death by " + deathType);
|
||||||
|
|
||||||
|
if (deathType == DeathType.Supernova)
|
||||||
|
{
|
||||||
|
// Allow real death
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_instance.ResetShip();
|
||||||
|
_instance.ResetPlayer();
|
||||||
|
|
||||||
// Prevent original death method from running.
|
// Prevent original death method from running.
|
||||||
return false;
|
return false;
|
Loading…
x
Reference in New Issue
Block a user