コード例 #1
0
ファイル: WiredSaver.cs プロジェクト: habb0/Bfly
        internal static void HandleConditionSave(uint itemID, Room room, ClientMessage clientMessage)
        {
            RoomItem item = room.GetRoomItemHandler().GetItem(itemID);
            if (item == null)
                return;

            if (item.wiredHandler != null)
            {
                item.wiredHandler.Dispose();
                item.wiredHandler = null;
            }

            InteractionType type = item.GetBaseItem().InteractionType;

            if (type != InteractionType.conditionfurnishaveusers && type != InteractionType.conditionstatepos &&
                type != InteractionType.conditiontimelessthan && type != InteractionType.conditiontimemorethan &&
                type != InteractionType.conditiontriggeronfurni)
                return;

            clientMessage.AdvancePointer(1);
            bool a = clientMessage.PopWiredBoolean();
            bool b = clientMessage.PopWiredBoolean();
            bool c = clientMessage.PopWiredBoolean();
            clientMessage.AdvancePointer(2);

            int furniCount;
            List<RoomItem> items = GetItems(clientMessage, room, out furniCount);

            IWiredCondition handler = null;

            switch (type)
            {
                case InteractionType.conditionfurnishaveusers:
                    {
                        handler = new FurniHasUser(item, items);
                        break;
                    }
                case InteractionType.conditionstatepos:
                    {
                        handler = new FurniStatePosMatch(item, items);
                        break;
                    }

                case InteractionType.conditiontimelessthan:
                    {
                        handler = new LessThanTimer(500, room, item);
                        break;
                    }

                case InteractionType.conditiontimemorethan:
                    {
                        handler = new MoreThanTimer(500, room, item);
                        break;
                    }

                case InteractionType.conditiontriggeronfurni:
                    {
                        handler = new TriggerUserIsOnFurni(item, items);
                        break;
                    }

                default:
                    return;
            }

            item.wiredCondition = handler;
            room.GetWiredHandler().conditionHandler.AddOrIgnoreRefferance(item);

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                handler.SaveToDatabase(dbClient);
            }
        }
