public override bool Interact(HandInteraction getHandInteractionState, IHands hands) { switch (getHandInteractionState) { case HandInteraction.NoHands: return(false); case HandInteraction.Left: if (_hands < 2) { hands.GrabWithLeftHand(this); } break; case HandInteraction.Right: if (_hands < 2) { hands.GrabWithRightHand(this); } break; case HandInteraction.Both: hands.GrabWithBothHands(this); break; default: throw new ArgumentOutOfRangeException(nameof(getHandInteractionState), getHandInteractionState, null); } return(true); }
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(PilotingChair __instance, GUIHand hand) { if (skipPrefix) { return(true); } SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); SubRoot subRoot = __instance.GetComponentInParent <SubRoot>(); Validate.NotNull(subRoot, "PilotingChair cannot find it's corresponding SubRoot!"); NitroxId id = NitroxEntity.GetId(subRoot.gameObject); if (simulationOwnership.HasExclusiveLock(id)) { Log.Debug($"Already have an exclusive lock on the piloting chair: {id}"); return(true); } HandInteraction <PilotingChair> context = new HandInteraction <PilotingChair>(__instance, hand); LockRequest <HandInteraction <PilotingChair> > lockRequest = new LockRequest <HandInteraction <PilotingChair> >(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); simulationOwnership.RequestSimulationLock(lockRequest); return(false); }
public override bool Interact(HandInteraction getHandInteractionState, IHands hands) { _isOpen = !_isOpen; _animator.SetBool(isOpen, _isOpen); return(true); }
private void PickUp(HandInteraction getHandInteractionState, IHands hands, Pickup pickup) { if (getHandInteractionState == HandInteraction.Left) { hands.GrabWithLeftHand(pickup); } if (getHandInteractionState == HandInteraction.Right || getHandInteractionState == HandInteraction.Both) { hands.GrabWithRightHand(pickup); } }
public override bool Interact(HandInteraction getHandInteractionState, IHands hands) { if (_isOpen && _content.Count > 0) { var pickup = _content[0]; _content.RemoveAt(0); var contentInstance = Instantiate(pickup, transform); PickUp(getHandInteractionState, hands, contentInstance); } else { _isOpen = !_isOpen; } _animator.SetBool(isOpen, _isOpen); return(true); }
public static bool Prefix(Incubator __instance, GUIHand hand) { if (skipPrefix) { return(true); } // Request a simulation lock on the incubator so that we can authoritatively spawn the resulting creatures if (__instance.powered && !__instance.hatched && Inventory.main.container.Contains(TechType.HatchingEnzymes)) { SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); // the server only knows about the the main incubator platform which is the direct parent GameObject platform = __instance.gameObject.transform.parent.gameObject; NitroxId id = NitroxEntity.GetId(platform); HandInteraction <Incubator> context = new HandInteraction <Incubator>(__instance, hand); LockRequest <HandInteraction <Incubator> > lockRequest = new LockRequest <HandInteraction <Incubator> >(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); simulationOwnership.RequestSimulationLock(lockRequest); } return(false); }
public static bool Prefix(Bench __instance, GUIHand hand) { if (skipPrefix) { return(true); } SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>(); NitroxId id = NitroxEntity.GetId(__instance.gameObject); if (simulationOwnership.HasExclusiveLock(id)) { Log.Debug($"Already have an exclusive lock on the bench/chair: {id}"); return(true); } HandInteraction <Bench> context = new HandInteraction <Bench>(__instance, hand); LockRequest <HandInteraction <Bench> > lockRequest = new LockRequest <HandInteraction <Bench> >(id, SimulationLockType.EXCLUSIVE, ReceivedSimulationLockResponse, context); simulationOwnership.RequestSimulationLock(lockRequest); return(false); }
private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, HandInteraction <Bench> context) { Bench bench = context.Target; if (lockAquired) { skipPrefix = true; bench.OnHandClick(context.GuiHand); localPlayer.AnimationChange(AnimChangeType.BENCH, AnimChangeState.ON); skipPrefix = false; } else { bench.gameObject.AddComponent <DenyOwnershipHand>(); bench.isValidHandTarget = false; } }
private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, HandInteraction <Vehicle> context) { Vehicle vehicle = context.Target; if (lockAquired) { skipPrefix = true; vehicle.OnHandClick(context.GuiHand); skipPrefix = false; } else { vehicle.gameObject.AddComponent <DenyOwnershipHand>(); vehicle.isValidHandTarget = false; } }
private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, HandInteraction <DockedVehicleHandTarget> context) { if (lockAquired) { VehicleDockingBay dockingBay = context.Target.dockingBay; NitroxServiceLocator.LocateService <Vehicles>().BroadcastVehicleUndocking(dockingBay, dockingBay.GetDockedVehicle(), true); skipPrefix = true; context.Target.OnHandClick(context.GuiHand); skipPrefix = false; } else { HandReticle.main.SetInteractText("Another player is using this vehicle!"); HandReticle.main.SetIcon(HandReticle.IconType.HandDeny, 1f); context.Target.isValidHandTarget = false; } }
private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, HandInteraction <PilotingChair> context) { PilotingChair pilotingChair = context.Target; if (lockAquired) { skipPrefix = true; TARGET_METHOD.Invoke(pilotingChair, new[] { context.GuiHand }); skipPrefix = false; } else { pilotingChair.gameObject.AddComponent <DenyOwnershipHand>(); pilotingChair.isValidHandTarget = false; } }
private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, HandInteraction <Incubator> context) { if (lockAquired) { IncubatorMetadata metadata = new IncubatorMetadata(true, true); Entities entities = NitroxServiceLocator.LocateService <Entities>(); entities.BroadcastMetadataUpdate(id, metadata); skipPrefix = true; TARGET_METHOD.Invoke(context.Target, new[] { context.GuiHand }); skipPrefix = false; } else { context.Target.gameObject.AddComponent <DenyOwnershipHand>(); } }
private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, HandInteraction <Bench> context) { Bench bench = context.Target; if (lockAquired) { skipPrefix = true; TARGET_METHOD.Invoke(bench, new[] { context.GuiHand }); skipPrefix = false; } else { bench.gameObject.AddComponent <DenyOwnershipHand>(); bench.isValidHandTarget = false; } }
void Start() { _rb = GetComponent <Rigidbody2D>(); _interaction = GetComponentInChildren <HandInteraction>(); }
void Awake() { handInteraction = GameObject.Find("Player").GetComponent<HandInteraction>(); }
public virtual bool Interact(HandInteraction getHandInteractionState, IHands hands) { return(false); }
void Awake() { handInteraction = GameObject.Find("Player").GetComponent <HandInteraction>(); }