public override void Interact(GameObject originator, Vector3 position, string hand) { if (!isServer) { UI_ItemSlot slot = UIManager.Hands.CurrentSlot; // Client pre-approval if (slot.CanPlaceItem()) { //Client informs server of interaction attempt InteractMessage.Send(gameObject, position, slot.eventName); //Client simulation // var placedOk = slot.PlaceItem(gameObject.transform.position); // if ( !placedOk ) // { // Logger.Log("Client placing error"); // } } } else { //Server actions if (!ValidateTableInteraction(originator, position, hand)) { //Rollback prediction here // originator.GetComponent<PlayerNetworkActions>().RollbackPrediction(hand); } } }
/// Throw mode toggle. Actual throw is in /// <see cref="InputController.CheckThrow()"/> public void Throw() { PlayerScript lps = PlayerManager.LocalPlayerScript; UI_ItemSlot currentSlot = UIManager.Hands.CurrentSlot; if (!lps || lps.canNotInteract() || !currentSlot.CanPlaceItem()) { UIManager.IsThrow = false; throwImage.sprite = throwSprites[0]; return; } SoundManager.Play("Click01"); // Logger.Log("Throw Button"); if (!UIManager.IsThrow) { UIManager.IsThrow = true; throwImage.sprite = throwSprites[1]; } else { UIManager.IsThrow = false; throwImage.sprite = throwSprites[0]; } }
public override void ClientAction() { UI_ItemSlot slot = UIManager.Hands.CurrentSlot; // Client pre-approval if (slot.CanPlaceItem()) { InteractMessage.Send(gameObject, position, slot.eventName); } }
public override void Interact(GameObject originator, Vector3 position, string hand) { if (!isServer) { UI_ItemSlot slot = UIManager.Hands.CurrentSlot; // Client pre-approval if (!microwave.Cooking && slot.CanPlaceItem()) { //Client informs server of interaction attempt InteractMessage.Send(gameObject, position, slot.eventName); } } else { ValidateMicrowaveInteraction(originator, position, hand); } }
/// <summary> /// Perform the drop action /// </summary> public void Drop() { PlayerScript lps = PlayerManager.LocalPlayerScript; if (!lps || lps.canNotInteract()) { return; } UI_ItemSlot currentSlot = UIManager.Hands.CurrentSlot; // Vector3 dropPos = lps.gameObject.transform.position; if (!currentSlot.CanPlaceItem()) { return; } // if ( isNotMovingClient(lps) ) // { // // Full client simulation(standing still) // var placedOk = currentSlot.PlaceItem(dropPos); // if ( !placedOk ) // { // Logger.Log("Client dropping error"); // } // } // else // { //Only clear slot(while moving, as prediction is shit in this situation) // GameObject dropObj = currentSlot.Item; // CustomNetTransform cnt = dropObj.GetComponent<CustomNetTransform>(); // It is converted to LocalPos in transformstate struct // cnt.AppearAtPosition(PlayerManager.LocalPlayer.transform.position); // } //Message if (UIManager.IsThrow == true) { Throw(); // Disable throw } UIManager.CheckStorageHandlerOnMove(currentSlot.Item); //forceClientInform = true because we aren't doing prediction any more. lps.playerNetworkActions.RequestDropItem(currentSlot.inventorySlot.UUID, true); SoundManager.Play("Click01"); Logger.Log("Drop Button", Category.UI); }
public void Drop() { PlayerScript lps = PlayerManager.LocalPlayerScript; if (!lps || lps.canNotInteract()) { return; } UI_ItemSlot currentSlot = UIManager.Hands.CurrentSlot; // Vector3 dropPos = lps.gameObject.transform.position; if (!currentSlot.CanPlaceItem()) { return; } // if ( isNotMovingClient(lps) ) // { // // Full client simulation(standing still) // var placedOk = currentSlot.PlaceItem(dropPos); // if ( !placedOk ) // { // Logger.Log("Client dropping error"); // } // } // else // { //Only clear slot(while moving, as prediction is shit in this situation) // GameObject dropObj = currentSlot.Item; // CustomNetTransform cnt = dropObj.GetComponent<CustomNetTransform>(); // It is converted to LocalPos in transformstate struct // cnt.AppearAtPosition(PlayerManager.LocalPlayer.transform.position); currentSlot.Clear(); // } //Message lps.playerNetworkActions.RequestDropItem(currentSlot.eventName, false); SoundManager.Play("Click01"); Logger.Log("Drop Button", Category.UI); }
/// Throw mode toggle. Actual throw is in /// <see cref="InputController.CheckThrow()"/> public void Throw(bool forceDisable = false) { if (forceDisable) { Debug.Log("Force disable"); UIManager.IsThrow = false; throwImage.sprite = throwSprites[0]; return; } // See if requesting to enable or disable throw (for keyDown or keyUp) if (throwImage.sprite == throwSprites[0] && UIManager.IsThrow == false) { PlayerScript lps = PlayerManager.LocalPlayerScript; UI_ItemSlot currentSlot = UIManager.Hands.CurrentSlot; // Check if player can throw if (!lps || lps.canNotInteract() || !currentSlot.CanPlaceItem()) { UIManager.IsThrow = false; throwImage.sprite = throwSprites[0]; return; } // Enable throw Logger.Log("Throw Button Enabled", Category.UI); SoundManager.Play("Click01"); UIManager.IsThrow = true; throwImage.sprite = throwSprites[1]; } else if (throwImage.sprite == throwSprites[1] && UIManager.IsThrow == true) { // Disable throw Logger.Log("Throw Button Disabled", Category.UI); UIManager.IsThrow = false; throwImage.sprite = throwSprites[0]; } }