Exemplo n.º 1
0
        private void SendGameStarts(List <Player> playerList)
        {
            List <long> players = new List <long>();

            foreach (Player player in playerList)
            {
                players.Add(player.Id);
            }

            GameStarts data = new GameStarts(this.Game, players);

            dispatcher.GameStarts(PacketSerializer.Serialize(data)).Wait();
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 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
            }
        }
Exemplo n.º 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;
             *      }
             * }*/
        }
Exemplo n.º 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;
            }
            }
        }
Exemplo n.º 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;
            }
            }
        }
Exemplo n.º 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;
            }
            }
        }
Exemplo n.º 8
0
 private void ProcessMessage(GameStarts gameStartsMessage)
 {
     Kernel.startGame();
     battleViewer.StartOnlineGame(IsLocalPlayerFirst);
 }
Exemplo n.º 9
0
 public void Play()
 {
     SceneManager.LoadScene("Game");
     GameStarts?.Invoke();
 }