예제 #1
0
        public void RemoveFurniture(Item item)
        {
            Point itemCoord = item.Coordinate;

            if (WiredUtillity.TypeIsWiredAction(item.GetBaseItem().InteractionType))
            {
                Point coordinate = item.Coordinate;
                if (!this.actionStacks.ContainsKey(coordinate))
                {
                    return;
                }

                ((List <Item>) this.actionStacks[coordinate]).Remove(item);
                if (this.actionStacks[coordinate].Count == 0)
                {
                    List <Item> NewList = new List <Item>();
                    this.actionStacks.TryRemove(coordinate, out NewList);
                }
            }
            else if (WiredUtillity.TypeIsWiredCondition(item.GetBaseItem().InteractionType))
            {
                if (!this.conditionStacks.ContainsKey(itemCoord))
                {
                    return;
                }

                ((List <Item>) this.conditionStacks[itemCoord]).Remove(item);
                if (this.conditionStacks[itemCoord].Count == 0)
                {
                    List <Item> NewList = new List <Item>();
                    this.conditionStacks.TryRemove(itemCoord, out NewList);
                }
            }
            else if (item.GetBaseItem().InteractionType == InteractionType.specialrandom)
            {
                if (this.SpecialRandom.Contains(itemCoord))
                {
                    this.SpecialRandom.Remove(itemCoord);
                }
            }
            else if (item.GetBaseItem().InteractionType == InteractionType.specialunseen)
            {
                if (this.SpecialUnseen.ContainsKey(itemCoord))
                {
                    this.SpecialUnseen.Remove(itemCoord);
                }
            }
        }
예제 #2
0
        public void AddFurniture(Item item)
        {
            Point itemCoord = item.Coordinate;

            if (WiredUtillity.TypeIsWiredAction(item.GetBaseItem().InteractionType))
            {
                if (this.actionStacks.ContainsKey(itemCoord))
                {
                    ((List <Item>) this.actionStacks[itemCoord]).Add(item);
                }
                else
                {
                    this.actionStacks.TryAdd(itemCoord, new List <Item>()
                    {
                        item
                    });
                }
            }
            else if (WiredUtillity.TypeIsWiredCondition(item.GetBaseItem().InteractionType))
            {
                if (this.conditionStacks.ContainsKey(itemCoord))
                {
                    ((List <Item>) this.conditionStacks[itemCoord]).Add(item);
                }
                else
                {
                    this.conditionStacks.TryAdd(itemCoord, new List <Item>()
                    {
                        item
                    });
                }
            }
            else if (item.GetBaseItem().InteractionType == InteractionType.specialrandom)
            {
                if (!this.SpecialRandom.Contains(itemCoord))
                {
                    this.SpecialRandom.Add(itemCoord);
                }
            }
            else if (item.GetBaseItem().InteractionType == InteractionType.specialunseen)
            {
                if (!this.SpecialUnseen.ContainsKey(itemCoord))
                {
                    this.SpecialUnseen.Add(itemCoord, 0);
                }
            }
        }
예제 #3
0
        private void AddFurnitureToItems(RoomItem item)
        {
            InteractionType type = item.GetBaseItem().InteractionType;

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

            if (actionItems.ContainsKey(type))
            {
                ((List <RoomItem>)actionItems[type]).Add(item);
            }
            else
            {
                List <RoomItem> stack = new List <RoomItem>();
                stack.Add(item);

                actionItems.Add(type, stack);
            }
        }
예제 #4
0
        private static List <RoomItem> GetItems(ClientMessage message, Room room, out int itemCount)
        {
            List <RoomItem> items = new List <RoomItem>();

            itemCount = message.PopWiredInt32();

            uint     itemID;
            RoomItem item;

            for (int i = 0; i < itemCount; i++)
            {
                itemID = message.PopWiredUInt();
                item   = room.GetRoomItemHandler().GetItem(itemID);

                if (item != null && !WiredUtillity.TypeIsWired(item.GetBaseItem().InteractionType))
                {
                    items.Add(item);
                }
            }

            return(items);
        }
예제 #5
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));
        }