use __instance in patches instead of ___whatever since we can access fields directly

This commit is contained in:
JohnCorby 2021-12-26 21:25:26 -08:00
parent a0a1c21a66
commit ad076e716d
12 changed files with 259 additions and 377 deletions

View File

@ -22,27 +22,19 @@ namespace QSB.Animation.NPC.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterAnimController), nameof(CharacterAnimController.OnAnimatorIK))]
public static bool AnimatorIKReplacement(
CharacterAnimController __instance,
float ___headTrackingWeight,
bool ___lookOnlyWhenTalking,
bool ____inConversation,
ref float ____currentLookWeight,
ref Vector3 ____currentLookTarget,
DampedSpring3D ___lookSpring,
Animator ____animator,
CharacterDialogueTree ____dialogueTree)
CharacterAnimController __instance)
{
if (!WorldObjectManager.AllObjectsReady || ConversationManager.Instance == null)
{
return false;
}
var playerId = ConversationManager.Instance.GetPlayerTalkingToTree(____dialogueTree);
var playerId = ConversationManager.Instance.GetPlayerTalkingToTree(__instance._dialogueTree);
var player = QSBPlayerManager.GetPlayer(playerId);
var qsbObj = __instance.GetWorldObject<QSBCharacterAnimController>(); // OPTIMIZE : maybe cache this somewhere... or assess how slow this is
PlayerInfo playerToUse = null;
if (____inConversation)
if (__instance._inConversation)
{
if (playerId == uint.MaxValue)
{
@ -56,7 +48,7 @@ namespace QSB.Animation.NPC.Patches
: player;
}
}
else if (!___lookOnlyWhenTalking && qsbObj.GetPlayersInHeadZone().Count != 0) // IDEA : maybe this would be more fun if characters looked between players at random times? :P
else if (!__instance.lookOnlyWhenTalking && qsbObj.GetPlayersInHeadZone().Count != 0) // IDEA : maybe this would be more fun if characters looked between players at random times? :P
{
playerToUse = QSBPlayerManager.GetClosestPlayerToWorldPoint(qsbObj.GetPlayersInHeadZone(), __instance.transform.position);
}
@ -66,13 +58,13 @@ namespace QSB.Animation.NPC.Patches
}
var localPosition = playerToUse != null
? ____animator.transform.InverseTransformPoint(playerToUse.CameraBody.transform.position)
? __instance._animator.transform.InverseTransformPoint(playerToUse.CameraBody.transform.position)
: Vector3.zero;
var targetWeight = ___headTrackingWeight;
if (___lookOnlyWhenTalking)
var targetWeight = __instance.headTrackingWeight;
if (__instance.lookOnlyWhenTalking)
{
if (!____inConversation
if (!__instance._inConversation
|| qsbObj.GetPlayersInHeadZone().Count == 0
|| !qsbObj.GetPlayersInHeadZone().Contains(playerToUse))
{
@ -88,10 +80,10 @@ namespace QSB.Animation.NPC.Patches
}
}
____currentLookWeight = Mathf.Lerp(____currentLookWeight, targetWeight, Time.deltaTime * 2f);
____currentLookTarget = ___lookSpring.Update(____currentLookTarget, localPosition, Time.deltaTime);
____animator.SetLookAtPosition(____animator.transform.TransformPoint(____currentLookTarget));
____animator.SetLookAtWeight(____currentLookWeight);
__instance._currentLookWeight = Mathf.Lerp(__instance._currentLookWeight, targetWeight, Time.deltaTime * 2f);
__instance._currentLookTarget = __instance.lookSpring.Update(__instance._currentLookTarget, localPosition, Time.deltaTime);
__instance._animator.SetLookAtPosition(__instance._animator.transform.TransformPoint(__instance._currentLookTarget));
__instance._animator.SetLookAtWeight(__instance._currentLookWeight);
return false;
}

View File

