mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 15:35:22 +00:00
Merge pull request #438 from misternebula/probe-destruction
fix probe destruction
This commit is contained in:
commit
47385623fd
@ -6,7 +6,7 @@ namespace QSB.MeteorSync.WorldObjects
|
||||
public class QSBMeteor : WorldObject<MeteorController>
|
||||
{
|
||||
public static bool IsSpecialImpact(GameObject go) =>
|
||||
go == Locator.GetPlayerCollider().gameObject || go == Locator.GetProbe()._anchor._collider.gameObject;
|
||||
go == Locator.GetPlayerCollider().gameObject || (Locator.GetProbe() != null && go == Locator.GetProbe()._anchor._collider.gameObject);
|
||||
|
||||
public void SpecialImpact()
|
||||
{
|
||||
|
@ -284,7 +284,8 @@ namespace QSB.Player.TransformSync
|
||||
}
|
||||
|
||||
public override bool IsReady
|
||||
=> Locator.GetPlayerTransform() != null;
|
||||
=> AttachedObject != null
|
||||
|| Locator.GetPlayerTransform() != null;
|
||||
|
||||
public static PlayerTransformSync LocalInstance { get; private set; }
|
||||
|
||||
|
@ -104,6 +104,7 @@ namespace QSB.Syncs
|
||||
protected virtual float DistanceLeeway { get; } = 5f;
|
||||
private float _previousDistance;
|
||||
protected const float SmoothTime = 0.1f;
|
||||
protected const int MaxLabelSize = 15;
|
||||
private Vector3 _positionSmoothVelocity;
|
||||
private Quaternion _rotationSmoothVelocity;
|
||||
protected bool _isInitialized;
|
||||
@ -294,5 +295,40 @@ namespace QSB.Syncs
|
||||
Popcron.Gizmos.Cube(ReferenceTransform.position, ReferenceTransform.rotation, Vector3.one / 8, Color.magenta);
|
||||
Popcron.Gizmos.Line(AttachedObject.transform.position, ReferenceTransform.position, Color.cyan);
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUIStyle guiStyle = new();
|
||||
guiStyle.normal.textColor = Color.white;
|
||||
GUI.contentColor = Color.white;
|
||||
|
||||
if (Locator.GetPlayerCamera() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AttachedObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var screenPosition = Locator.GetPlayerCamera().WorldToScreenPoint(AttachedObject.transform.position);
|
||||
var distance = screenPosition.z;
|
||||
var mappedFontSize = distance.Map(0, 250, MaxLabelSize, 0, true);
|
||||
guiStyle.fontSize = (int)mappedFontSize;
|
||||
|
||||
if ((int)mappedFontSize <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((int)mappedFontSize >= MaxLabelSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// WorldToScreenPoint's (0,0) is at screen bottom left, GUI's (0,0) is at screen top left. grrrr
|
||||
GUI.Label(new Rect(screenPosition.x, Screen.height - screenPosition.y, 100f, 20f), LogName, guiStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ namespace QSB.TimeSync
|
||||
return;
|
||||
}
|
||||
|
||||
var mappedTimescale = diff.Map(-PauseOrFastForwardThreshold, PauseOrFastForwardThreshold, 1 + TimescaleBounds, 1 - TimescaleBounds);
|
||||
var mappedTimescale = diff.Map(-PauseOrFastForwardThreshold, PauseOrFastForwardThreshold, 1 + TimescaleBounds, 1 - TimescaleBounds, true);
|
||||
if (mappedTimescale > 100f)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - CheckTimeDifference() returned over 100 - should have switched into fast-forward!", MessageType.Warning);
|
||||
|
41
QSB/Tools/ProbeTool/Patches/ProbeToolPatches.cs
Normal file
41
QSB/Tools/ProbeTool/Patches/ProbeToolPatches.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using HarmonyLib;
|
||||
using QSB.Patches;
|
||||
|
||||
namespace QSB.Tools.ProbeTool.Patches
|
||||
{
|
||||
internal class ProbeToolPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
/*
|
||||
* This patch is just to avoid error spam when testing probe destruction in SolarSystem
|
||||
*/
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(NomaiWarpStreaming), nameof(NomaiWarpStreaming.FixedUpdate))]
|
||||
public static bool FixedUpdateOverride(NomaiWarpStreaming __instance)
|
||||
{
|
||||
if (__instance._warpTransmitter != null)
|
||||
{
|
||||
var ableToBeWarped = __instance._warpTransmitter.GetViewAngleToTarget() < __instance._streamingAngle;
|
||||
var probeAbove = __instance._probe != null && __instance._probe.IsLaunched() && (!__instance._probe.IsAnchored() || __instance._warpTransmitter.IsProbeOnPlatform());
|
||||
|
||||
var shouldBeLoadingRequiredAssets = ableToBeWarped && (__instance._playerInVolume || (__instance._probeInVolume && probeAbove));
|
||||
var shouldBeLoadingGeneralAssets = ableToBeWarped && __instance._warpTransmitter.IsPlayerOnPlatform();
|
||||
__instance.UpdatePreloadingState(shouldBeLoadingRequiredAssets, shouldBeLoadingGeneralAssets);
|
||||
}
|
||||
|
||||
if (__instance._warpReceiver != null)
|
||||
{
|
||||
var ableToBeWarped = __instance._warpReceiver.IsReturnWarpEnabled() || __instance._warpReceiver.IsBlackHoleOpen();
|
||||
var probeAbove = __instance._probe != null && __instance._probe.IsLaunched() && (!__instance._probe.IsAnchored() || __instance._warpReceiver.IsProbeOnPlatform());
|
||||
|
||||
var shouldBeLoadingRequiredAssets = ableToBeWarped && (__instance._playerInVolume || (__instance._probeInVolume && probeAbove));
|
||||
var shouldBeLoadingGeneralAssets = ableToBeWarped && __instance._playerInVolume;
|
||||
__instance.UpdatePreloadingState(shouldBeLoadingRequiredAssets, shouldBeLoadingGeneralAssets);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -27,9 +27,15 @@ namespace QSB.Tools.ProbeTool
|
||||
// ProbeDetector
|
||||
//Object.Destroy(newProbe.Find("ProbeDetector").gameObject);
|
||||
var probeDetector = newProbe.Find("ProbeDetector").gameObject;
|
||||
probeDetector.tag = "Untagged";
|
||||
Object.Destroy(probeDetector.GetComponent<ForceApplier>());
|
||||
Object.Destroy(probeDetector.GetComponent<ProbeFluidDetector>());
|
||||
Object.Destroy(probeDetector.GetComponent<SectorDetector>());
|
||||
Object.Destroy(probeDetector.GetComponent<AlignmentForceDetector>());
|
||||
Object.Destroy(probeDetector.GetComponent<OxygenDetector>());
|
||||
Object.Destroy(probeDetector.GetComponent<RulesetDetector>());
|
||||
Object.Destroy(probeDetector.GetComponent<ProbeDestructionDetector>());
|
||||
Object.Destroy(probeDetector.GetComponent<VisionDetector>());
|
||||
|
||||
// CameraPivot
|
||||
var cameraPivot = newProbe.Find("CameraPivot");
|
||||
|
@ -101,6 +101,8 @@ namespace QSB.Tools.ProbeTool
|
||||
OnRetrieveProbe();
|
||||
break;
|
||||
case ProbeEvent.Destroy:
|
||||
Destroy(gameObject);
|
||||
|
||||
if (OnProbeDestroyed == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - OnProbeDestroyed is null!", OWML.Common.MessageType.Warning);
|
||||
|
@ -113,6 +113,6 @@ namespace QSB.Tools.ProbeTool.TransformSync
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool IsReady => Locator.GetProbe() != null;
|
||||
public override bool IsReady => AttachedObject != null || Locator.GetProbe() != null;
|
||||
}
|
||||
}
|
||||
|
@ -73,11 +73,16 @@ namespace QSB.Utility
|
||||
}
|
||||
}
|
||||
|
||||
if (Keyboard.current[Key.Numpad1].wasPressedThisFrame)
|
||||
if (Keyboard.current[Key.Numpad2].wasPressedThisFrame)
|
||||
{
|
||||
TimeLoop._isTimeFlowing = true;
|
||||
}
|
||||
|
||||
if (Keyboard.current[Key.Numpad3].wasPressedThisFrame)
|
||||
{
|
||||
Destroy(Locator.GetProbe().gameObject);
|
||||
}
|
||||
|
||||
if (Keyboard.current[Key.Numpad4].wasPressedThisFrame)
|
||||
{
|
||||
DamageShipElectricalSystem();
|
||||
|
@ -100,8 +100,14 @@ namespace QSB.Utility
|
||||
}
|
||||
}
|
||||
|
||||
public static float Map(this float value, float inputFrom, float inputTo, float outputFrom, float outputTo)
|
||||
=> ((value - inputFrom) / (inputTo - inputFrom) * (outputTo - outputFrom)) + outputFrom;
|
||||
public static float Map(this float value, float inputFrom, float inputTo, float outputFrom, float outputTo, bool clamp)
|
||||
{
|
||||
var mappedValue = ((value - inputFrom) / (inputTo - inputFrom) * (outputTo - outputFrom)) + outputFrom;
|
||||
|
||||
return clamp
|
||||
? Mathf.Clamp(mappedValue, outputTo, outputFrom)
|
||||
: mappedValue;
|
||||
}
|
||||
|
||||
public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user