示例#1
0
        private static bool HandleFixedGateSwitch(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event)
            {
            case ItemEventType.Interact:

                if (!Instance.CheckUserRights(Session))
                {
                    return(true);
                }

                List <Vector2> GateTiles = Instance.CalculateAffectedTiles(Item, Item.RoomPosition.GetVector2(), Item.RoomRotation);

                foreach (Vector2 Tile in GateTiles)
                {
                    if (Instance.GetActorsOnPosition(Tile).Count > 0)
                    {
                        return(true);
                    }
                }

                int CurrentState = 0;
                int.TryParse(Item.Flags, out CurrentState);

                Item.Flags        = (CurrentState == 0 ? 1 : 0).ToString();
                Item.DisplayFlags = Item.Flags;

                RoomManager.MarkWriteback(Item, true);

                Item.BroadcastStateUpdate(Instance);
                Instance.RegenerateRelativeHeightmap();
                break;
            }

            return(true);
        }