public virtual void ServerPerformInteraction(HandActivate interaction) { if (CurrentMagazine != null && allowMagazineRemoval && !MagInternal) { RequestUnload(CurrentMagazine); } }
/// <summary> /// Check if item has an interaction with a an item in a slot /// If not or if bool returned is true, swap items /// </summary> public void TryItemInteract(bool swapIfEmpty = true) { var slotName = itemSlot.SlotIdentifier.NamedSlot; // Clicked on another slot other than our own hands if (itemSlot != UIManager.Hands.LeftHand.ItemSlot && itemSlot != UIManager.Hands.RightHand.itemSlot) { // If full, attempt to interact the two, otherwise swap if (Item != null) { //check IF2 InventoryApply interaction - combine the active hand item with this (only if //both are occupied) if (TryIF2InventoryApply()) { return; } if (swapIfEmpty) { UIManager.Hands.SwapItem(this); } return; } else { if (swapIfEmpty) { UIManager.Hands.SwapItem(this); } return; } } // If there is an item and the hand is interacting in the same slot if (Item != null && UIManager.Hands.CurrentSlot.ItemSlot == itemSlot) { //check IF2 logic first var interactables = Item.GetComponents <IBaseInteractable <HandActivate> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); var activate = HandActivate.ByLocalPlayer(); InteractionUtils.ClientCheckAndTrigger(interactables, activate); } else { if (UIManager.Hands.CurrentSlot.ItemSlot != itemSlot) { //Clicked on item with otherslot selected if (UIManager.Hands.OtherSlot.Item != null) { if (TryIF2InventoryApply()) { return; } if (swapIfEmpty) { UIManager.Hands.SwapItem(this); } } } } }
public void ServerPerformInteraction(HandActivate interaction) { Chat.AddExamineMsgFromServer(interaction.Performer, "You Clear internal buffer"); ListBuffer.Clear(); MultiMaster = false; ConfigurationBuffer = MultitoolConnectionType.Empty; }
public void ServerPerformInteraction(HandActivate interaction) { Chat.AddExamineMsgFromServer(interaction.Performer, "You clear the multitool's internal buffer."); buffers.Clear(); isMultipleMaster = false; configurationBuffer = MultitoolConnectionType.Empty; }
//For pressing Z to place the object on the tile you're on. public void ServerPerformInteraction(HandActivate interaction) { // Spawns object at player's position. Spawn.ServerPrefab(prefabVariant, interaction.PerformerPlayerScript.WorldPos); // Remove the used item from the player's inventory Inventory.ServerDespawn(interaction.HandSlot); }
public bool WillInteract(HandActivate interaction, NetworkSide side) { if (!DefaultWillInteract.Default(interaction, side)) { return(false); } return(true); }
private void BuildGirder(HandActivate interaction, Vector3 position) { PoolManager.PoolNetworkInstantiate(girderPrefab, position); isBuilding = false; var slot = InventoryManager.GetSlotFromOriginatorHand(interaction.Performer, interaction.HandSlot.equipSlot); GetComponent <Pickupable>().DisappearObject(slot); GetComponent <CustomNetTransform>().DisappearFromWorldServer(); }
/// <summary> /// For most cases you should use InteractionMessageUtils.SendRequest() instead of this. /// /// Sends a request to the server to validate + perform the interaction. /// </summary> /// <param name="handActivate">info on the interaction being performed. Each object involved in the interaction /// must have a networkidentity.</param> /// <param name="processorObject">object who has a component implementing IInteractionProcessor<Activate> which /// will process the interaction on the server-side. This object must have a NetworkIdentity and there must only be one instance /// of this component on the object. For organization, we suggest that the component which is sending this message /// should be on the processorObject, as such this parameter should almost always be passed using "this.gameObject", and /// should almost always be either a component on the target object or a component on the used object</param> public static void Send(HandActivate handActivate, GameObject processorObject) { var msg = new RequestHandActivateMessage { ProcessorObject = processorObject.GetComponent <NetworkIdentity>().netId }; msg.Send(); }
public override bool WillInteract(HandActivate interaction, NetworkSide side) { if (base.WillInteract(interaction, side) == false) { return(false); } // If charges remain, return false to allow the HasNetworkTabItem component to take over. return(!HasCharges); }
/// <summary> /// Check if item has an interaction with a an item in a slot /// If not or if bool returned is true, swap items /// </summary> public void TryItemInteract() { // Clicked on another slot other than hands if (equipSlot != EquipSlot.leftHand && equipSlot != EquipSlot.rightHand) { // If full, attempt to interact the two, otherwise swap if (Item != null) { //check IF2 InventoryApply interaction - combine the active hand item with this (only if //both are occupied) if (TryIF2InventoryApply()) { return; } UIManager.Hands.SwapItem(this); return; } else { UIManager.Hands.SwapItem(this); return; } } // If there is an item and the hand is interacting in the same slot if (Item != null && UIManager.Hands.CurrentSlot.equipSlot == equipSlot) { //check IF2 logic first var interactables = Item.GetComponents <IInteractable <HandActivate> >() .Where(mb => mb != null && (mb as MonoBehaviour).enabled); var activate = HandActivate.ByLocalPlayer(); foreach (var interactable in interactables) { if (interactable.Interact(activate)) { return; } } } else { if (UIManager.Hands.CurrentSlot.equipSlot != equipSlot) { //Clicked on item with otherslot selected if (UIManager.Hands.OtherSlot.Item != null) { if (TryIF2InventoryApply()) { return; } UIManager.Hands.SwapItem(this); } } } }
public bool Interact(HandActivate interaction) { //try ejecting the mag if external if (CurrentMagazine != null && !MagInternal && CanRemovableMag) { RequestUnload(CurrentMagazine); return(true); } return(false); }
public bool Interact(HandActivate interaction) { //try ejecting the mag if (CurrentMagazine != null) { RequestUnload(CurrentMagazine); return(true); } return(false); }
public virtual bool Interact(HandActivate interaction) { //try ejecting the mag if external if (CurrentMagazine != null && allowMagazineRemoval && !MagInternal) { RequestUnload(CurrentMagazine); return(true); } return(false); }
public bool Interact(HandActivate interaction) { if (isCan && capRemoved == false) { Chat.AddExamineMsgToClient("Need to remove the cap first"); return(false); } UIManager.Instance.CrayonUI.openingObject = gameObject; UIManager.Instance.CrayonUI.SetActive(true); return(true); }
public void ServerInteract(HandActivate interaction) { if (countFiremode - 1 == currentFiremode) { currentFiremode = 0; } else { currentFiremode += 1; } UpdateFiremode(); }
protected override void ServerPerformInteraction(HandActivate interaction) { if (safety) { safety = false; spriteSync = 1; } else { safety = true; spriteSync = 0; } }
private void ProcessActivate(GameObject activatedObject, GameObject processorObj, GameObject performerObj, HandSlot handSlot) { //try to look up the components on the processor that can handle this interaction var processorComponents = InteractionMessageUtils.TryGetProcessors <HandActivate>(processorObj); //invoke each component that can handle this interaction var activate = HandActivate.ByClient(performerObj, activatedObject, handSlot); foreach (var processorComponent in processorComponents) { if (processorComponent.ServerProcessInteraction(activate)) { //something happened, don't check further components return; } } }
public void ServerPerformInteraction(HandActivate interaction) { if (onCooldown) { Chat.AddExamineMsg(interaction.Performer, $"The {gameObject.ExpensiveName()} is still charging!"); return; } if (isReady == false) { Chat.AddExamineMsg(interaction.Performer, $"You prepare the {gameObject.ExpensiveName()}"); isReady = true; _ = SoundManager.PlayNetworkedAtPosAsync(soundReady, gameObject.AssumedWorldPosServer()); return; } Chat.AddExamineMsg(interaction.Performer, $"<color=green>The {gameObject.ExpensiveName()} is charged and ready to be used.</color>"); }
public override bool Interact(HandActivate interaction) { if (countFiremode == 1) { return(false); } if (countFiremode - 1 == currentFiremode) { currentFiremode = 0; } else { currentFiremode += 1; } UpdateFiremode(); return(true); }
public virtual bool WillInteract(HandActivate interaction, NetworkSide side) { if (DefaultWillInteract.Default(interaction, side) == false) { return(false); } if (side == NetworkSide.Server && DefaultWillInteract.Default(interaction, side)) { return(true); } //try ejecting the mag if external if (CurrentMagazine != null && allowMagazineRemoval && !MagInternal && side == NetworkSide.Client) { return(true); } return(false); }
private void startBuilding(HandActivate interaction) { if (!isBuilding) { var position = interaction.Performer.transform.position; var progressFinishAction = new FinishProgressAction( reason => { if (reason == FinishProgressAction.FinishReason.INTERRUPTED) { CancelBuild(); } else if (reason == FinishProgressAction.FinishReason.COMPLETED) { BuildGirder(interaction, position); } } ); isBuilding = true; UIManager.ProgressBar.StartProgress(position.RoundToInt(), 5f, progressFinishAction, interaction.Performer); } }
public virtual void ServerPerformInteraction(HandActivate interaction) { rotatable.Rotate(); }
protected override void ServerPerformInteraction(HandActivate interaction) { StartCoroutine(TimeExplode(interaction.Performer)); }
/// <summary> /// Default WillInteract logic for Activate /// </summary> public static bool HandActivate(HandActivate interaction, NetworkSide side) { return(Validations.CanInteract(interaction.Performer, side)); }
public virtual bool WillInteract(HandActivate interaction, NetworkSide side) { return(DefaultWillInteract.Default(interaction, side)); }
protected override void ServerPerformInteraction(HandActivate interaction) { startBuilding(interaction); }
public virtual void ServerPerformInteraction(HandActivate interaction) { RotatePipe(); }
protected override void ServerPerformInteraction(HandActivate interaction) { SoundManager.PlayNetworkedAtPos(soundToggle, interaction.Performer.transform.position); ToggleState(); }
protected override void ClientPredictInteraction(HandActivate interaction) { ToggleState(); }
public override void Process() { var performer = SentByPlayer.GameObject; if (SentByPlayer == null || SentByPlayer.Script == null || SentByPlayer.Script.ItemStorage == null) { return; } if (InteractionType == typeof(PositionalHandApply)) { //look up item in active hand slot var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot, Intent, TargetBodyPart); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject }); var targetObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; var interaction = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot, Intent, IsAltUsed); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(AimApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; var interaction = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState, Intent); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(MouseDrop)) { LoadMultipleObjects(new uint[] { UsedObject, TargetObject, ProcessorObject }); var usedObj = NetworkObjects[0]; var targetObj = NetworkObjects[1]; var processorObj = NetworkObjects[2]; var interaction = MouseDrop.ByClient(performer, usedObj, targetObj, Intent); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(HandActivate)) { LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; var performerObj = SentByPlayer.GameObject; //look up item in active hand slot var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; var interaction = HandActivate.ByClient(performer, usedObject, usedSlot, Intent); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(InventoryApply)) { LoadMultipleObjects(new uint[] { ProcessorObject, UsedObject, Storage }); var processorObj = NetworkObjects[0]; var usedObj = NetworkObjects[1]; var storageObj = NetworkObjects[2]; ItemSlot targetSlot = null; if (SlotIndex == -1) { targetSlot = ItemSlot.GetNamed(storageObj.GetComponent <ItemStorage>(), NamedSlot); } else { targetSlot = ItemSlot.GetIndexed(storageObj.GetComponent <ItemStorage>(), SlotIndex); } //if used object is null, then empty hand was used ItemSlot fromSlot = null; if (usedObj == null) { fromSlot = SentByPlayer.Script.ItemStorage.GetActiveHandSlot(); } else { fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot; } var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot, Intent, IsAltUsed); ProcessInteraction(interaction, processorObj); } else if (InteractionType == typeof(TileApply)) { var clientStorage = SentByPlayer.Script.ItemStorage; var usedSlot = clientStorage.GetActiveHandSlot(); var usedObject = clientStorage.GetActiveHandSlot().ItemObject; LoadNetworkObject(ProcessorObject); var processorObj = NetworkObject; processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex, SentByPlayer.GameObject, TargetVector, processorObj, usedSlot, usedObject, Intent, TileApply.ApplyType.HandApply); } else if (InteractionType == typeof(TileMouseDrop)) { LoadMultipleObjects(new uint[] { UsedObject, ProcessorObject }); var usedObj = NetworkObjects[0]; var processorObj = NetworkObjects[1]; processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(TileInteractionIndex, SentByPlayer.GameObject, TargetVector, processorObj, null, usedObj, Intent, TileApply.ApplyType.MouseDrop); } }