public static bool Prefix(PropulsionCannon __instance, GameObject target) { if (skipPrefixPatch) { return(true); } SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); NitroxId id = NitroxEntity.GetId(target); if (simulationOwnership.HasExclusiveLock(id)) { Log.Debug($"Already have an exclusive lock on the grabbed propulsion cannon object: {id}"); return(true); } PropulsionGrab context = new PropulsionGrab(__instance, target); LockRequest <PropulsionGrab> lockRequest = new LockRequest <PropulsionGrab>(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); simulationOwnership.RequestSimulationLock(lockRequest); return(false); }
private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, PropulsionGrab context) { if (lockAquired) { EntityPositionBroadcaster.WatchEntity(id, context.GrabbedObject); skipPrefixPatch = true; context.Cannon.GrabObject(context.GrabbedObject); skipPrefixPatch = false; } else { context.GrabbedObject.AddComponent <DenyOwnershipHand>(); } }