@ -16,28 +16,16 @@ namespace QSB.Animation.Player.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerAnimController), nameof(PlayerAnimController.LateUpdate))]
public static bool LateUpdateReplacement(
PlayerAnimController __instance,
PlayerCharacterController ____playerController,
ThrusterModel ____playerJetpack,
ref float ____ungroundedTime,
Animator ____animator,
ref bool ____justBecameGrounded,
ref bool ____justTookFallDamage,
ref bool ____leftFootGrounded,
ref bool ____rightFootGrounded,
ref bool ____rightArmHidden,
GameObject[] ____rightArmObjects,
int ____defaultLayer,
int ____probeOnlyLayer)
PlayerAnimController __instance)
{
var isGrounded = ____playerController.IsGrounded();
var isGrounded = __instance._playerController.IsGrounded();
var isAttached = PlayerState.IsAttached();
var isInZeroG = PlayerState.InZeroG();
var isFlying = ____playerJetpack.GetLocalAcceleration().y > 0f;
var isFlying = __instance._playerJetpack.GetLocalAcceleration().y > 0f;
var movementVector = Vector3.zero;
if (!isAttached)
{
movementVector = ____playerController.GetRelativeGroundVelocity();
movementVector = __instance._playerController.GetRelativeGroundVelocity();
}
if (Mathf.Abs(movementVector.x) < 0.05f)
@ -52,77 +40,77 @@ namespace QSB.Animation.Player.Patches
if (isFlying)
{
____ungroundedTime = Time.time;
__instance._ungroundedTime = Time.time;
}
var freefallMagnitude = 0f;
var timeInFreefall = 0f;
var lastGroundBody = ____playerController.GetLastGroundBody();
var lastGroundBody = __instance._playerController.GetLastGroundBody();
if (!isGrounded && !isAttached && !isInZeroG && lastGroundBody != null)
{
freefallMagnitude = (____playerController.GetAttachedOWRigidbody().GetVelocity() - lastGroundBody.GetPointVelocity(____playerController.transform.position)).magnitude;
timeInFreefall = Time.time - ____ungroundedTime;
freefallMagnitude = (__instance._playerController.GetAttachedOWRigidbody().GetVelocity() - lastGroundBody.GetPointVelocity(__instance._playerController.transform.position)).magnitude;
timeInFreefall = Time.time - __instance._ungroundedTime;
}
____animator.SetFloat("RunSpeedX", movementVector.x / 3f);
____animator.SetFloat("RunSpeedY", movementVector.z / 3f);
____animator.SetFloat("TurnSpeed", ____playerController.GetTurning());
____animator.SetBool("Grounded", isGrounded || isAttached || PlayerState.IsRecentlyDetached());
____animator.SetLayerWeight(1, ____playerController.GetJumpCrouchFraction());
____animator.SetFloat("FreefallSpeed", freefallMagnitude / 15f * (timeInFreefall / 3f));
____animator.SetBool("InZeroG", isInZeroG || isFlying);
____animator.SetBool("UsingJetpack", isInZeroG && PlayerState.IsWearingSuit());
if (____justBecameGrounded)
__instance._animator.SetFloat("RunSpeedX", movementVector.x / 3f);
__instance._animator.SetFloat("RunSpeedY", movementVector.z / 3f);
__instance._animator.SetFloat("TurnSpeed", __instance._playerController.GetTurning());
__instance._animator.SetBool("Grounded", isGrounded || isAttached || PlayerState.IsRecentlyDetached());
__instance._animator.SetLayerWeight(1, __instance._playerController.GetJumpCrouchFraction());
__instance._animator.SetFloat("FreefallSpeed", freefallMagnitude / 15f * (timeInFreefall / 3f));
__instance._animator.SetBool("InZeroG", isInZeroG || isFlying);
__instance._animator.SetBool("UsingJetpack", isInZeroG && PlayerState.IsWearingSuit());
if (__instance._justBecameGrounded)
{
var playerAnimationSync = QSBPlayerManager.LocalPlayer.AnimationSync;
if (____justTookFallDamage)
if (__instance._justTookFallDamage)
{
____animator.SetTrigger("LandHard");
__instance._animator.SetTrigger("LandHard");
new AnimationTriggerMessage(playerAnimationSync.AttachedNetId, "LandHard").Send();
}
else
{
____animator.SetTrigger("Land");
__instance._animator.SetTrigger("Land");
new AnimationTriggerMessage(playerAnimationSync.AttachedNetId, "Land").Send();
}
}
if (isGrounded)
{
var leftFootLift = ____animator.GetFloat("LeftFootLift");
if (!____leftFootGrounded && leftFootLift < 0.333f)
var leftFootLift = __instance._animator.GetFloat("LeftFootLift");
if (!__instance._leftFootGrounded && leftFootLift < 0.333f)
{
____leftFootGrounded = true;
__instance._leftFootGrounded = true;
__instance.RaiseEvent(nameof(__instance.OnLeftFootGrounded));
}
else if (____leftFootGrounded && leftFootLift > 0.666f)
else if (__instance._leftFootGrounded && leftFootLift > 0.666f)
{
____leftFootGrounded = false;
__instance._leftFootGrounded = false;
__instance.RaiseEvent(nameof(__instance.OnLeftFootLift));
}
var rightFootLift = ____animator.GetFloat("RightFootLift");
if (!____rightFootGrounded && rightFootLift < 0.333f)
var rightFootLift = __instance._animator.GetFloat("RightFootLift");
if (!__instance._rightFootGrounded && rightFootLift < 0.333f)
{
____rightFootGrounded = true;
__instance._rightFootGrounded = true;
__instance.RaiseEvent(nameof(__instance.OnRightFootGrounded));
}
else if (____rightFootGrounded && rightFootLift > 0.666f)
else if (__instance._rightFootGrounded && rightFootLift > 0.666f)
{
____rightFootGrounded = false;
__instance._rightFootGrounded = false;
__instance.RaiseEvent(nameof(__instance.OnRightFootLift));
}
}
____justBecameGrounded = false;
____justTookFallDamage = false;
__instance._justBecameGrounded = false;
__instance._justTookFallDamage = false;
var usingTool = Locator.GetToolModeSwapper().GetToolMode() != ToolMode.None;
if ((usingTool && !____rightArmHidden) || (!usingTool && ____rightArmHidden))
if ((usingTool && !__instance._rightArmHidden) || (!usingTool && __instance._rightArmHidden))
{
____rightArmHidden = usingTool;
for (var i = 0; i < ____rightArmObjects.Length; i++)
__instance._rightArmHidden = usingTool;
for (var i = 0; i < __instance._rightArmObjects.Length; i++)
{
____rightArmObjects[i].layer = (!____rightArmHidden) ? ____defaultLayer : ____probeOnlyLayer;
__instance._rightArmObjects[i].layer = (!__instance._rightArmHidden) ? __instance._defaultLayer : __instance._probeOnlyLayer;
}
}

View File

@ -7,7 +7,6 @@ using QSB.Patches;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using System.Collections.Generic;
namespace QSB.ConversationSync.Patches
{
@ -54,7 +53,7 @@ namespace QSB.ConversationSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.InputDialogueOption))]
public static bool CharacterDialogueTree_InputDialogueOption(int optionIndex, DialogueBoxVer2 ____currentDialogueBox)
public static bool CharacterDialogueTree_InputDialogueOption(CharacterDialogueTree __instance, int optionIndex)
{
if (optionIndex < 0)
{
@ -63,16 +62,16 @@ namespace QSB.ConversationSync.Patches
return true;
}
var selectedOption = ____currentDialogueBox.OptionFromUIIndex(optionIndex);
var selectedOption = __instance._currentDialogueBox.OptionFromUIIndex(optionIndex);
ConversationManager.Instance.SendPlayerOption(selectedOption.Text);
return true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(DialogueNode), nameof(DialogueNode.GetNextPage))]
public static void DialogueNode_GetNextPage(string ____name, List<string> ____listPagesToDisplay, int ____currentPage)
public static void DialogueNode_GetNextPage(DialogueNode __instance)
{
var key = ____name + ____listPagesToDisplay[____currentPage];
var key = __instance._name + __instance._listPagesToDisplay[__instance._currentPage];
// Sending key so translation can be done on client side - should make different language-d clients compatible
QSBCore.UnityEvents.RunWhen(() => QSBPlayerManager.LocalPlayer.CurrentCharacterDialogueTreeId != -1,
() => ConversationManager.Instance.SendCharacterDialogue(QSBPlayerManager.LocalPlayer.CurrentCharacterDialogueTreeId, key));

View File

@ -41,7 +41,7 @@ namespace QSB.DeathSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerResources), nameof(PlayerResources.OnImpact))]
public static bool PlayerResources_OnImpact(ImpactData impact, PlayerResources __instance, float ____currentHealth)
public static bool PlayerResources_OnImpact(PlayerResources __instance, ImpactData impact)
{
if (PlayerState.IsInsideShip())
{
@ -50,7 +50,7 @@ namespace QSB.DeathSync.Patches
var speed = Mathf.Clamp01((impact.speed - __instance.GetMinImpactSpeed()) / (__instance.GetMaxImpactSpeed() - __instance.GetMinImpactSpeed()));
var tookDamage = __instance.ApplyInstantDamage(100f * speed, InstantDamageType.Impact);
if (tookDamage && ____currentHealth <= 0f && !PlayerState.IsDead())
if (tookDamage && __instance._currentHealth <= 0f && !PlayerState.IsDead())
{
Locator.GetDeathManager().SetImpactDeathSpeed(impact.speed);
Locator.GetDeathManager().KillPlayer(DeathType.Impact);
@ -62,31 +62,21 @@ namespace QSB.DeathSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(HighSpeedImpactSensor), nameof(HighSpeedImpactSensor.FixedUpdate))]
public static bool HighSpeedImpactSensor_FixedUpdate(
HighSpeedImpactSensor __instance,
bool ____isPlayer,
ref bool ____dead,
ref bool ____dieNextUpdate,
OWRigidbody ____body,
ref float ____impactSpeed,
float ____sqrCheckSpeedThreshold,
RaycastHit[] ____raycastHits,
SectorDetector ____sectorDetector,
float ____radius,
Vector3 ____localOffset
HighSpeedImpactSensor __instance
)
{
if (____isPlayer && (PlayerState.IsAttached() || PlayerState.IsInsideShuttle() || PlayerState.UsingNomaiRemoteCamera()))
if (__instance._isPlayer && (PlayerState.IsAttached() || PlayerState.IsInsideShuttle() || PlayerState.UsingNomaiRemoteCamera()))
{
return false;
}
if (____dieNextUpdate && !____dead)
if (__instance._dieNextUpdate && !__instance._dead)
{
____dead = true;
____dieNextUpdate = false;
__instance._dead = true;
__instance._dieNextUpdate = false;
if (__instance.gameObject.CompareTag("Player"))
{
Locator.GetDeathManager().SetImpactDeathSpeed(____impactSpeed);
Locator.GetDeathManager().SetImpactDeathSpeed(__instance._impactSpeed);
Locator.GetDeathManager().KillPlayer(DeathType.Impact);
}
else if (__instance.gameObject.CompareTag("Ship"))
@ -95,40 +85,40 @@ namespace QSB.DeathSync.Patches
}
}
if (____isPlayer && PlayerState.IsInsideShip())
if (__instance._isPlayer && PlayerState.IsInsideShip())
{
var shipCenter = Locator.GetShipTransform().position + (Locator.GetShipTransform().up * 2f);
var distanceFromShip = Vector3.Distance(____body.GetPosition(), shipCenter);
var distanceFromShip = Vector3.Distance(__instance._body.GetPosition(), shipCenter);
if (distanceFromShip > 8f)
{
____body.SetPosition(shipCenter);
__instance._body.SetPosition(shipCenter);
}
if (!____dead)
if (!__instance._dead)
{
var a = ____body.GetVelocity() - Locator.GetShipBody().GetPointVelocity(____body.GetPosition());
if (a.sqrMagnitude > ____sqrCheckSpeedThreshold)
var a = __instance._body.GetVelocity() - Locator.GetShipBody().GetPointVelocity(__instance._body.GetPosition());
if (a.sqrMagnitude > __instance._sqrCheckSpeedThreshold)
{
____impactSpeed = a.magnitude;
____body.AddVelocityChange(-a);
__instance._impactSpeed = a.magnitude;
__instance._body.AddVelocityChange(-a);
}
}
return false;
}
var passiveReferenceFrame = ____sectorDetector.GetPassiveReferenceFrame();
if (!____dead && passiveReferenceFrame != null)
var passiveReferenceFrame = __instance._sectorDetector.GetPassiveReferenceFrame();
if (!__instance._dead && passiveReferenceFrame != null)
{
var relativeVelocity = ____body.GetVelocity() - passiveReferenceFrame.GetOWRigidBody().GetPointVelocity(____body.GetPosition());
if (relativeVelocity.sqrMagnitude > ____sqrCheckSpeedThreshold)
var relativeVelocity = __instance._body.GetVelocity() - passiveReferenceFrame.GetOWRigidBody().GetPointVelocity(__instance._body.GetPosition());
if (relativeVelocity.sqrMagnitude > __instance._sqrCheckSpeedThreshold)
{
var hitCount = Physics.RaycastNonAlloc(__instance.transform.TransformPoint(____localOffset), relativeVelocity, ____raycastHits, (relativeVelocity.magnitude * Time.deltaTime) + ____radius, OWLayerMask.physicalMask, QueryTriggerInteraction.Ignore);
var hitCount = Physics.RaycastNonAlloc(__instance.transform.TransformPoint(__instance._localOffset), relativeVelocity, __instance._raycastHits, (relativeVelocity.magnitude * Time.deltaTime) + __instance._radius, OWLayerMask.physicalMask, QueryTriggerInteraction.Ignore);
for (var i = 0; i < hitCount; i++)
{
if (____raycastHits[i].rigidbody.mass > 10f && !____raycastHits[i].rigidbody.Equals(____body.GetRigidbody()))
if (__instance._raycastHits[i].rigidbody.mass > 10f && !__instance._raycastHits[i].rigidbody.Equals(__instance._body.GetRigidbody()))
{
var owRigidbody = ____raycastHits[i].rigidbody.GetComponent<OWRigidbody>();
var owRigidbody = __instance._raycastHits[i].rigidbody.GetComponent<OWRigidbody>();
if (owRigidbody == null)
{
DebugLog.ToConsole("Rigidbody does not have attached OWRigidbody!!!", OWML.Common.MessageType.Error);
@ -136,15 +126,15 @@ namespace QSB.DeathSync.Patches
}
else
{
relativeVelocity = ____body.GetVelocity() - owRigidbody.GetPointVelocity(____body.GetPosition());
var a2 = Vector3.Project(relativeVelocity, ____raycastHits[i].normal);
if (a2.sqrMagnitude > ____sqrCheckSpeedThreshold)
relativeVelocity = __instance._body.GetVelocity() - owRigidbody.GetPointVelocity(__instance._body.GetPosition());
var a2 = Vector3.Project(relativeVelocity, __instance._raycastHits[i].normal);
if (a2.sqrMagnitude > __instance._sqrCheckSpeedThreshold)
{
____body.AddVelocityChange(-a2);
____impactSpeed = a2.magnitude;
__instance._body.AddVelocityChange(-a2);
__instance._impactSpeed = a2.magnitude;
if (!PlayerState.IsInsideTheEye())
{
____dieNextUpdate = true;
__instance._dieNextUpdate = true;
}
break;
@ -202,12 +192,12 @@ namespace QSB.DeathSync.Patches
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipDamageController), nameof(ShipDamageController.Awake))]
public static void ShipDamageController_Awake(ref bool ____exploded)
=> ____exploded = true;
public static void ShipDamageController_Awake(ShipDamageController __instance)
=> __instance._exploded = true;
[HarmonyPrefix]
[HarmonyPatch(typeof(DestructionVolume), nameof(DestructionVolume.VanishShip))]
public static bool DestructionVolume_VanishShip(DeathType ____deathType)
public static bool DestructionVolume_VanishShip(DestructionVolume __instance)
{
if (RespawnOnDeath.Instance == null)
{
@ -221,7 +211,7 @@ namespace QSB.DeathSync.Patches
if (PlayerState.IsInsideShip() || PlayerState.UsingShipComputer() || PlayerState.AtFlightConsole())
{
Locator.GetDeathManager().KillPlayer(____deathType);
Locator.GetDeathManager().KillPlayer(__instance._deathType);
}
return true;

View File

@ -12,151 +12,86 @@ namespace QSB.DeathSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(MapController), nameof(MapController.EnterMapView))]
public static bool MapController_EnterMapView(
MapController __instance,
ref bool ____isMapMode,
OWAudioSource ____audioSource,
MapMarkerManager ____mapMarkerManager,
OWCamera ____mapCamera,
OWCamera ____activeCam,
MeshRenderer ____gridRenderer,
ref Transform ____targetTransform,
ref bool ____lockedToTargetTransform,
ref Vector3 ____position,
ref float ____yaw,
ref float ____pitch,
ref float ____zoom,
ref float ____targetZoom,
ref bool ____interpPosition,
ref bool ____interpPitch,
ref bool ____interpZoom,
ref bool ____framingPlayer,
ref float ____lockTimer,
float ____defaultYawAngle,
float ____initialPitchAngle,
float ____initialZoomDist,
float ____defaultZoomDist,
float ____lockOnMoveLength,
ref float ____gridOverrideSize,
ref bool ____gridOverride,
ref float ____gridTimer,
ref float ____revealLength,
ReferenceFrame ____currentRFrame,
float ____gridLockOnLength,
ref float ____revealTimer
MapController __instance
)
{
if (____isMapMode)
if (__instance._isMapMode)
{
return false;
}
____mapMarkerManager.SetVisible(true);
__instance._mapMarkerManager.SetVisible(true);
GlobalMessenger.FireEvent("EnterMapView");
GlobalMessenger<OWCamera>.FireEvent("SwitchActiveCamera", ____mapCamera);
if (____audioSource.isPlaying)
GlobalMessenger<OWCamera>.FireEvent("SwitchActiveCamera", __instance._mapCamera);
if (__instance._audioSource.isPlaying)
{
____audioSource.Stop();
____audioSource.SetLocalVolume(1f);
____audioSource.Play();
__instance._audioSource.Stop();
__instance._audioSource.SetLocalVolume(1f);
__instance._audioSource.Play();
}
else
{
____audioSource.SetLocalVolume(1f);
____audioSource.Play();
__instance._audioSource.SetLocalVolume(1f);
__instance._audioSource.Play();
}
Locator.GetAudioMixer().MixMap();
____activeCam.enabled = false;
____mapCamera.enabled = true;
____gridRenderer.enabled = false;
____targetTransform = null;
____lockedToTargetTransform = false;
____position = RespawnOnDeath.Instance.DeathPositionWorld - Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().GetPosition();
____position.y = 0f;
____yaw = ____defaultYawAngle;
____pitch = ____initialPitchAngle;
____zoom = ____initialZoomDist;
____targetZoom = ____defaultZoomDist;
__instance._activeCam.enabled = false;
__instance._mapCamera.enabled = true;
__instance._gridRenderer.enabled = false;
__instance._targetTransform = null;
__instance._lockedToTargetTransform = false;
__instance._position = RespawnOnDeath.Instance.DeathPositionWorld - Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().GetPosition();
__instance._position.y = 0f;
__instance._yaw = __instance._defaultYawAngle;
__instance._pitch = __instance._initialPitchAngle;
__instance._zoom = __instance._initialZoomDist;
__instance._targetZoom = __instance._defaultZoomDist;
__instance.transform.rotation = Quaternion.LookRotation(-RespawnOnDeath.Instance.DeathPlayerUpVector, RespawnOnDeath.Instance.DeathPlayerForwardVector);
__instance.transform.position = RespawnOnDeath.Instance.DeathPositionWorld;
____interpPosition = true;
____interpPitch = true;
____interpZoom = true;
____framingPlayer = ____lockedToTargetTransform;
____lockTimer = ____lockOnMoveLength;
____gridOverrideSize = (____currentRFrame == null) ? 0f : ____currentRFrame.GetAutopilotArrivalDistance();
____gridOverride = ____gridOverrideSize > 0f;
____gridTimer = (!____gridOverride) ? 0f : ____gridLockOnLength;
____revealLength = 20f;
____revealTimer = 0f;
____isMapMode = true;
__instance._interpPosition = true;
__instance._interpPitch = true;
__instance._interpZoom = true;
__instance._framingPlayer = __instance._lockedToTargetTransform;
__instance._lockTimer = __instance._lockOnMoveLength;
__instance._gridOverrideSize = (__instance._currentRFrame == null) ? 0f : __instance._currentRFrame.GetAutopilotArrivalDistance();
__instance._gridOverride = __instance._gridOverrideSize > 0f;
__instance._gridTimer = (!__instance._gridOverride) ? 0f : __instance._gridLockOnLength;
__instance._revealLength = 20f;
__instance._revealTimer = 0f;
__instance._isMapMode = true;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MapController), nameof(MapController.LateUpdate))]
public static bool MapController_LateUpdate(
MapController __instance,
ref float ____observatoryRevealTwist,
ref float ____defaultPitchAngle,
ref float ____initialPitchAngle,
OWCamera ____mapCamera,
ref float ____lockTimer,
ref float ____revealTimer,
float ____lockOnMoveLength,
float ____revealLength,
ref bool ____screenPromptsVisible,
bool ____isPaused,
ScreenPrompt ____closePrompt,
ScreenPrompt ____panPrompt,
ScreenPrompt ____rotatePrompt,
ScreenPrompt ____zoomPrompt,
ref bool ____lockedToTargetTransform,
ref bool ____interpPosition,
ref bool ____interpPitch,
ref bool ____interpZoom,
OWCamera ____activeCam,
ref Vector3 ____position,
float ____panSpeed,
ref float ____zoom,
float ____maxPanDistance,
float ____yawSpeed,
ref float ____yaw,
float ____pitchSpeed,
ref float ____pitch,
float ____minPitchAngle,
float ____maxPitchAngle,
ref float ____targetZoom,
float ____minZoomDistance,
float ____maxZoomDistance,
float ____initialZoomDist,
float ____zoomSpeed,
float ____observatoryRevealDist
MapController __instance
)
{
____lockTimer = Mathf.Min(____lockTimer + Time.deltaTime, ____lockOnMoveLength);
____revealTimer = Mathf.Min(____revealTimer + Time.deltaTime, ____revealLength);
__instance._lockTimer = Mathf.Min(__instance._lockTimer + Time.deltaTime, __instance._lockOnMoveLength);
__instance._revealTimer = Mathf.Min(__instance._revealTimer + Time.deltaTime, __instance._revealLength);
var revealFraction = Mathf.Clamp01(____revealTimer / ____revealLength);
var revealFraction = Mathf.Clamp01(__instance._revealTimer / __instance._revealLength);
var smoothedRevealFraction = Mathf.SmoothStep(0f, 1f, revealFraction);
var canInteractWith = ____revealTimer > 18f;
var canInteractWith = __instance._revealTimer > 18f;
if (____screenPromptsVisible && ____isPaused)
if (__instance._screenPromptsVisible && __instance._isPaused)
{
____closePrompt.SetVisibility(false);
____panPrompt.SetVisibility(false);
____rotatePrompt.SetVisibility(false);
____zoomPrompt.SetVisibility(false);
____screenPromptsVisible = false;
__instance._closePrompt.SetVisibility(false);
__instance._panPrompt.SetVisibility(false);
__instance._rotatePrompt.SetVisibility(false);
__instance._zoomPrompt.SetVisibility(false);
__instance._screenPromptsVisible = false;
}
else if (!____screenPromptsVisible && canInteractWith && !____isPaused)
else if (!__instance._screenPromptsVisible && canInteractWith && !__instance._isPaused)
{
____closePrompt.SetVisibility(false);
____panPrompt.SetVisibility(true);
____rotatePrompt.SetVisibility(true);
____zoomPrompt.SetVisibility(true);
____screenPromptsVisible = true;
__instance._closePrompt.SetVisibility(false);
__instance._panPrompt.SetVisibility(true);
__instance._rotatePrompt.SetVisibility(true);
__instance._zoomPrompt.SetVisibility(true);
__instance._screenPromptsVisible = true;
}
var XZinput = Vector2.zero;
@ -171,54 +106,54 @@ namespace QSB.DeathSync.Patches
zoomInput *= -1f;
}
____lockedToTargetTransform &= XZinput.sqrMagnitude < 0.01f;
____interpPosition &= XZinput.sqrMagnitude < 0.01f;
____interpPitch &= Mathf.Abs(lookInput.y) < 0.1f;
____interpZoom &= Mathf.Abs(zoomInput) < 0.1f;
__instance._lockedToTargetTransform &= XZinput.sqrMagnitude < 0.01f;
__instance._interpPosition &= XZinput.sqrMagnitude < 0.01f;
__instance._interpPitch &= Mathf.Abs(lookInput.y) < 0.1f;
__instance._interpZoom &= Mathf.Abs(zoomInput) < 0.1f;
if (____interpPosition)
if (__instance._interpPosition)
{
var a = ____activeCam.transform.position - Locator.GetCenterOfTheUniverse().GetOffsetPosition();
var a = __instance._activeCam.transform.position - Locator.GetCenterOfTheUniverse().GetOffsetPosition();
var b = Vector3.zero;
____position = Vector3.Lerp(a, b, smoothedRevealFraction);
__instance._position = Vector3.Lerp(a, b, smoothedRevealFraction);
}
else
{
var normalized = Vector3.Scale(__instance.transform.forward + __instance.transform.up, new Vector3(1f, 0f, 1f)).normalized;
var a2 = (__instance.transform.right * XZinput.x) + (normalized * XZinput.y);
____position += a2 * ____panSpeed * ____zoom * Time.deltaTime;
____position.y = 0f;
if (____position.sqrMagnitude > ____maxPanDistance * ____maxPanDistance)
__instance._position += a2 * __instance._panSpeed * __instance._zoom * Time.deltaTime;
__instance._position.y = 0f;
if (__instance._position.sqrMagnitude > __instance._maxPanDistance * __instance._maxPanDistance)
{
____position = ____position.normalized * ____maxPanDistance;
__instance._position = __instance._position.normalized * __instance._maxPanDistance;
}
}
____yaw += lookInput.x * ____yawSpeed * Time.deltaTime;
____yaw = OWMath.WrapAngle(____yaw);
if (____interpPitch)
__instance._yaw += lookInput.x * __instance._yawSpeed * Time.deltaTime;
__instance._yaw = OWMath.WrapAngle(__instance._yaw);
if (__instance._interpPitch)
{
____pitch = Mathf.Lerp(____initialPitchAngle, ____defaultPitchAngle, smoothedRevealFraction);
__instance._pitch = Mathf.Lerp(__instance._initialPitchAngle, __instance._defaultPitchAngle, smoothedRevealFraction);
}
else
{
____pitch += lookInput.y * ____pitchSpeed * Time.deltaTime;
____pitch = Mathf.Clamp(____pitch, ____minPitchAngle, ____maxPitchAngle);
__instance._pitch += lookInput.y * __instance._pitchSpeed * Time.deltaTime;
__instance._pitch = Mathf.Clamp(__instance._pitch, __instance._minPitchAngle, __instance._maxPitchAngle);
}
if (____interpZoom)
if (__instance._interpZoom)
{
____zoom = Mathf.Lerp(____initialZoomDist, ____targetZoom, smoothedRevealFraction);
__instance._zoom = Mathf.Lerp(__instance._initialZoomDist, __instance._targetZoom, smoothedRevealFraction);
}
else
{
____zoom += zoomInput * ____zoomSpeed * Time.deltaTime;
____zoom = Mathf.Clamp(____zoom, ____minZoomDistance, ____maxZoomDistance);
__instance._zoom += zoomInput * __instance._zoomSpeed * Time.deltaTime;
__instance._zoom = Mathf.Clamp(__instance._zoom, __instance._minZoomDistance, __instance._maxZoomDistance);
}
____mapCamera.nearClipPlane = Mathf.Lerp(0.1f, 1f, smoothedRevealFraction);
__instance._mapCamera.nearClipPlane = Mathf.Lerp(0.1f, 1f, smoothedRevealFraction);
var finalRotation = Quaternion.Euler(____pitch, ____yaw, 0f);
var finalRotation = Quaternion.Euler(__instance._pitch, __instance._yaw, 0f);
var num4 = revealFraction * (2f - revealFraction);
@ -229,15 +164,15 @@ namespace QSB.DeathSync.Patches
// Get starting position - distance above player
var startingPosition = RespawnOnDeath.Instance.DeathPositionWorld;
startingPosition += RespawnOnDeath.Instance.DeathPlayerUpVector * num5 * ____observatoryRevealDist;
startingPosition += RespawnOnDeath.Instance.DeathPlayerUpVector * num5 * __instance._observatoryRevealDist;
// Lerp to final rotation
__instance.transform.rotation = Quaternion.Lerp(lookingDownAtPlayer, finalRotation, num5);
// Lerp reveal twist
__instance.transform.rotation *= Quaternion.AngleAxis(Mathf.Lerp(____observatoryRevealTwist, 0f, num4), Vector3.forward);
__instance.transform.rotation *= Quaternion.AngleAxis(Mathf.Lerp(__instance._observatoryRevealTwist, 0f, num4), Vector3.forward);
var endPosition = ____position + (-__instance.transform.forward * ____zoom) + Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().GetPosition();
var endPosition = __instance._position + (-__instance.transform.forward * __instance._zoom) + Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().GetPosition();
// Lerp to final position
__instance.transform.position = Vector3.Lerp(startingPosition, endPosition, num5);

View File

@ -29,9 +29,9 @@ namespace QSB.ItemSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.SocketItem))]
public static bool ItemTool_SocketItem(OWItem ____heldItem, OWItemSocket socket)
public static bool ItemTool_SocketItem(ItemTool __instance, OWItemSocket socket)
{
var qsbObj = ____heldItem.GetWorldObject<IQSBOWItem>();
var qsbObj = __instance._heldItem.GetWorldObject<IQSBOWItem>();
var socketId = socket.GetWorldObject<IQSBOWItemSocket>().ObjectId;
var itemId = qsbObj.ObjectId;
QSBPlayerManager.LocalPlayer.HeldItem = null;
@ -52,18 +52,18 @@ namespace QSB.ItemSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.CompleteUnsocketItem))]
public static bool ItemTool_CompleteUnsocketItem(OWItem ____heldItem)
public static bool ItemTool_CompleteUnsocketItem(ItemTool __instance)
{
var itemId = ____heldItem.GetWorldObject<IQSBOWItem>().ObjectId;
var itemId = __instance._heldItem.GetWorldObject<IQSBOWItem>().ObjectId;
new SocketItemMessage(SocketMessageType.CompleteUnsocket, itemId: itemId).Send();
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ItemTool), nameof(ItemTool.DropItem))]
public static bool ItemTool_DropItem(RaycastHit hit, OWRigidbody targetRigidbody, IItemDropTarget customDropTarget, ref OWItem ____heldItem)
public static bool ItemTool_DropItem(ItemTool __instance, RaycastHit hit, OWRigidbody targetRigidbody, IItemDropTarget customDropTarget)
{
Locator.GetPlayerAudioController().PlayDropItem(____heldItem.GetItemType());
Locator.GetPlayerAudioController().PlayDropItem(__instance._heldItem.GetItemType());
var hitGameObject = hit.collider.gameObject;
var gameObject2 = hitGameObject;
var sectorGroup = gameObject2.GetComponent<ISectorGroup>();
@ -90,9 +90,9 @@ namespace QSB.ItemSync.Patches
var parent = (customDropTarget == null)
? targetRigidbody.transform
: customDropTarget.GetItemDropTargetTransform(hit.collider.gameObject);
var qsbItem = ____heldItem.GetWorldObject<IQSBOWItem>();
____heldItem.DropItem(hit.point, hit.normal, parent, sector, customDropTarget);
____heldItem = null;
var qsbItem = __instance._heldItem.GetWorldObject<IQSBOWItem>();
__instance._heldItem.DropItem(hit.point, hit.normal, parent, sector, customDropTarget);
__instance._heldItem = null;
QSBPlayerManager.LocalPlayer.HeldItem = null;
Locator.GetToolModeSwapper().UnequipTool();
var parentSector = parent.GetComponentInChildren<Sector>();

View File

@ -44,11 +44,11 @@ namespace QSB.QuantumSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(RendererVisibilityTracker), nameof(RendererVisibilityTracker.IsVisibleUsingCameraFrustum))]
public static bool RendererVisibilityTracker_IsVisibleUsingCameraFrustum(RendererVisibilityTracker __instance, ref bool __result, Renderer ____renderer, bool ____checkFrustumOcclusion)
public static bool RendererVisibilityTracker_IsVisibleUsingCameraFrustum(RendererVisibilityTracker __instance, ref bool __result)
{
__result = QSBPlayerManager.GetPlayersWithCameras()
.Any(x => GeometryUtility.TestPlanesAABB(x.Camera.GetFrustumPlanes(), ____renderer.bounds))
&& (!____checkFrustumOcclusion || QSBPlayerManager.GetPlayersWithCameras()
.Any(x => GeometryUtility.TestPlanesAABB(x.Camera.GetFrustumPlanes(), __instance._renderer.bounds))
&& (!__instance._checkFrustumOcclusion || QSBPlayerManager.GetPlayersWithCameras()
.Any(x => !__instance.IsOccludedFromPosition(x.Camera.transform.position)));
return false;
}
@ -57,50 +57,50 @@ namespace QSB.QuantumSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(VisibilityObject), nameof(VisibilityObject.CheckIllumination))]
public static bool VisibilityObject_CheckIllumination(VisibilityObject __instance, ref bool __result, bool ____checkIllumination, Vector3 ____localIlluminationOffset, float ____illuminationRadius, Light[] ____lightSources)
public static bool VisibilityObject_CheckIllumination(VisibilityObject __instance, ref bool __result)
{
if (!____checkIllumination)
if (!__instance._checkIllumination)
{
__result = true;
return false;
}
var point = __instance.transform.TransformPoint(____localIlluminationOffset);
var point = __instance.transform.TransformPoint(__instance._localIlluminationOffset);
var tupleFlashlights = QSBPlayerManager.GetPlayerFlashlights();
var localFlashlight = tupleFlashlights.Item1;
var playerFlashlights = tupleFlashlights.Item2;
// local player flashlight
if (localFlashlight.CheckIlluminationAtPoint(point, ____illuminationRadius))
if (localFlashlight.CheckIlluminationAtPoint(point, __instance._illuminationRadius))
{
__result = true;
return false;
}
// all other player flashlights
if (playerFlashlights.Any(x => x.CheckIlluminationAtPoint(point, ____illuminationRadius)))
if (playerFlashlights.Any(x => x.CheckIlluminationAtPoint(point, __instance._illuminationRadius)))
{
__result = true;
return false;
}
// BUG : Implement checking for other probes!
if (Locator.GetProbe() != null && Locator.GetProbe().IsLaunched() && Locator.GetProbe().CheckIlluminationAtPoint(point, ____illuminationRadius))
if (Locator.GetProbe() != null && Locator.GetProbe().IsLaunched() && Locator.GetProbe().CheckIlluminationAtPoint(point, __instance._illuminationRadius))
{
__result = true;
return false;
}
// BUG : Implement checking for other player's thrusters!
if (Locator.GetThrusterLightTracker().CheckIlluminationAtPoint(point, ____illuminationRadius))
if (Locator.GetThrusterLightTracker().CheckIlluminationAtPoint(point, __instance._illuminationRadius))
{
__result = true;
return false;
}
if (____lightSources != null)
if (__instance._lightSources != null)
{
foreach (var light in ____lightSources)
foreach (var light in __instance._lightSources)
{
if (light.intensity > 0f && light.range > 0f)
{

View File

@ -22,19 +22,16 @@ namespace QSB.RoastingSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(Marshmallow), nameof(Marshmallow.Burn))]
public static bool Marshmallow_Burn(
ref Marshmallow.MallowState ____mallowState,
MeshRenderer ____fireRenderer,
ref float ____toastedFraction,
ref float ____initBurnTime,
PlayerAudioController ____audioController)
Marshmallow __instance
)
{
if (____mallowState == Marshmallow.MallowState.Default)
if (__instance._mallowState == Marshmallow.MallowState.Default)
{
____fireRenderer.enabled = true;
____toastedFraction = 1f;
____initBurnTime = Time.time;
____mallowState = Marshmallow.MallowState.Burning;
____audioController.PlayMarshmallowCatchFire();
__instance._fireRenderer.enabled = true;
__instance._toastedFraction = 1f;
__instance._initBurnTime = Time.time;
__instance._mallowState = Marshmallow.MallowState.Burning;
__instance._audioController.PlayMarshmallowCatchFire();
new MarshmallowEventMessage(MarshmallowMessageType.Burn).Send();
}
@ -44,13 +41,13 @@ namespace QSB.RoastingSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(Marshmallow), nameof(Marshmallow.Shrivel))]
public static bool Marshmallow_Shrivel(
ref Marshmallow.MallowState ____mallowState,
ref float ____initShrivelTime)
Marshmallow __instance
)
{
if (____mallowState == Marshmallow.MallowState.Burning)
if (__instance._mallowState == Marshmallow.MallowState.Burning)
{
____initShrivelTime = Time.time;
____mallowState = Marshmallow.MallowState.Shriveling;
__instance._initShrivelTime = Time.time;
__instance._mallowState = Marshmallow.MallowState.Shriveling;
new MarshmallowEventMessage(MarshmallowMessageType.Shrivel).Send();
}
@ -60,16 +57,12 @@ namespace QSB.RoastingSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(Marshmallow), nameof(Marshmallow.RemoveMallow))]
public static bool Marshmallow_RemoveMallow(
ParticleSystem ____smokeParticles,
MeshRenderer ____fireRenderer,
MeshRenderer ____mallowRenderer,
ref Marshmallow.MallowState ____mallowState,
Marshmallow __instance)
{
____smokeParticles.Stop();
____fireRenderer.enabled = false;
____mallowRenderer.enabled = false;
____mallowState = Marshmallow.MallowState.Gone;
__instance._smokeParticles.Stop();
__instance._fireRenderer.enabled = false;
__instance._mallowRenderer.enabled = false;
__instance._mallowState = Marshmallow.MallowState.Gone;
__instance.enabled = false;
new MarshmallowEventMessage(MarshmallowMessageType.Remove).Send();
return false;
@ -78,82 +71,75 @@ namespace QSB.RoastingSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(RoastingStickController), nameof(RoastingStickController.UpdateMarshmallowInput))]
public static bool RoastingStickController_UpdateMarshmallowInput(
float ____extendFraction,
Marshmallow ____marshmallow,
GameObject ____mallowBodyPrefab,
Transform ____stickTransform,
Campfire ____campfire,
ref string ____promptText,
ScreenPrompt ____mallowPrompt,
ref bool ____showMallowPrompt,
ref bool ____showRemovePrompt)
RoastingStickController __instance
)
{
var changePromptText = false;
var showRemovePrompt = false;
var text = string.Empty;
if (____extendFraction == 0f)
if (__instance._extendFraction == 0f)
{
if (____marshmallow.IsEdible())
if (__instance._marshmallow.IsEdible())
{
text = UITextLibrary.GetString(UITextType.RoastingEatPrompt);
changePromptText = true;
if (____marshmallow.IsBurned())
if (__instance._marshmallow.IsBurned())
{
showRemovePrompt = true;
if (OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.Roasting))
{
____marshmallow.Remove();
__instance._marshmallow.Remove();
Locator.GetPlayerAudioController().PlayMarshmallowToss();
var spawnedMarshmallow = Object.Instantiate(____mallowBodyPrefab, ____stickTransform.position, ____stickTransform.rotation);
var spawnedMarshmallow = Object.Instantiate(__instance._mallowBodyPrefab, __instance._stickTransform.position, __instance._stickTransform.rotation);
var rigidbody = spawnedMarshmallow.GetComponent<OWRigidbody>();
rigidbody.SetVelocity(____campfire.GetAttachedOWRigidbody().GetPointVelocity(____stickTransform.position) + ____stickTransform.forward * 3f);
rigidbody.SetAngularVelocity(____stickTransform.right * 10f);
var burntColor = ____marshmallow.GetBurntColor();
rigidbody.SetVelocity(__instance._campfire.GetAttachedOWRigidbody().GetPointVelocity(__instance._stickTransform.position) + __instance._stickTransform.forward * 3f);
rigidbody.SetAngularVelocity(__instance._stickTransform.right * 10f);
var burntColor = __instance._marshmallow.GetBurntColor();
spawnedMarshmallow.GetComponentInChildren<MeshRenderer>().material.color = burntColor;
new MarshmallowEventMessage(MarshmallowMessageType.Toss).Send();
}
}
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting) && ____marshmallow.IsEdible())
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting) && __instance._marshmallow.IsEdible())
{
____marshmallow.Eat();
__instance._marshmallow.Eat();
}
}
else if (____marshmallow.GetState() == Marshmallow.MallowState.Burning)
else if (__instance._marshmallow.GetState() == Marshmallow.MallowState.Burning)
{
text = UITextLibrary.GetString(UITextType.RoastingExtinguishPrompt);
changePromptText = true;
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting))
{
____marshmallow.Extinguish();
__instance._marshmallow.Extinguish();
new MarshmallowEventMessage(MarshmallowMessageType.Extinguish).Send();
}
}
else if (____marshmallow.GetState() == Marshmallow.MallowState.Gone)
else if (__instance._marshmallow.GetState() == Marshmallow.MallowState.Gone)
{
text = UITextLibrary.GetString(UITextType.RoastingReplacePrompt);
changePromptText = true;
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.Roasting))
{
____marshmallow.SpawnMallow(true);
__instance._marshmallow.SpawnMallow(true);
}
}
if (changePromptText && ____promptText != text)
if (changePromptText && __instance._promptText != text)
{
____promptText = text;
____mallowPrompt.SetText(____promptText);
__instance._promptText = text;
__instance._mallowPrompt.SetText(__instance._promptText);
}
if (OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.Roasting))
{
____campfire.StopRoasting();
__instance._campfire.StopRoasting();
return false;
}
}
____showMallowPrompt = changePromptText;
____showRemovePrompt = showRemovePrompt;
__instance._showMallowPrompt = changePromptText;
__instance._showRemovePrompt = showRemovePrompt;
return false;
}

