Пример #1
0
        internal static void HandleSave(GameClient Session, uint itemID, Room room, ClientMessage clientMessage)
        {
            if (room == null || room.GetRoomItemHandler() == null)
            {
                return;
            }

            var item = room.GetRoomItemHandler().GetItem(itemID);

            if (item == null)
            {
                return;
            }

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

            InteractorGenericSwitch.DoAnimation(item);

            var type = item.GetBaseItem().InteractionType;

            switch (type)
            {
                #region Causantes
            case InteractionType.triggeronusersay:
            {
                var junk        = clientMessage.PopWiredInt32();
                var isOnlyOwner = (clientMessage.PopWiredInt32() == 1);
                var message     = clientMessage.PopFixedString();

                IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), isOnlyOwner, message, room);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerwalkonfurni:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);

                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerwalkofffurni:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);

                IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

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

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

            case InteractionType.triggertimer:
            {
                var junk   = clientMessage.PopWiredInt32();
                var cycles = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerrepeater:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerroomenter:
            {
                var junk  = clientMessage.PopWiredInt32();
                var users = clientMessage.PopFixedString();

                IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerscoreachieved:
            {
                var junk  = clientMessage.PopWiredInt32();
                var score = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerstatechanged:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();

                int furniAmount;
                var items = GetItems(clientMessage, room, out furniAmount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, items);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggercollision:
            {
                IWiredTrigger handler = new Collision(item, room.GetWiredHandler(), room.GetRoomUserManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.triggerlongperiodic:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new LongRepeater(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerbotreachedavtr:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botname = clientMessage.PopFixedString();

                IWiredTrigger handler = new BotAlcanzaUsuario(item, room.GetWiredHandler(), room.GetRoomUserManager(), botname);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.triggerbotreachedstf:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botname = clientMessage.PopFixedString();

                int furniAmount;
                var items = GetItems(clientMessage, room, out furniAmount);

                IWiredTrigger handler = new BotAlcanzaFurni(item, room.GetWiredHandler(), room.GetRoomUserManager(), items, botname);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }
                #endregion

                #region Efectos
            case InteractionType.actiongivescore:
            {
                var junk   = clientMessage.PopWiredInt32();
                var points = clientMessage.PopWiredInt32();
                var games  = clientMessage.PopWiredInt32();

                IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionposreset:
            {
                var junk = clientMessage.PopWiredInt32();

                var state     = clientMessage.PopWiredInt32();
                var direction = clientMessage.PopWiredInt32();
                var position  = clientMessage.PopWiredInt32();

                var junk3 = clientMessage.PopFixedString();

                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new PositionReset(items, delay, state + "," + direction + "," + position, new Dictionary <uint, OriginalItemLocation>(), room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionresettimer:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionshowmessage:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());

                if (BlackWordsManager.Check(message, BlackWordType.Hotel, Session, "<WiredMensaje>"))
                {
                    message = "Mensaje bloqueado por el filtro bobba.";
                }

                IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionhandiitemcustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new HandiCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números.");
                }
                break;
            }

            case InteractionType.actioneffectcustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new EffectCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números.");
                }
                break;
            }

            case InteractionType.actiondiamantescustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new DiamantesCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                    break;
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números e hífen (-).");
                }
                break;
            }

            case InteractionType.actiondancecustom:
            {
                var  junk    = clientMessage.PopWiredInt32();
                var  message = OtanixEnvironment.FilterInjectionChars(clientMessage.PopFixedString());
                int  valorInteiro;
                bool inteiroCustom = int.TryParse(message, out valorInteiro);

                if (inteiroCustom)
                {
                    IWiredTrigger action = new DanceCustom(message, room.GetWiredHandler(), item);
                    HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                }
                else
                {
                    RoomUser usuario = room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
                    usuario.WhisperComposer("Você não pode colocar letras neste wired, apenas números.");
                }
                break;
            }

            case InteractionType.actionfastwalk:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new FastWalkCustom(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionfreezecustom:
            {
                var junk       = clientMessage.PopWiredInt32();
                var cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new FreezeCustom(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actionteleportto:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actiontogglestate:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new ToggleItemState(room.GetWiredHandler(), items, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmoverotate:
            {
                var junk     = clientMessage.PopWiredInt32();
                var movement = (MovementState)clientMessage.PopWiredInt32();
                var rotation = (RotationState)clientMessage.PopWiredInt32();

                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();
                var items = GetItems(clientMessage, room, out int furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), item);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actiongivereward:
            {
                if (!Session.GetHabbo().HasFuse("fuse_wired_rewards"))
                {
                    Session.SendNotif("No tienes permitido usar este Wired.");
                    break;
                }

                var junk      = clientMessage.PopWiredInt32();
                var often     = clientMessage.PopWiredInt32();
                var unique    = clientMessage.PopWiredInt32();
                var limite    = clientMessage.PopWiredInt32();
                var nInt      = clientMessage.PopWiredInt32();
                var extrainfo = clientMessage.PopFixedString();

                #region Posible Bug?
                if (extrainfo.Contains(";"))
                {
                    foreach (var s in extrainfo.Split(';'))
                    {
                        if (s.StartsWith("1"))
                        {
                            string value = s.Split(',')[1];
                            if (!value.StartsWith("diamonds:") && !value.StartsWith("alert:"))
                            {
                                try { int.Parse(value); }
                                catch { Session.SendNotif("Has intentado poner un item inválido. Recuerda que debes poner el item_id."); return; }
                            }
                        }
                    }
                }
                else
                {
                    if (extrainfo.StartsWith("1"))
                    {
                        string value = extrainfo.Split(',')[1];
                        if (!value.StartsWith("diamonds:") && !value.StartsWith("alert:"))
                        {
                            try { int.Parse(value); }
                            catch { Session.SendNotif("Has intentado poner un item inválido. Recuerda que debes poner el item_id."); return; }
                        }
                    }
                }
                #endregion

                OtanixEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Username, "", "WiredReward", "Wired Id: " + item.Id + ", RoomId: " + item.RoomId + ".");

                IWiredTrigger action = new GiveReward(extrainfo, limite, often, unique, nInt, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionchase:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new Chase(items, delay, room, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionkickuser:
            {
                var junk    = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();

                IWiredTrigger action = new KickUser(message, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionescape:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new Escape(items, delay, room, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionjointoteam:
            {
                var junk   = clientMessage.PopWiredInt32();
                var teamid = (Team)clientMessage.PopWiredInt32();

                IWiredTrigger action = new JoinToTeam(room.GetWiredHandler(), item, teamid);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionleaveteam:
            {
                IWiredTrigger action = new LeaveTeam(room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actiongiveteamscore:
            {
                var junk   = clientMessage.PopWiredInt32();
                var points = clientMessage.PopWiredInt32();
                var games  = clientMessage.PopWiredInt32();
                var teamid = (Team)clientMessage.PopWiredInt32();

                IWiredTrigger action = new GiveTeamScore(games, points, teamid, room.GetGameManager(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);

                break;
            }

            case InteractionType.actioncallstacks:
            {
                var junk  = clientMessage.PopWiredInt32();
                var junk2 = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new CallStacks(items, room, room.GetWiredHandler(), item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmovetodir:
            {
                var junk     = clientMessage.PopWiredInt32();
                var movement = (MovementDirection)clientMessage.PopWiredInt32();
                var rotation = (WhenMovementBlock)clientMessage.PopWiredInt32();

                var junk3 = clientMessage.PopWiredBoolean();
                var junk2 = clientMessage.PopWiredBoolean();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new MoveToDir(items, movement, rotation, room, room.GetWiredHandler(), item);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotmove:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botName = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotMove(item.Id, room, room.GetWiredHandler(), botName, items, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotwhisper:
            {
                var    junk          = clientMessage.PopWiredInt32();
                bool   talkorwhisper = clientMessage.PopWiredInt32() == 1;
                string message       = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);

                IWiredTrigger action = new BotTalkToUser(item.Id, room, room.GetWiredHandler(), message, talkorwhisper);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotteleport:
            {
                var junk    = clientMessage.PopWiredInt32();
                var botName = clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotTeleport(item.Id, room, room.GetWiredHandler(), botName, items, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotclothes:
            {
                int    junk    = clientMessage.PopWiredInt32();
                string message = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotChangeLook(item.Id, room, room.GetWiredHandler(), message, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbottalk:
            {
                var    junk        = clientMessage.PopWiredInt32();
                bool   talkorshout = clientMessage.PopWiredInt32() == 1;
                string message     = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotTalkToAll(item.Id, room, room.GetWiredHandler(), message, talkorshout, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbothanditem:
            {
                var    junk     = clientMessage.PopWiredInt32();
                int    handitem = clientMessage.PopWiredInt32();
                string botname  = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotGiveHandItem(item.Id, room, room.GetWiredHandler(), botname, handitem, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionbotfollowavt:
            {
                var    junk         = clientMessage.PopWiredInt32();
                bool   followorstop = clientMessage.PopWiredInt32() == 1;
                string botname      = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new BotFollowUser(item.Id, room, room.GetWiredHandler(), botname, followorstop, delay);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmutetriggerer:
            {
                var    junk      = clientMessage.PopWiredInt32();
                uint   mutetimer = clientMessage.PopWiredUInt();
                string botname   = clientMessage.PopFixedString();
                int    furniCount;
                var    items = GetItems(clientMessage, room, out furniCount);
                var    delay = clientMessage.PopWiredUInt();

                IWiredTrigger action = new MuteTriggerer(room.GetWiredHandler(), botname, mutetimer, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }

            case InteractionType.actionmovetofurni:
            {
                var junk      = clientMessage.PopWiredInt32();
                int direction = clientMessage.PopWiredInt32();
                int length    = clientMessage.PopWiredInt32();
                clientMessage.PopFixedString();
                int furniCount;
                var items = GetItems(clientMessage, room, out furniCount);
                var delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new MoveToFurni(room.GetWiredHandler(), items, length, direction, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, item);
                break;
            }
                #endregion
            }
            Session.SendMessage(new ServerMessage(Outgoing.SaveWired));
        }
Пример #2
0
        public static void LoadWiredItem(Item item, Room room, IQueryAdapter dbClient)
        {
            IWired handler = null;

            switch (item.GetBaseItem().InteractionType)
            {
                #region Trigger
            case InteractionType.triggertimer:
                handler = new Timer(item, room.GetWiredHandler(), 2, room.GetGameManager());
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggerroomenter:
                handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), false, string.Empty);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggercollision:
                handler = new Collision(item, room.GetWiredHandler(), room.GetRoomUserManager());
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggergameend:
                HandleItemLoad(new GameEnds(item, room.GetWiredHandler(), room.GetGameManager()), item);
                break;

            case InteractionType.triggergamestart:
                HandleItemLoad(new GameStarts(item, room.GetWiredHandler(), room.GetGameManager()), item);
                break;

            case InteractionType.triggerrepeater:
                handler = new Repeater(room.GetWiredHandler(), item, 0);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggerrepeaterlong:
                handler = new Repeaterlong(room.GetWiredHandler(), item, 0);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggeronusersay:
                handler = new UserSays(item, room.GetWiredHandler(), false, string.Empty, room);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.triggercommand:
                handler = new UserCommand(item, room.GetWiredHandler(), room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_trg_bot_reached_avtr:
                handler = new BotReadchedAvatar(item, room.GetWiredHandler(), "");
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggercollisionuser:
                handler = new UserCollision(item, room.GetWiredHandler(), room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerscoreachieved:
                handler = new ScoreAchieved(item, room.GetWiredHandler(), 0, room.GetGameManager());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerstatechanged:
                handler = new SateChanged(room.GetWiredHandler(), item, new List <Item>(), 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerwalkonfurni:
                handler = new WalksOnFurni(item, room.GetWiredHandler(), new List <Item>(), 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.triggerwalkofffurni:
                handler = new WalksOffFurni(item, room.GetWiredHandler(), new List <Item>(), 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

                #endregion
                #region Action
            case InteractionType.actiongivescore:
                handler = new GiveScore(0, 0, room.GetGameManager(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_give_score_tm:
                handler = new GiveScoreTeam(0, 0, 0, room.GetGameManager(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionposreset:
                handler = new PositionReset(new List <Item>(), 0, room.GetRoomItemHandler(), room.GetWiredHandler(), item.Id, 0, 0, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionmoverotate:
                handler = new MoveRotate(MovementState.none, RotationState.none, new List <Item>(), 0, room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionresettimer:
                handler = new TimerReset(room, room.GetWiredHandler(), 1, item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.highscore:
                handler = new HighScore(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.highscorepoints:
                handler = new HighScorePoints(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionshowmessage:
                handler = new ShowMessage(string.Empty, room.GetWiredHandler(), item.Id, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actiongivereward:
                //handlergr = (IWiredTrigger) new GiveReward(string.Empty, room.GetWiredHandler(), item.Id);
                //handlergr.LoadFromDatabase(dbClient, room);
                //WiredLoader.HandleItemLoad(handlergr, item);
                break;

            case InteractionType.superwired:
                handler = new SuperWired(string.Empty, 0, false, false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionteleportto:
                handler = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), new List <Item>(), 0, item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_endgame_team:
                handler = new TeamGameOver(1, item.Id, room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actiontogglestate:
                handler = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), new List <Item>(), 0, item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_call_stacks:
                handler = new ExecutePile(new List <Item>(), 0, room.GetWiredHandler(), item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionkickuser:
                handler = new KickUser(string.Empty, room.GetWiredHandler(), item.Id, room);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionflee:
                handler = new Escape(new List <Item>(), room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionchase:
                handler = new Chase(new List <Item>(), room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.collisionteam:
                handler = new CollisionTeam(1, room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.collisioncase:
                handler = new CollisionCase(new List <Item>(), room, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.actionmovetodir:
                handler = new MoveToDir(new List <Item>(), room, room.GetWiredHandler(), item.Id, MovementDirection.up, WhenMovementBlock.none);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_clothes:
                handler = new BotClothes("", "", room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_teleport:
                handler = new BotTeleport("", new List <Item>(), room.GetGameMap(), room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_follow_avatar:
                handler = new BotFollowAvatar("", false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_give_handitem:
                handler = new BotGiveHanditem("", room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_move:
                handler = new BotMove("", new List <Item>(), room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_user_move:
                handler = new UserMove(new List <Item>(), 0, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_talk_to_avatar:
                handler = new BotTalkToAvatar("", "", false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_bot_talk:
                handler = new BotTalk("", "", false, room.GetWiredHandler(), item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_leave_team:
                handler = new TeamLeave(item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_act_join_team:
                handler = new TeamJoin(1, item.Id);
                handler.LoadFromDatabase(dbClient, room);

                break;

                #endregion
                #region Condition
            case InteractionType.superwiredcondition:
                handler = (IWiredCondition) new SuperWiredCondition(item, string.Empty, false);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionfurnishaveusers:
                handler = (IWiredCondition) new FurniHasUser(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionfurnishavenousers:
                handler = (IWiredCondition) new FurniHasNoUser(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionstatepos:
                handler = (IWiredCondition) new FurniStatePosMatch(item, new List <Item>(), 0, 0, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_stuff_is:
                handler = (IWiredCondition) new FurniStuffIs(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_not_stuff_is:
                handler = (IWiredCondition) new FurniNotStuffIs(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionstateposNegative:
                handler = (IWiredCondition) new FurniStatePosMatchNegative(item, new List <Item>(), 0, 0, 0);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontimelessthan:
                handler = (IWiredCondition) new LessThanTimer(0, room, item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontimemorethan:
                handler = (IWiredCondition) new MoreThanTimer(0, room, item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontriggeronfurni:
                handler = (IWiredCondition) new TriggerUserIsOnFurni(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditiontriggeronfurniNegative:
                handler = (IWiredCondition) new TriggerUserIsOnFurniNegative(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionhasfurnionfurni:
                handler = (IWiredCondition) new HasFurniOnFurni(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionhasfurnionfurniNegative:
                handler = (IWiredCondition) new HasFurniOnFurniNegative(item, new List <Item>());
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionactoringroup:
                handler = (IWiredCondition) new HasUserInGroup(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.conditionnotingroup:
                handler = (IWiredCondition) new HasUserNotInGroup(item);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_actor_in_team:
                handler = (IWiredCondition) new ActorInTeam(item.Id, 1);
                handler.LoadFromDatabase(dbClient, room);

                break;

            case InteractionType.wf_cnd_not_in_team:
                handler = (IWiredCondition) new ActorNotInTeam(item.Id, 1);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.wf_cnd_not_user_count:
                handler = (IWiredCondition) new RoomUserNotCount(item, 1, 1);
                handler.LoadFromDatabase(dbClient, room);
                break;

            case InteractionType.wf_cnd_user_count_in:
                handler = (IWiredCondition) new RoomUserCount(item, 1, 1);
                handler.LoadFromDatabase(dbClient, room);
                break;
                #endregion
            }
            if (handler != null)
            {
                HandleItemLoad(handler, item);
            }
        }
Пример #3
0
        internal static void LoadWiredItem(RoomItem item, Room room, IQueryAdapter dbClient)
        {
            WiredLoaderSQL wired = new WiredLoaderSQL(item, room, dbClient);

            switch (item.GetBaseItem().InteractionType)
            {
                #region Cargar Causantes
            case InteractionType.triggerroomenter:
            {
                IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(wired.StringSettings[0]), wired.StringSettings[0]);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerwalkonfurni:
            {
                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), wired.wiredItems);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerwalkofffurni:
            {
                IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), wired.wiredItems);
                HandleItemLoad(handler, item);
                break;
            }

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

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

            case InteractionType.triggertimer:
            {
                int time = 50;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), time, room.GetGameManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerrepeater:
            {
                int time = 50;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, time);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggeronusersay:
            {
                IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), ((wired.StringSettings[2] == "true") ? true : false), wired.StringSettings[0], room);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerscoreachieved:
            {
                int score = 0;
                int.TryParse(wired.StringSettings[0], out score);

                IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerstatechanged:
            {
                IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, wired.wiredItems);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggercollision:
            {
                IWiredTrigger handler = new Collision(item, room.GetWiredHandler(), room.GetRoomUserManager());
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerlongperiodic:
            {
                int time = 10;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger handler = new LongRepeater(room.GetWiredHandler(), item, time);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerbotreachedavtr:
            {
                IWiredTrigger handler = new BotAlcanzaUsuario(item, room.GetWiredHandler(), room.GetRoomUserManager(), wired.StringSettings[0]);
                HandleItemLoad(handler, item);
                break;
            }

            case InteractionType.triggerbotreachedstf:
            {
                IWiredTrigger handler = new BotAlcanzaFurni(item, room.GetWiredHandler(), room.GetRoomUserManager(), wired.wiredItems, wired.StringSettings[0]);
                HandleItemLoad(handler, item);
                break;
            }
                #endregion

                #region Cargar Efectos
            case InteractionType.actiongivescore:
            {
                int maxCountPerGame = 1;
                int.TryParse(wired.StringSettings[1], out maxCountPerGame);
                int scoreToGive = 10;
                int.TryParse(wired.StringSettings[0], out scoreToGive);

                IWiredTrigger action = new GiveScore(maxCountPerGame, scoreToGive, room.GetGameManager(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionposreset:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new PositionReset(wired.wiredItems, time, wired.StringSettings[1], wired.originalPositionList, room.GetRoomItemHandler(), room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionresettimer:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), time, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionshowmessage:
            {
                IWiredTrigger action = new ShowMessage(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionhandiitemcustom:
            {
                IWiredTrigger action = new HandiCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actioneffectcustom:
            {
                IWiredTrigger action = new EffectCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiondiamantescustom:
            {
                IWiredTrigger action = new DiamantesCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiondancecustom:
            {
                IWiredTrigger action = new DanceCustom(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionfastwalk:
            {
                int time = 2;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new FastWalkCustom(room.GetWiredHandler(), item, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionfreezecustom:
            {
                int time = 2;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new FreezeCustom(room.GetWiredHandler(), item, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionteleportto:
            {
                IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), wired.wiredItems, 0, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiontogglestate:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredTrigger action = new ToggleItemState(room.GetWiredHandler(), wired.wiredItems, time, item);

                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmoverotate:
            {
                int time = 5;
                int.TryParse(wired.StringSettings[0], out time);

                Console.WriteLine(wired.StringSettings[0]);
                Console.WriteLine(wired.StringSettings[1]);
                int movementInt = 0;
                int rotationInt = 0;
                if (wired.StringSettings[1].Length > 0 && wired.StringSettings[1].Contains(","))
                {
                    int.TryParse(wired.StringSettings[1].Split(',')[0], out movementInt);
                    int.TryParse(wired.StringSettings[1].Split(',')[1], out rotationInt);
                }

                IWiredTrigger action = new MoveRotate((MovementState)Convert.ToInt32(movementInt), (RotationState)Convert.ToInt32(rotationInt), wired.wiredItems, time, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiongivereward:
            {
                int Amount   = 0;
                int Type     = 0;
                int AllUsers = 0;
                int nInt     = 1;

                if (wired.StringSettings[1].Length > 0 && wired.StringSettings[1].Contains(",") && wired.StringSettings[1].Split(',').Length >= 4)
                {
                    int.TryParse(wired.StringSettings[1].Split(',')[0], out Amount);
                    int.TryParse(wired.StringSettings[1].Split(',')[1], out Type);
                    int.TryParse(wired.StringSettings[1].Split(',')[2], out AllUsers);
                    int.TryParse(wired.StringSettings[1].Split(',')[3], out nInt);
                }

                IWiredTrigger action = new GiveReward(wired.StringSettings[0], Amount, Type, AllUsers, nInt, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionchase:
            {
                IWiredTrigger action = new Chase(wired.wiredItems, 0, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionkickuser:
            {
                IWiredTrigger action = new KickUser(wired.StringSettings[0], room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionescape:
            {
                IWiredTrigger action = new Escape(wired.wiredItems, 0, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionjointoteam:
            {
                int teamid = 1;
                int.TryParse(wired.StringSettings[0], out teamid);

                IWiredTrigger action = new JoinToTeam(room.GetWiredHandler(), item, (Team)teamid);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionleaveteam:
            {
                IWiredTrigger action = new LeaveTeam(room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actiongiveteamscore:
            {
                int maxCountPerGame = 1;
                int scoreToGive     = 10;
                if (wired.StringSettings[0].Contains(","))
                {
                    int.TryParse(wired.StringSettings[0].Split(',')[1], out maxCountPerGame);
                    int.TryParse(wired.StringSettings[0].Split(',')[0], out scoreToGive);
                }

                int teamid = 1;
                int.TryParse(wired.StringSettings[1], out teamid);

                IWiredTrigger action = new GiveTeamScore(maxCountPerGame, scoreToGive, (Team)teamid, room.GetGameManager(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actioncallstacks:
            {
                IWiredTrigger action = new CallStacks(wired.wiredItems, room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmovetodir:
            {
                int movementInt = 0;
                int rotationInt = 0;
                int.TryParse(wired.StringSettings[0], out movementInt);
                int.TryParse(wired.StringSettings[1], out rotationInt);

                IWiredTrigger action = new MoveToDir(wired.wiredItems, (MovementDirection)Convert.ToInt32(movementInt), (WhenMovementBlock)Convert.ToInt32(rotationInt), room, room.GetWiredHandler(), item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotmove:
            {
                string botName = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                IWiredTrigger action = new BotMove(item.Id, room, room.GetWiredHandler(), botName, wired.wiredItems, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotwhisper:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                bool talkorwhisper = wired.StringSettings[2].ToLower() == "true";

                IWiredTrigger action = new BotTalkToUser(item.Id, room, room.GetWiredHandler(), message, talkorwhisper);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotteleport:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                IWiredTrigger action = new BotTeleport(item.Id, room, room.GetWiredHandler(), message, wired.wiredItems, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotclothes:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new BotChangeLook(item.Id, room, room.GetWiredHandler(), message, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbottalk:
            {
                string message = wired.StringSettings[0];

                uint time = 5;
                uint.TryParse(wired.StringSettings[1], out time);

                bool talkorwhisper = wired.StringSettings[2].ToLower() == "true";

                IWiredTrigger action = new BotTalkToAll(item.Id, room, room.GetWiredHandler(), message, talkorwhisper, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbothanditem:
            {
                string message = wired.StringSettings[0];

                int handitem = 0;
                int.TryParse(wired.StringSettings[1], out handitem);

                uint time = 5;
                uint.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new BotGiveHandItem(item.Id, room, room.GetWiredHandler(), message, handitem, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionbotfollowavt:
            {
                string botname = wired.StringSettings[0];

                uint time = 0;
                uint.TryParse(wired.StringSettings[1], out time);

                bool followorstop = wired.StringSettings[2].ToLower() == "true";

                IWiredTrigger action = new BotFollowUser(item.Id, room, room.GetWiredHandler(), botname, followorstop, time);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmutetriggerer:
            {
                string botname = wired.StringSettings[0];

                uint mutetimer = 0;
                uint.TryParse(wired.StringSettings[1], out mutetimer);

                uint time = 0;
                uint.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new MuteTriggerer(room.GetWiredHandler(), botname, mutetimer, time, item);
                HandleItemLoad(action, item);
                break;
            }

            case InteractionType.actionmovetofurni:
            {
                int length = 0;
                int.TryParse(wired.StringSettings[0], out length);

                int direction = 0;
                int.TryParse(wired.StringSettings[1], out direction);

                int time = 0;
                int.TryParse(wired.StringSettings[2], out time);

                IWiredTrigger action = new MoveToFurni(room.GetWiredHandler(), wired.wiredItems, length, direction, time, item);
                HandleItemLoad(action, item);
                break;
            }
                #endregion

                #region Condiciones
            case InteractionType.conditionfurnishaveusers:
            {
                IWiredCondition furniHasUsers = new FurniHasUsers(item, wired.wiredItems);
                HandleConditionLoad(furniHasUsers, item, room);
                break;
            }

            case InteractionType.conditionhasfurnion:
            {
                int hasfurni = 0;
                int.TryParse(wired.StringSettings[0], out hasfurni);

                IWiredCondition furniHasFurni = new FurniHasFurni(item, wired.wiredItems, hasfurni);
                HandleConditionLoad(furniHasFurni, item, room);
                break;
            }

            case InteractionType.conditiontriggeronfurni:
            {
                IWiredCondition triggerUserIsOnFurni = new TriggerUserIsOnFurni(item, wired.wiredItems);
                HandleConditionLoad(triggerUserIsOnFurni, item, room);
                break;
            }

            case InteractionType.conditionstatepos:
            {
                IWiredCondition furnistatepos = new FurniStatePosMatch(item, wired.wiredItems, wired.StringSettings[0], wired.originalPositionList);
                HandleConditionLoad(furnistatepos, item, room);
                break;
            }

            case InteractionType.conditiontimelessthan:
            {
                int time = 18;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredCondition timeLessThan = new LessThanTimer(time, room, item);
                HandleConditionLoad(timeLessThan, item, room);
                break;
            }

            case InteractionType.conditiontimemorethan:
            {
                int time = 18;
                int.TryParse(wired.StringSettings[0], out time);

                IWiredCondition timeMoreThan = new MoreThanTimer(time, room, item);
                HandleConditionLoad(timeMoreThan, item, room);
                break;
            }

            case InteractionType.conditionactoringroup:
            {
                IWiredCondition actionInGroup = new ActorInGroup(room.RoomData.GroupId, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionactorinteam:
            {
                int teamid = 1;
                int.TryParse(wired.StringSettings[0], out teamid);

                IWiredCondition actionInGroup = new ActorInTeam((Team)teamid, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionusercountin:
            {
                uint minUsers = 1;
                uint.TryParse(wired.StringSettings[0], out minUsers);

                uint maxUsers = 50;
                uint.TryParse(wired.StringSettings[1], out maxUsers);

                IWiredCondition userCountIn = new UserCountIn(minUsers, maxUsers, item);
                HandleConditionLoad(userCountIn, item, room);
                break;
            }

            case InteractionType.conditionstuffis:
            {
                IWiredCondition struffIn = new StuffIs(item, wired.wiredItems);
                HandleConditionLoad(struffIn, item, room);
                break;
            }

            case InteractionType.conditionhandleitemid:
            {
                int handleId = 18;
                int.TryParse(wired.StringSettings[0], out handleId);

                IWiredCondition handleItem = new HandleItemUser(handleId, item);
                HandleConditionLoad(handleItem, item, room);
                break;
            }

            case InteractionType.conditionnotfurnishaveusers:
            {
                IWiredCondition furniHasUsers = new NotFurniHasUsers(item, wired.wiredItems);
                HandleConditionLoad(furniHasUsers, item, room);
                break;
            }

            case InteractionType.conditionnotfurnion:
            {
                int hasfurni = 0;
                int.TryParse(wired.StringSettings[0], out hasfurni);

                IWiredCondition furniHasFurni = new NotFurniHasFurni(item, wired.wiredItems, hasfurni);
                HandleConditionLoad(furniHasFurni, item, room);
                break;
            }

            case InteractionType.conditionnottriggeronfurni:
            {
                IWiredCondition triggerUserIsOnFurni = new NotTriggerUserIsOnFurni(item, wired.wiredItems);
                HandleConditionLoad(triggerUserIsOnFurni, item, room);
                break;
            }

            case InteractionType.conditionnotstatepos:
            {
                IWiredCondition furnistatepos = new NotFurniStatePosMatch(item, wired.wiredItems, wired.StringSettings[0], wired.originalPositionList);
                HandleConditionLoad(furnistatepos, item, room);
                break;
            }

            case InteractionType.conditionnotingroup:
            {
                IWiredCondition actionInGroup = new NotActorInGroup(room.RoomData.GroupId, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionnotinteam:
            {
                int teamid = 1;
                int.TryParse(wired.StringSettings[0], out teamid);

                IWiredCondition actionInGroup = new NotActorInTeam((Team)teamid, item);
                HandleConditionLoad(actionInGroup, item, room);
                break;
            }

            case InteractionType.conditionnotusercount:
            {
                uint minUsers = 1;
                uint.TryParse(wired.StringSettings[0], out minUsers);

                uint maxUsers = 50;
                uint.TryParse(wired.StringSettings[1], out maxUsers);

                IWiredCondition userCountIn = new NotUserCountIn(minUsers, maxUsers, item);
                HandleConditionLoad(userCountIn, item, room);
                break;
            }

            case InteractionType.conditionnotstuffis:
            {
                IWiredCondition struffIn = new NotStuffIs(item, wired.wiredItems);
                HandleConditionLoad(struffIn, item, room);
                break;
            }

            case InteractionType.conditionwearingeffect:
            {
                uint effect = 0;
                uint.TryParse(wired.StringSettings[0], out effect);

                IWiredCondition wearingEffect = new UserWearingEffect(effect, item);
                HandleConditionLoad(wearingEffect, item, room);
                break;
            }

            case InteractionType.conditionnotwearingeffect:
            {
                uint effect = 0;
                uint.TryParse(wired.StringSettings[0], out effect);

                IWiredCondition notWearingEffect = new UserNotWearingEffect(effect, item);
                HandleConditionLoad(notWearingEffect, item, room);
                break;
            }

            case InteractionType.conditionwearingbadge:
            {
                string badge = wired.StringSettings[0];

                IWiredCondition wearingBadge = new UserWearingBadge(badge, item);
                HandleConditionLoad(wearingBadge, item, room);
                break;
            }

            case InteractionType.conditionnotwearingbadge:
            {
                string badge = wired.StringSettings[0];

                IWiredCondition notWearingBadge = new UserNotWearingBadge(badge, item);
                HandleConditionLoad(notWearingBadge, item, room);
                break;
            }

            case InteractionType.conditiondaterange:
            {
                int startDate = 0;
                int.TryParse(wired.StringSettings[0], out startDate);

                int endDate = 0;
                int.TryParse(wired.StringSettings[1], out endDate);

                IWiredCondition dateRangeActive = new DateRangeActive(startDate, endDate, item);
                HandleConditionLoad(dateRangeActive, item, room);
                break;
            }
                #endregion
            }
        }
Пример #4
0
        internal static void HandleSave(GameClient Session, 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;
            }
            //Logging.WriteLine("handle wired!");
            InteractionType type = item.GetBaseItem().InteractionType;

            switch (type)
            {
            case InteractionType.triggeronusersay:
            {
                int    junk        = clientMessage.ReadInt32();
                bool   isOnlyOwner = (clientMessage.ReadInt32() == 1);
                string message     = clientMessage.ReadString();
                //Logging.WriteLine("Handle 'onusersay' itemid(" + item.Id + ") junk(" + junk + ") wired: isOnlyOwner(" + isOnlyOwner + ") message = " + message);

                IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), isOnlyOwner, message, room);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerwalkonfurni:
            {
                int             junk    = clientMessage.ReadInt32();
                string          message = clientMessage.ReadString();
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.ReadInt32();

                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerwalkofffurni:
            {
                int             junk    = clientMessage.ReadInt32();
                string          message = clientMessage.ReadString();
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.ReadInt32();

                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionshowmessage:
            {
                int    junk    = clientMessage.ReadInt32();
                string message = clientMessage.ReadString();

                IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionteleportto:
            {
                int             junk  = clientMessage.ReadInt32();
                string          junk2 = clientMessage.ReadString();
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.ReadInt32();

                IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actiontogglestate:
            {
                int             junk    = clientMessage.ReadInt32();
                string          message = clientMessage.ReadString();
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.ReadInt32();
                //Logging.WriteLine("Save action toogle wired with " + items.Count + " item(s) and " + delay + " second(s) of delay!");

                IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionmoverotate:
            {
                int           junk     = clientMessage.ReadInt32();
                MovementState movement = (MovementState)clientMessage.ReadInt32();
                RotationState rotation = (RotationState)clientMessage.ReadInt32();

                bool            junk3 = clientMessage.ReadBoolean();
                bool            junk2 = clientMessage.ReadBoolean();
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.ReadInt32();

                IWiredTrigger handler = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), itemID);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionposreset:
            {
                int  junk  = clientMessage.ReadInt32();
                bool junk3 = clientMessage.ReadBoolean();
                bool junk2 = clientMessage.ReadBoolean();

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

                IWiredTrigger action = new PositionReset(items, delay, room.GetRoomItemHandler(), room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.actionresettimer:
            {
                int             junk  = clientMessage.ReadInt32();
                bool            junk3 = clientMessage.ReadBoolean();
                bool            junk2 = clientMessage.ReadBoolean();
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.ReadInt32();

                IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), items, delay, itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.actiongivescore:
            {
                int junk   = clientMessage.ReadInt32();
                int points = clientMessage.ReadInt32();
                int games  = clientMessage.ReadInt32();

                IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

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

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

            case InteractionType.triggerrepeater:
            {
                int junk       = clientMessage.ReadInt32();
                int cycleTimes = clientMessage.ReadInt32();

                IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerroomenter:
            {
                int    junk  = clientMessage.ReadInt32();
                string users = clientMessage.ReadString();

                IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerscoreachieved:
            {
                int junk  = clientMessage.ReadInt32();
                int score = clientMessage.ReadInt32();

                IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggertimer:
            {
                int junk   = clientMessage.ReadInt32();
                int cycles = clientMessage.ReadInt32();

                IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerstatechanged:
            {
                int  junk  = clientMessage.ReadInt32();
                bool junk3 = clientMessage.ReadBoolean();
                bool junk2 = clientMessage.ReadBoolean();

                int             furniAmount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniAmount);
                int             delay = clientMessage.ReadInt32();

                IWiredTrigger handler = new SateChanged(room.GetWiredHandler(), item, items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }
            }
            Session.SendMessage(new ServerMessage(Outgoing.SaveWired));

            /*switch (type)
             * {
             *  case InteractionType.actiongivescore:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          int points = clientMessage.PopWiredInt32();
             *          int games = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), itemID);
             *          HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.actionmoverotate:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          MovementState movement = (MovementState)clientMessage.PopWiredInt32();
             *          RotationState rotation = (RotationState)clientMessage.PopWiredInt32();
             *
             *          clientMessage.AdvancePointer(2);
             *          int furniCount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniCount);
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger action = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), itemID);
             *          HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.actionposreset:
             *      {
             *
             *          clientMessage.AdvancePointer(3);
             *          int furniCount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniCount);
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger action = new PositionReset(items, delay, room.GetRoomItemHandler(), room.GetWiredHandler(), itemID);
             *          HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.actionresettimer:
             *      {
             *
             *          clientMessage.AdvancePointer(3);
             *          int furniCount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniCount);
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), items, delay, itemID);
             *          HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.actionshowmessage:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          string message = clientMessage.PopFixedString();
             *
             *          IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), itemID);
             *          HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
             *          break;
             *      }
             *
             *  case InteractionType.actionteleportto:
             *      {
             *          clientMessage.AdvancePointer(3);
             *          int furniCount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniCount);
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, itemID);
             *          HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.actiontogglestate:
             *      {
             *          clientMessage.AdvancePointer(3);
             *          int furniCount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniCount);
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), items, delay, itemID);
             *          HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *
             *  case InteractionType.conditionfurnishaveusers:
             *      {
             *          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);
             *
             *
             *          if (a)
             *          {
             *              int a1 = 2;
             *          }
             *
             *          break;
             *      }
             *
             *  case InteractionType.conditionstatepos:
             *      {
             *
             *          break;
             *      }
             *
             *  case InteractionType.conditiontimelessthan:
             *      {
             *
             *          break;
             *      }
             *
             *  case InteractionType.conditiontimemorethan:
             *      {
             *
             *          break;
             *      }
             *
             *  case InteractionType.conditiontriggeronfurni:
             *      {
             *
             *          break;
             *      }
             *
             *  case InteractionType.specialrandom:
             *      {
             *
             *          break;
             *      }
             *
             *  case InteractionType.specialunseen:
             *      {
             *
             *          break;
             *      }
             *
             *  case InteractionType.triggergameend:
             *      {
             *          IWiredTrigger handler = new GameEnds(item, room.GetWiredHandler(), room.GetGameManager());
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *          break;
             *      }
             *
             *  case InteractionType.triggergamestart:
             *      {
             *          IWiredTrigger handler = new GameStarts(item, room.GetWiredHandler(), room.GetGameManager());
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *          break;
             *      }
             *
             *  case InteractionType.triggeronusersay:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          bool isOnlyOwner = clientMessage.PopWiredBoolean();
             *          clientMessage.AdvancePointer(0);
             *          string message = clientMessage.PopFixedString();
             *          string stuff = clientMessage.ToString();
             *
             *          IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), isOnlyOwner, message, room);
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.triggerrepeater:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          int cycleTimes = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.triggerroomenter:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          string users = clientMessage.PopFixedString();
             *
             *          IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *          break;
             *      }
             *
             *  case InteractionType.triggerscoreachieved:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          int score = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.triggertimer:
             *      {
             *          clientMessage.AdvancePointer(1);
             *          int cycles = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.triggerstatechanged:
             *      {
             *          clientMessage.AdvancePointer(3);
             *
             *          int furniAmount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniAmount);
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger handler = new SateChanged(room.GetWiredHandler(), item, items, delay);
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             *
             *  case InteractionType.triggerwalkofffurni:
             *      {
             *          clientMessage.AdvancePointer(3);
             *
             *          int furniAmount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniAmount);
             *
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items, delay);
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *          break;
             *      }
             *
             *  case InteractionType.triggerwalkonfurni:
             *      {
             *          clientMessage.AdvancePointer(3);
             *          int furniAmount;
             *          List<RoomItem> items = GetItems(clientMessage, room, out furniAmount);
             *
             *          int delay = clientMessage.PopWiredInt32();
             *
             *          IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay);
             *          HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
             *
             *          break;
             *      }
             * }*/
        }
Пример #5
0
        internal static void HandleDefaultSave(uint itemID, Room room)
        {
            RoomItem item = room.GetRoomItemHandler().GetItem(itemID);

            if (item == null)
            {
                return;
            }

            InteractionType type = item.GetBaseItem().InteractionType;

            switch (type)
            {
            case InteractionType.actiongivescore:
            {
                int points = 0;
                int games  = 0;

                IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionmoverotate:
            {
                MovementState movement = MovementState.none;
                RotationState rotation = RotationState.none;

                List <RoomItem> items = new List <RoomItem>();
                int             delay = 0;

                IWiredTrigger action = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionposreset:
            {
                List <RoomItem> items = new List <RoomItem>();
                int             delay = 0;

                IWiredTrigger action = new PositionReset(items, delay, room.GetRoomItemHandler(), room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionresettimer:
            {
                List <RoomItem> items = new List <RoomItem>();
                int             delay = 0;

                IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), items, delay, itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionshowmessage:
            {
                string message = string.Empty;

                IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionteleportto:
            {
                List <RoomItem> items = new List <RoomItem>();
                int             delay = 0;

                IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actiontogglestate:
            {
                List <RoomItem> items = new List <RoomItem>();
                int             delay = 0;

                IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), items, delay, item);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.conditionfurnishaveusers:
            {
                break;
            }

            case InteractionType.conditionstatepos:
            {
                break;
            }

            case InteractionType.conditiontimelessthan:
            {
                break;
            }

            case InteractionType.conditiontimemorethan:
            {
                break;
            }

            case InteractionType.conditiontriggeronfurni:
            {
                break;
            }

            case InteractionType.specialrandom:
            {
                break;
            }

            case InteractionType.specialunseen:
            {
                break;
            }

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

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

            case InteractionType.triggeronusersay:
            {
                bool   isOnlyOwner = false;
                string message     = string.Empty;

                IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), !isOnlyOwner, message, room);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerrepeater:
            {
                int cycleTimes = 0;

                IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerroomenter:
            {
                string users = string.Empty;

                IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerscoreachieved:
            {
                int score = 0;

                IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggertimer:
            {
                int cycles = 0;

                IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerstatechanged:
            {
                List <RoomItem> items = new List <RoomItem>();
                int             delay = 0;

                IWiredTrigger handler = new SateChanged(room.GetWiredHandler(), item, items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerwalkofffurni:
            {
                List <RoomItem> items = new List <RoomItem>();

                int delay = 0;

                IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerwalkonfurni:
            {
                List <RoomItem> items = new List <RoomItem>();

                int delay = 0;

                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }
            }
        }
Пример #6
0
        internal static void HandleSave(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;

            switch (type)
            {
            case InteractionType.actiongivescore:
            {
                clientMessage.AdvancePointer(1);
                int points = clientMessage.PopWiredInt32();
                int games  = clientMessage.PopWiredInt32();

                IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.actionmoverotate:
            {
                clientMessage.AdvancePointer(1);
                MovementState movement = (MovementState)clientMessage.PopWiredInt32();
                RotationState rotation = (RotationState)clientMessage.PopWiredInt32();

                clientMessage.AdvancePointer(2);
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.actionposreset:
            {
                clientMessage.AdvancePointer(3);
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new PositionReset(items, delay, room.GetRoomItemHandler(), room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.actionresettimer:
            {
                clientMessage.AdvancePointer(3);
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), items, delay, itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.actionshowmessage:
            {
                clientMessage.AdvancePointer(1);
                string message = clientMessage.PopFixedString();

                IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.actionteleportto:
            {
                clientMessage.AdvancePointer(3);
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.actiontogglestate:
            {
                clientMessage.AdvancePointer(3);
                int             furniCount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniCount);
                int             delay = clientMessage.PopWiredInt32();

                IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), items, delay, itemID);
                HandleTriggerSave(action, room.GetWiredHandler(), room, itemID);

                break;
            }


            case InteractionType.conditionfurnishaveusers:
            {
                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);

                // WTF?
                //if (a)
                //{
                //    int a1 = 2;
                //}

                break;
            }

            case InteractionType.conditionstatepos:
            {
                break;
            }

            case InteractionType.conditiontimelessthan:
            {
                break;
            }

            case InteractionType.conditiontimemorethan:
            {
                break;
            }

            case InteractionType.conditiontriggeronfurni:
            {
                break;
            }

            case InteractionType.specialrandom:
            {
                break;
            }

            case InteractionType.specialunseen:
            {
                break;
            }

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

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

            case InteractionType.triggeronusersay:
            {
                clientMessage.AdvancePointer(1);
                bool isOnlyOwner = clientMessage.PopWiredBoolean();
                clientMessage.AdvancePointer(0);
                string message = clientMessage.PopFixedString();
                string stuff   = clientMessage.ToString();

                IWiredTrigger handler = new UserSays(item, room.GetWiredHandler(), isOnlyOwner, message, room);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerrepeater:
            {
                clientMessage.AdvancePointer(1);
                int cycleTimes = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerroomenter:
            {
                clientMessage.AdvancePointer(1);
                string users = clientMessage.PopFixedString();

                IWiredTrigger handler = new EntersRoom(item, room.GetWiredHandler(), room.GetRoomUserManager(), !string.IsNullOrEmpty(users), users);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerscoreachieved:
            {
                clientMessage.AdvancePointer(1);
                int score = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggertimer:
            {
                clientMessage.AdvancePointer(1);
                int cycles = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager());
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerstatechanged:
            {
                clientMessage.AdvancePointer(3);

                int             furniAmount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniAmount);
                int             delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new SateChanged(room.GetWiredHandler(), item, items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }

            case InteractionType.triggerwalkofffurni:
            {
                clientMessage.AdvancePointer(3);

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

                int delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);
                break;
            }

            case InteractionType.triggerwalkonfurni:
            {
                clientMessage.AdvancePointer(3);
                int             furniAmount;
                List <RoomItem> items = GetItems(clientMessage, room, out furniAmount);

                int delay = clientMessage.PopWiredInt32();

                IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay);
                HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID);

                break;
            }
            }
        }
Пример #7
0
        internal static void LoadWiredItem(RoomItem item, Room room, IQueryAdapter dbClient)
        {
            InteractionType type = item.GetBaseItem().InteractionType;

            switch (type)
            {
            case InteractionType.actiongivescore:
            {
                IWiredTrigger action = new GiveScore(0, 0, room.GetGameManager(), item.Id);
                action.LoadFromDatabase(dbClient, room);
                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.Id);
                action.LoadFromDatabase(dbClient, room);
                HandleItemLoad(action, room.GetWiredHandler(), item);
                break;
            }

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

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

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

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

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

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

            case InteractionType.conditionstatepos:
            {
                IWiredCondition furnistatepos = new FurniStatePosMatch(item, new List <RoomItem>());
                furnistatepos.LoadFromDatabase(dbClient, room);
                HandleConditionLoad(furnistatepos, item);
                break;
            }

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

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

            case InteractionType.conditiontriggeronfurni:
            {
                IWiredCondition triggerOnFurni = new TriggerUserIsOnFurni(item, new List <RoomItem>());
                triggerOnFurni.LoadFromDatabase(dbClient, room);
                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.LoadFromDatabase(dbClient, room);
                HandleItemLoad(handler, room.GetWiredHandler(), item);
                break;
            }

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

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

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

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

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

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

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