Exemplo n.º 1
0
            public static bool Interact(Humanoid human, bool hold, PrivateArea __instance, ref bool __result)
            {
                // if using the original interaction behavior then just return true and run the original code
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.Original)
                {
                    return(true);
                }

                // default to a false just in case.
                __result = false;

                Plugin.Log("Patched Interact");

                // if not allowing permitted players to activate/deactivate, just run the standard function
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerOnly)
                {
                    return(true);
                }

                if (hold)
                {
                    Plugin.Log("HOLDING");
                    __result = false;

                    //don't execute.. what's the point?
                    return(false);
                }
                Player player = human as Player;

                // If player is creator
                // or if ward mode is ownerandpermitted and is permitted or behavior is all AND modifier key is not being held....
                if (__instance.m_piece.IsCreator()
                    ||
                    ((Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerAndPermitted && __instance.IsPermitted(player.GetPlayerID()) || (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.All)) &&
                     !UtilityClass.CheckKeyHeld(Settings.InteractModifier.Value))
                    )
                {
                    __instance.m_nview.InvokeRPC("ToggleEnabled", player.GetPlayerID());
                    __result = true;

                    // don't execute the original code
                    return(false);
                }
                Plugin.Log("Wasn't normal activation");

                // if OwnerOnly then don't allow anyone to do anything else
                if (Settings.WardInteractBehavior.Value == Plugin.WardInteractBehavior.OwnerOnly)
                {
                    __result = false;
                    return(false);
                }

                // if the player is using the modifier key and gets this far, then toggle permitted
                // can only do this when the peice isn't active
                if (UtilityClass.CheckKeyHeld(Settings.InteractModifier.Value) && !__instance.IsEnabled())
                {
                    __instance.m_nview.InvokeRPC("TogglePermitted", player.GetPlayerID(), player.GetPlayerName());
                    __result = true;

                    // don't execute original code
                    return(false);
                }

                __result = false;
                return(false);
            }
Exemplo n.º 2
0
        private static bool DropItem(Inventory inventory, ItemDrop.ItemData item, int amount, Humanoid __instance, ref bool __result)
        {
            // return and run the original if disabled or if this is not the player
            if (!Settings.MMDropItemUsingCameraDirection.Value || !__instance.IsPlayer())
            {
                return(true);
            }

            // run the original code if the player has chosen to use Character Facing modifier and the modifier key is being held
            if (Settings.DropModifierBehavior.Value == Plugin.DropModifierBehavior.CharacterFacing && UtilityClass.CheckKeyHeld(Settings.DropModifierKey.Value))
            {
                return(true);
            }

            // run the original code if the player has chosen to use Camera Facing modifier and the modifier key is NOT being held
            if (Settings.DropModifierBehavior.Value == Plugin.DropModifierBehavior.CameraDirection && !UtilityClass.CheckKeyHeld(Settings.DropModifierKey.Value))
            {
                return(true);
            }

            // run the updated code...
            if (amount == 0)
            {
                __result = false;
                return(false);
            }
            if (item.m_shared.m_questItem)
            {
                __instance.Message(MessageHud.MessageType.Center, "$msg_cantdrop");
                __result = false;
                return(false);
            }
            if (amount > item.m_stack)
            {
                amount = item.m_stack;
            }
            __instance.RemoveFromEquipQueue(item);
            __instance.UnequipItem(item, triggerEquipEffects: false);
            if (__instance.m_hiddenLeftItem == item)
            {
                __instance.m_hiddenLeftItem = null;
                __instance.SetupVisEquipment(__instance.m_visEquipment, isRagdoll: false);
            }
            if (__instance.m_hiddenRightItem == item)
            {
                __instance.m_hiddenRightItem = null;
                __instance.SetupVisEquipment(__instance.m_visEquipment, isRagdoll: false);
            }
            if (amount == item.m_stack)
            {
                ZLog.Log((object)("drop all " + amount + "  " + item.m_stack));
                Plugin.LogVerbose("drop all " + amount + "  " + item.m_stack);
                if (!inventory.RemoveItem(item))
                {
                    ZLog.Log((object)"Was not removed");
                    __result = false;
                    return(false);
                }
            }
            else
            {
                ZLog.Log((object)("drop some " + amount + "  " + item.m_stack));
                Plugin.Log("drop some " + amount + "  " + item.m_stack);
                inventory.RemoveItem(item, amount);
            }

            //our change to support dropping on camera direction
            ItemDrop itemDrop;

            Plugin.Log($"Drop by player... using camera rotation");
            itemDrop = ItemDrop.DropItem(item, amount, (__instance as Character).transform.position + GameCamera.instance.transform.forward + GameCamera.instance.transform.up, GameCamera.instance.transform.rotation);
            itemDrop.OnPlayerDrop();
            itemDrop.GetComponent <Rigidbody>().velocity = (GameCamera.instance.transform.forward + Vector3.up) * 5f;

            //end our change..

            __instance.m_zanim.SetTrigger("interact");
            __instance.m_dropEffects.Create((__instance as Character).transform.position, Quaternion.identity);
            __instance.Message(MessageHud.MessageType.TopLeft, "$msg_dropped " + itemDrop.m_itemData.m_shared.m_name, itemDrop.m_itemData.m_stack, itemDrop.m_itemData.GetIcon());
            __result = true;
            return(false);
        }