示例#1
0
        internal static void HandleConditionSave(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.wiredCondition != null)
            {
                room.GetWiredHandler().conditionHandler.RemoveConditionToTile(item.Coordinate, item.wiredCondition);

                item.wiredCondition.Dispose();
                item.wiredCondition = null;
            }

            var type = item.GetBaseItem().InteractionType;

            if (!WiredUtillity.TypeIsWiredCondition(type))
            {
                return;
            }

            IWiredCondition handler = null;

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

                handler = new FurniHasUsers(item, items);
                break;
            }

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

                handler = new FurniHasFurni(item, items, onlyOneItem);
                break;
            }

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

                handler = new TriggerUserIsOnFurni(item, items);
                break;
            }

            case InteractionType.conditionstatepos:
            {
                var junk    = clientMessage.PopWiredInt32();
                var item1   = clientMessage.PopWiredInt32();
                var item2   = clientMessage.PopWiredInt32();
                var item3   = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items                = GetItems(clientMessage, room, out furniCount);
                var delay                = clientMessage.PopWiredInt32();
                var itemsState           = item1 + "," + item2 + "," + item3;
                var originalItemLocation = new Dictionary <uint, OriginalItemLocation>();
                foreach (RoomItem nItem in items)
                {
                    originalItemLocation.Add(nItem.Id, new OriginalItemLocation(nItem.Id, nItem.GetX, nItem.GetY, nItem.TotalHeight, nItem.Rot, nItem.ExtraData));
                }

                handler = new FurniStatePosMatch(item, items, itemsState, originalItemLocation);
                break;
            }

            case InteractionType.conditiontimelessthan:
            {
                var junk = clientMessage.PopWiredInt32();
                var time = clientMessage.PopWiredInt32();
                handler = new LessThanTimer(time, room, item);
                break;
            }

            case InteractionType.conditiontimemorethan:
            {
                var junk = clientMessage.PopWiredInt32();
                var time = clientMessage.PopWiredInt32();
                handler = new MoreThanTimer(time, room, item);
                break;
            }

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

            case InteractionType.conditionactorinteam:
            {
                var junk = clientMessage.PopWiredInt32();
                var team = (Team)clientMessage.PopWiredInt32();
                handler = new ActorInTeam(team, item);
                break;
            }

            case InteractionType.conditionusercountin:
            {
                var junk     = clientMessage.PopWiredInt32();
                var minUsers = clientMessage.PopWiredUInt();
                var maxUsers = clientMessage.PopWiredUInt();
                handler = new UserCountIn(minUsers, maxUsers, item);
                break;
            }

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

                handler = new StuffIs(item, items);
                break;
            }

            case InteractionType.conditionhandleitemid:
            {
                var junk       = clientMessage.PopWiredInt32();
                var handleItem = clientMessage.PopWiredInt32();
                handler = new HandleItemUser(handleItem, item);
                break;
            }

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

                handler = new NotFurniHasUsers(item, items);
                break;
            }

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

                handler = new NotFurniHasFurni(item, items, onlyOneItem);
                break;
            }

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

                handler = new NotTriggerUserIsOnFurni(item, items);
                break;
            }

            case InteractionType.conditionnotstatepos:
            {
                var junk    = clientMessage.PopWiredInt32();
                var item1   = clientMessage.PopWiredInt32();
                var item2   = clientMessage.PopWiredInt32();
                var item3   = clientMessage.PopWiredInt32();
                var message = clientMessage.PopFixedString();
                int furniCount;
                var items                = GetItems(clientMessage, room, out furniCount);
                var delay                = clientMessage.PopWiredInt32();
                var itemsState           = item1 + "," + item2 + "," + item3;
                var originalItemLocation = new Dictionary <uint, OriginalItemLocation>();
                foreach (RoomItem nItem in items)
                {
                    originalItemLocation.Add(nItem.Id, new OriginalItemLocation(nItem.Id, nItem.GetX, nItem.GetY, nItem.TotalHeight, nItem.Rot, nItem.ExtraData));
                }

                handler = new NotFurniStatePosMatch(item, items, itemsState, originalItemLocation);
                break;
            }

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

            case InteractionType.conditionnotinteam:
            {
                var junk = clientMessage.PopWiredInt32();
                var team = (Team)clientMessage.PopWiredInt32();
                handler = new NotActorInTeam(team, item);
                break;
            }

            case InteractionType.conditionnotusercount:
            {
                var junk     = clientMessage.PopWiredInt32();
                var minUsers = clientMessage.PopWiredUInt();
                var maxUsers = clientMessage.PopWiredUInt();
                handler = new NotUserCountIn(minUsers, maxUsers, item);
                break;
            }

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

                handler = new NotStuffIs(item, items);
                break;
            }

            case InteractionType.conditionwearingeffect:
            {
                var junk   = clientMessage.PopWiredInt32();
                var effect = clientMessage.PopWiredUInt();
                handler = new UserWearingEffect(effect, item);
                break;
            }

            case InteractionType.conditionnotwearingeffect:
            {
                var junk   = clientMessage.PopWiredInt32();
                var effect = clientMessage.PopWiredUInt();
                handler = new UserNotWearingEffect(effect, item);
                break;
            }

            case InteractionType.conditionwearingbadge:
            {
                var junk    = clientMessage.PopWiredInt32();
                var badgeID = clientMessage.PopFixedString();
                handler = new UserWearingBadge(badgeID, item);
                break;
            }

            case InteractionType.conditionnotwearingbadge:
            {
                var junk    = clientMessage.PopWiredInt32();
                var badgeID = clientMessage.PopFixedString();
                handler = new UserNotWearingBadge(badgeID, item);
                break;
            }

            case InteractionType.conditiondaterange:
            {
                var junk      = clientMessage.PopWiredInt32();
                var startdate = clientMessage.PopWiredInt32();
                var enddate   = clientMessage.PopWiredInt32();
                handler = new DateRangeActive(startdate, enddate, item);
                break;
            }

            default:
                return;
            }

            item.wiredCondition = handler;
            room.GetWiredHandler().conditionHandler.AddConditionToTile(item.Coordinate, item.wiredCondition);
            room.GetRoomItemHandler().UpdateWiredItem(item);
            Session.SendMessage(new ServerMessage(Outgoing.SaveWired));
        }
