public static bool Prefix(DockedVehicleHandTarget __instance, GUIHand hand) { vehicleDockingBay = __instance.dockingBay; Vehicle vehicle = vehicleDockingBay.GetDockedVehicle(); if (skipPrefix || vehicle == null) { return(true); } dockedVehicle = __instance; guiHand = hand; SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); NitroxId id = NitroxEntity.GetId(vehicle.gameObject); if (simulationOwnership.HasExclusiveLock(id)) { Log.Debug($"Already have an exclusive lock on this vehicle: {id}"); return(true); } simulationOwnership.RequestSimulationLock(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse); return(false); }
public static bool Prefix(DockedVehicleHandTarget __instance, GUIHand hand) { Vehicle vehicle = __instance.dockingBay.GetDockedVehicle(); if (skipPrefix || vehicle == null) { return(true); } SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); NitroxId id = NitroxEntity.GetId(vehicle.gameObject); if (simulationOwnership.HasExclusiveLock(id)) { Log.Debug($"Already have an exclusive lock on this vehicle: {id}"); return(true); } HandInteraction <DockedVehicleHandTarget> context = new HandInteraction <DockedVehicleHandTarget>(__instance, hand); LockRequest <HandInteraction <DockedVehicleHandTarget> > lockRequest = new LockRequest <HandInteraction <DockedVehicleHandTarget> >(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); simulationOwnership.RequestSimulationLock(lockRequest); return(false); }
public static bool Prefix(ref DockedVehicleHandTarget __instance, GUIHand hand) { #if SUBNAUTICA_STABLE Vehicle dockedVehicle = __instance.dockingBay.GetDockedVehicle(); #elif BELOWZERO #endif if (!(dockedVehicle != null)) { HandReticle.main.SetInteractInfo("NoVehicleDocked"); return(false); } bool crushDanger = false; CrushDamage crushDamage = dockedVehicle.crushDamage; if (crushDamage != null) { float crushDepth = crushDamage.crushDepth; if (Ocean.main.GetDepthOf(Player.main.gameObject) > crushDepth) { crushDanger = true; } } string text = (dockedVehicle is Exosuit) ? "EnterExosuit" : "EnterSeamoth"; bool result; string prompt = ""; string vehicleName = dockedVehicle.GetName(); result = Main.TryGetVehiclePrompt(text, Language.main.GetCurrentLanguage(), dockedVehicle.GetName(), out prompt); //Logger.Log(Logger.Level.Debug, $"DockedVehicleHandTarget_OnHandHover_Patch.Prefix(): with docked vehicle {vehicleName}, called OnHandHover with text {text}; Main.TryGetVehiclePrompt({text}) returned prompt '{prompt}'", null, true); if (result) { text = prompt; } if (crushDanger) { HandReticle.main.SetInteractText(text, "DockedVehicleDepthWarning"); return(false); } EnergyMixin component = dockedVehicle.GetComponent <EnergyMixin>(); LiveMixin liveMixin = dockedVehicle.liveMixin; if (component.charge < component.capacity) { string format = Language.main.GetFormat <float, float>("VehicleStatusFormat", liveMixin.GetHealthFraction(), component.GetEnergyScalar()); HandReticle.main.SetInteractText(text, format, true, false, HandReticle.Hand.Left); } else { string format2 = Language.main.GetFormat <float>("VehicleStatusChargedFormat", liveMixin.GetHealthFraction()); HandReticle.main.SetInteractText(text, format2, true, false, HandReticle.Hand.Left); } HandReticle.main.SetIcon(HandReticle.IconType.Hand, 1f); return(false); }