コード例 #2
0
ファイル: WiredLoader.cs プロジェクト: BjkGkh/R106
        internal static void LoadWiredItem(RoomItem item, Room room, IQueryAdapter dbClient)
        {
            InteractionType type = item.GetBaseItem().InteractionType;
            WiredLoaderObject wiredData = WiredLoaderObject.LoadItem(item, room, dbClient);
            
            switch (type)
            {
                case InteractionType.actiongivescore:
                    {
                        IWiredTrigger action = new GiveScore(0, 0, room.GetGameManager(), item, room.GetWiredHandler());
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionmoverotate:
                    {
                        IWiredTrigger action = new MoveRotate(MovementState.none, RotationState.none,new List<RoomItem>(), 0, room, room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionposreset:
                    {
                        IWiredTrigger action = new PositionReset(new List<RoomItem>(), 0, room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionresettimer:
                    {
                        IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), new List<RoomItem>(), 0, item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionshowmessage:
                    {
                        IWiredTrigger action = new ShowMessage(string.Empty, room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionteleportto:
                    {
                        IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), new List<RoomItem>(), 0, item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actiontogglestate:
                    {
                        IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), new List<RoomItem>(), 0, item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.actionkick:
                    {
                        IWiredTrigger action = new Kick(string.Empty, room.GetWiredHandler(), item);
                        action.LoadFromWiredObject(wiredData);
                        HandleItemLoad(action, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.conditionfurnishaveusers:
                    {
                        IWiredCondition furniHasUsers = new FurniHasUser(item, new List<RoomItem>(), room.GetWiredHandler());
                        furniHasUsers.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(furniHasUsers, item);
                        break;
                    }

                case InteractionType.conditionhasfurnionfurni:
                    {
                        IWiredCondition furniHasUsers = new FurniHasFurni(item, new List<RoomItem>(), room.GetWiredHandler(), false);
                        furniHasUsers.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(furniHasUsers, item);
                        break;
                    }
                case InteractionType.conditionstatepos:
                    {
                        IWiredCondition furnistatepos = new FurniStatePosMatch(item, new List<RoomItem>(), room.GetWiredHandler(),false,false,false);
                        furnistatepos.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(furnistatepos, item);
                        break;
                    }

                case InteractionType.conditiontimelessthan:
                    {
                        IWiredCondition timeLessThan = new LessThanTimer(0, room, item, room.GetWiredHandler());
                        timeLessThan.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(timeLessThan, item);
                        break;
                    }

                case InteractionType.conditiontimemorethan:
                    {
                        IWiredCondition timeMoreThan = new MoreThanTimer(0, room, item, room.GetWiredHandler());
                        timeMoreThan.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(timeMoreThan, item);
                        break;
                    }

                case InteractionType.conditiontriggeronfurni:
                    {
                        IWiredCondition triggerOnFurni = new TriggerUserIsOnFurni(item, new List<RoomItem>(), room.GetWiredHandler());
                        triggerOnFurni.LoadFromWiredObject(wiredData);
                        HandleConditionLoad(triggerOnFurni, item);
                        break;
                    }

                case InteractionType.specialrandom:
                    {

                        break;
                    }

                case InteractionType.specialunseen:
                    {

                        break;
                    }

                case InteractionType.triggergameend:
                    {
                        IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggergamestart:
                    {
                        IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager());
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggeronusersay:
                    {
                        IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), false, string.Empty, room);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerrepeater:
                    {
                        IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerroomenter:
                    {
                        IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), false, string.Empty);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerscoreachieved:
                    {
                        IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), 0, room.GetGameManager());
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggertimer:
                    {
                        IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), 0, room.GetGameManager());
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerstatechanged:
                    {
                        IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, new List<RoomItem>(), 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerwalkofffurni:
                    {
                        IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), new List<RoomItem>(), 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }

                case InteractionType.triggerwalkonfurni:
                    {
                        IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), new List<RoomItem>(), 0);
                        handler.LoadFromWiredObject(wiredData);
                        HandleItemLoad(handler, room.GetWiredHandler(), item);
                        break;
                    }
            }

        }
コード例 #3
0
ファイル: WiredSaver.cs プロジェクト: BjkGkh/R106
        internal static void HandleConditionSave(uint itemID, Room room, ClientMessage clientMessage)
        {
            RoomItem item = room.GetRoomItemHandler().GetItem(itemID);
            if (item == null)
                return;

            if (item.wiredHandler != null)
            {
                item.wiredHandler.Dispose();
                item.wiredHandler = null;
            }

            InteractionType type = item.GetBaseItem().InteractionType;

            if (type != InteractionType.conditionfurnishaveusers && type != InteractionType.conditionstatepos &&
                type != InteractionType.conditiontimelessthan && type != InteractionType.conditiontimemorethan &&
                type != InteractionType.conditiontriggeronfurni && type != InteractionType.conditionhasfurnionfurni)
                return;

            int amountOfBooleanSettings = clientMessage.ReadInt();

            if (amountOfBooleanSettings > 3)
                return;

            int[] booleans = new int[amountOfBooleanSettings];
            for (int i = 0; i < amountOfBooleanSettings; i++)
            {
                booleans[i] = clientMessage.ReadInt();
            }

            string someString = clientMessage.ReadString();

            List<RoomItem> items = null;
            if (ConditionPacketBuilder.NeedsFurni(type))
            {
                items = GetItems(clientMessage, room);
            }
            else
            {
                items = new List<RoomItem>();
            }
            //int furniCount;


            IWiredCondition handler = null;

            switch (type)
            {
                case InteractionType.conditionfurnishaveusers:
                    {
                        handler = new FurniHasUser(item, items, room.GetWiredHandler());
                        break;
                    }
                case InteractionType.conditionstatepos:
                    {
                        handler = new FurniStatePosMatch(item, items, room.GetWiredHandler(), booleans[0] == 1, booleans[1] == 1, booleans[2] == 1);
                        break;
                    }

                case InteractionType.conditiontimelessthan:
                    {
                        handler = new LessThanTimer(500, room, item, room.GetWiredHandler());
                        break;
                    }

                case InteractionType.conditiontimemorethan:
                    {
                        handler = new MoreThanTimer(500, room, item, room.GetWiredHandler());
                        break;
                    }

                case InteractionType.conditiontriggeronfurni:
                    {
                        handler = new TriggerUserIsOnFurni(item, items, room.GetWiredHandler());
                        break;
                    }
                case InteractionType.conditionhasfurnionfurni:
                    {
                        handler = new FurniHasFurni(item, items, room.GetWiredHandler(), booleans[0] == 1);
                        break;
                    }

                default:
                    return;
            }

            item.wiredCondition = handler;
            room.GetWiredHandler().conditionHandler.AddOrIgnoreRefferance(item);

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                WiredSaverHandler.UpdateInDatabase(handler, dbClient);
            }


        }