示例#2
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
            }
        }
示例#3
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;
            }
            }
        }
示例#4
0
        internal static void HandleConditionSave(uint itemID, Room room, ClientMessage clientMessage)
        {
            RoomItem item = room.GetRoomItemHandler().GetItem(itemID);

            if (item == null)
            {
                return;
            }

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

            InteractionType type = item.GetBaseItem().InteractionType;

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

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

            clientMessage.AdvancePointer(2);

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

            IWiredCondition handler = null;

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

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

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

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

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

            default:
                return;
            }

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

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                handler.SaveToDatabase(dbClient);
            }
        }
示例#5
0
        internal static void HandleConditionSave(GameClient Session, uint itemID, Room room, ClientMessage clientMessage)
        {
            // // id, resolveIntParams, resolveStringParam, getStuffIds, resolveStuffSelectionType
            RoomItem item = room.GetRoomItemHandler().GetItem(itemID);

            if (item == null)
            {
                return;
            }

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

            InteractionType type = item.GetBaseItem().InteractionType;

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

            // Parse data
            int[] intParams = new int[clientMessage.ReadInt32()];
            for (int i = 0; i < intParams.Length; i++)
            {
                intParams[i] = clientMessage.ReadInt32();
            }

            string stringParam = clientMessage.ReadString();

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

            int stuffSelectionType = clientMessage.ReadInt32();

            IWiredCondition handler = null;

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

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

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

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

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

            default:
                return;
            }

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

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                handler.SaveToDatabase(dbClient);
            }
            Session.SendMessage(new ServerMessage(Outgoing.SaveWired));
        }