mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 00:39:53 +00:00
add forest patches
This commit is contained in:
parent
1eb7ca4315
commit
30604faee8
@ -0,0 +1,63 @@
|
||||
using HarmonyLib;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.ForestOfGalaxies.Patches
|
||||
{
|
||||
internal class ForestPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(OldGrowthForestController), nameof(OldGrowthForestController.CheckIllumination))]
|
||||
public static bool CheckIlluminationReplacement(Vector3 worldPosition, ref bool __result)
|
||||
{
|
||||
if (Locator.GetFlashlight().IsFlashlightOn() || QSBPlayerManager.PlayerList.Any(x => x.FlashlightActive))
|
||||
{
|
||||
foreach (var player in QSBPlayerManager.PlayerList)
|
||||
{
|
||||
var vector = player.Body.transform.position - worldPosition;
|
||||
vector.y = 0f;
|
||||
if (vector.magnitude < 50f)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((Locator.GetProbe() != null && Locator.GetProbe().IsAnchored())
|
||||
|| QSBPlayerManager.PlayerList.Where(x => x != QSBPlayerManager.LocalPlayer).Any(x => x.Probe != null && x.Probe.IsAnchored()))
|
||||
{
|
||||
foreach (var player in QSBPlayerManager.PlayerList)
|
||||
{
|
||||
if (player == QSBPlayerManager.LocalPlayer)
|
||||
{
|
||||
var vector = Locator.GetProbe().transform.position - worldPosition;
|
||||
vector.y = 0f;
|
||||
if (vector.magnitude < 50f)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var vector = player.ProbeBody.transform.position - worldPosition;
|
||||
vector.y = 0f;
|
||||
if (vector.magnitude < 50f)
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ namespace QSB.Tools.ProbeTool
|
||||
private SingularityWarpEffect _warpEffect;
|
||||
private bool _isRetrieving;
|
||||
private PlayerInfo _owner;
|
||||
private bool _anchored;
|
||||
|
||||
public RulesetDetector GetRulesetDetector()
|
||||
=> _rulesetDetector;
|
||||
@ -56,6 +57,9 @@ namespace QSB.Tools.ProbeTool
|
||||
public bool IsLaunched()
|
||||
=> gameObject.activeSelf;
|
||||
|
||||
public bool IsAnchored()
|
||||
=> IsLaunched() && _anchored;
|
||||
|
||||
public void HandleEvent(ProbeEvent probeEvent)
|
||||
{
|
||||
if (_owner == null)
|
||||
@ -67,19 +71,23 @@ namespace QSB.Tools.ProbeTool
|
||||
switch (probeEvent)
|
||||
{
|
||||
case ProbeEvent.Launch:
|
||||
_anchored = false;
|
||||
|
||||
gameObject.SetActive(true);
|
||||
transform.position = _owner.ProbeLauncher.transform.position;
|
||||
transform.rotation = _owner.ProbeLauncher.transform.rotation;
|
||||
|
||||
if (OnLaunchProbe == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - OnLaunchProbe is null!", OWML.Common.MessageType.Warning);
|
||||
break;
|
||||
}
|
||||
|
||||
gameObject.SetActive(true);
|
||||
transform.position = _owner.ProbeLauncher.transform.position;
|
||||
transform.rotation = _owner.ProbeLauncher.transform.rotation;
|
||||
|
||||
OnLaunchProbe();
|
||||
break;
|
||||
case ProbeEvent.Anchor:
|
||||
_anchored = true;
|
||||
|
||||
if (OnAnchorProbe == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - OnAnchorProbe is null!", OWML.Common.MessageType.Warning);
|
||||
@ -89,9 +97,11 @@ namespace QSB.Tools.ProbeTool
|
||||
OnAnchorProbe();
|
||||
break;
|
||||
case ProbeEvent.Unanchor:
|
||||
_anchored = false;
|
||||
OnUnanchorProbe();
|
||||
break;
|
||||
case ProbeEvent.Retrieve:
|
||||
_anchored = false;
|
||||
if (OnRetrieveProbe == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - OnRetrieveProbe is null!", OWML.Common.MessageType.Warning);
|
||||
@ -101,6 +111,7 @@ namespace QSB.Tools.ProbeTool
|
||||
OnRetrieveProbe();
|
||||
break;
|
||||
case ProbeEvent.Destroy:
|
||||
_anchored = false;
|
||||
Destroy(gameObject);
|
||||
|
||||
if (OnProbeDestroyed == null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user