View File

@ -147,53 +147,53 @@ namespace QSB.ShipSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipHull), nameof(ShipHull.FixedUpdate))]
public static bool ShipHull_FixedUpdate(ShipHull __instance, ref ImpactData ____dominantImpact, ref float ____integrity, ref bool ____damaged, DamageEffect ____damageEffect, ShipComponent[] ____components)
public static bool ShipHull_FixedUpdate(ShipHull __instance)
{
if (____dominantImpact != null)
if (__instance._dominantImpact != null)
{
var damage = Mathf.InverseLerp(30f, 200f, ____dominantImpact.speed);
var damage = Mathf.InverseLerp(30f, 200f, __instance._dominantImpact.speed);
if (damage > 0f)
{
var num2 = 0.15f;
if (damage < num2 && ____integrity > 1f - num2)
if (damage < num2 && __instance._integrity > 1f - num2)
{
damage = num2;
}
____integrity = Mathf.Max(____integrity - damage, 0f);
__instance._integrity = Mathf.Max(__instance._integrity - damage, 0f);
var qsbShipHull = __instance.GetWorldObject<QSBShipHull>();
if (!____damaged)
if (!__instance._damaged)
{
____damaged = true;
__instance._damaged = true;
__instance.RaiseEvent(nameof(__instance.OnDamaged), __instance);
qsbShipHull
.SendMessage(new HullDamagedMessage());
}
if (____damageEffect != null)
if (__instance._damageEffect != null)
{
____damageEffect.SetEffectBlend(1f - ____integrity);
__instance._damageEffect.SetEffectBlend(1f - __instance._integrity);
}
qsbShipHull
.SendMessage(new HullChangeIntegrityMessage(____integrity));
.SendMessage(new HullChangeIntegrityMessage(__instance._integrity));
}
foreach (var component in ____components)
foreach (var component in __instance._components)
{
if (!(component == null) && !component.isDamaged)
{
if (component.ApplyImpact(____dominantImpact))
if (component.ApplyImpact(__instance._dominantImpact))
{
break;
}
}
}
__instance.RaiseEvent(nameof(__instance.OnImpact), ____dominantImpact, damage);
__instance.RaiseEvent(nameof(__instance.OnImpact), __instance._dominantImpact, damage);
____dominantImpact = null;
__instance._dominantImpact = null;
}
__instance.enabled = false;
@ -213,29 +213,29 @@ namespace QSB.ShipSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipHull), nameof(ShipHull.RepairTick))]
public static bool ShipHull_RepairTick(ShipHull __instance, ref float ____integrity, ref bool ____damaged, DamageEffect ____damageEffect, float ____repairTime)
public static bool ShipHull_RepairTick(ShipHull __instance)
{
if (!____damaged)
if (!__instance._damaged)
{
return false;
}
____integrity = Mathf.Min(____integrity + (Time.deltaTime / ____repairTime), 1f);
__instance._integrity = Mathf.Min(__instance._integrity + (Time.deltaTime / __instance._repairTime), 1f);
var qsbShipHull = __instance.GetWorldObject<QSBShipHull>();
qsbShipHull
.SendMessage(new HullRepairTickMessage(____integrity));
.SendMessage(new HullRepairTickMessage(__instance._integrity));
if (____integrity >= 1f)
if (__instance._integrity >= 1f)
{
____damaged = false;
__instance._damaged = false;
__instance.RaiseEvent(nameof(__instance.OnRepaired), __instance);
qsbShipHull
.SendMessage(new HullRepairedMessage());
}
if (____damageEffect != null)
if (__instance._damageEffect != null)
{
____damageEffect.SetEffectBlend(1f - ____integrity);
__instance._damageEffect.SetEffectBlend(1f - __instance._integrity);
}
return false;

View File

@ -14,14 +14,14 @@ namespace QSB.StatueSync.Patches
[HarmonyPrefix]
[HarmonyPatch(typeof(MemoryUplinkTrigger), nameof(MemoryUplinkTrigger.Update))]
public static bool MemoryUplinkTrigger_Update(bool ____waitForPlayerGrounded)
public static bool MemoryUplinkTrigger_Update(MemoryUplinkTrigger __instance)
{
if (StatueManager.Instance.HasStartedStatueLocally)
{
return true;
}
if (!____waitForPlayerGrounded || !Locator.GetPlayerController().IsGrounded())
if (!__instance._waitForPlayerGrounded || !Locator.GetPlayerController().IsGrounded())
{
return true;
}

View File

@ -6,7 +6,6 @@ using QSB.Tools.ProbeLauncherTool.Messages;
using QSB.Tools.ProbeLauncherTool.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.Tools.ProbeLauncherTool.Patches
{
@ -20,37 +19,30 @@ namespace QSB.Tools.ProbeLauncherTool.Patches
public static bool ProbeLauncher_RetrieveProbe(
ProbeLauncher __instance,
bool playEffects,
bool forcedRetrieval,
ref bool ____isRetrieving,
SurveyorProbe ____activeProbe,
NotificationTarget ____notificationFilter,
GameObject ____preLaunchProbeProxy,
ProbeLauncherEffects ____effects,
SingularityWarpEffect ____probeRetrievalEffect,
float ____probeRetrievalLength)
bool forcedRetrieval)
{
if (____isRetrieving)
if (__instance._isRetrieving)
{
return false;
}
if (____activeProbe != null)
if (__instance._activeProbe != null)
{
if (____activeProbe.IsLaunched() && TimelineObliterationController.IsParadoxProbeActive() && !forcedRetrieval)
if (__instance._activeProbe.IsLaunched() && TimelineObliterationController.IsParadoxProbeActive() && !forcedRetrieval)
{
var data = new NotificationData(____notificationFilter, UITextLibrary.GetString(UITextType.NotificationMultProbe), 3f);
var data = new NotificationData(__instance._notificationFilter, UITextLibrary.GetString(UITextType.NotificationMultProbe), 3f);
NotificationManager.SharedInstance.PostNotification(data);
Locator.GetPlayerAudioController().PlayNegativeUISound();
return false;
}
____activeProbe.GetRotatingCamera().ResetRotation();
____preLaunchProbeProxy.SetActive(true);
__instance._activeProbe.GetRotatingCamera().ResetRotation();
__instance._preLaunchProbeProxy.SetActive(true);
if (playEffects)
{
____effects.PlayRetrievalClip();
____probeRetrievalEffect.WarpObjectIn(____probeRetrievalLength);
__instance._effects.PlayRetrievalClip();
__instance._probeRetrievalEffect.WarpObjectIn(__instance._probeRetrievalLength);
}
if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher)
@ -63,8 +55,8 @@ namespace QSB.Tools.ProbeLauncherTool.Patches
new PlayerRetrieveProbeMessage(playEffects).Send();
}
____activeProbe.Retrieve(____probeRetrievalLength);
____isRetrieving = true;
__instance._activeProbe.Retrieve(__instance._probeRetrievalLength);
__instance._isRetrieving = true;
}
return false;

View File

@ -12,12 +12,12 @@ namespace QSB.Tools.SignalscopeTool.FrequencySync.Patches
[HarmonyPostfix]
[HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.IdentifyFrequency))]
public static void IdentifyFrequencyEvent(SignalFrequency ____frequency)
=> new IdentifyFrequencyMessage(____frequency).Send();
public static void IdentifyFrequencyEvent(AudioSignal __instance)
=> new IdentifyFrequencyMessage(__instance._frequency).Send();
[HarmonyPostfix]
[HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.IdentifySignal))]
public static void IdentifySignalEvent(SignalName ____name)
=> new IdentifySignalMessage(____name).Send();
public static void IdentifySignalEvent(AudioSignal __instance)
=> new IdentifySignalMessage(__instance._name).Send();
}
}