internal static void HandleConditionSave(uint itemID, Room room, ClientMessage clientMessage) { RoomItem item = room.GetRoomItemHandler().GetItem(itemID); if (item == null) return; if (item.wiredHandler != null) { item.wiredHandler.Dispose(); item.wiredHandler = null; } InteractionType type = item.GetBaseItem().InteractionType; if (type != InteractionType.conditionfurnishaveusers && type != InteractionType.conditionstatepos && type != InteractionType.conditiontimelessthan && type != InteractionType.conditiontimemorethan && type != InteractionType.conditiontriggeronfurni && type != InteractionType.conditionhasfurnionfurni) return; int amountOfBooleanSettings = clientMessage.ReadInt(); if (amountOfBooleanSettings > 3) return; int[] booleans = new int[amountOfBooleanSettings]; for (int i = 0; i < amountOfBooleanSettings; i++) { booleans[i] = clientMessage.ReadInt(); } string someString = clientMessage.ReadString(); List<RoomItem> items = null; if (ConditionPacketBuilder.NeedsFurni(type)) { items = GetItems(clientMessage, room); } else { items = new List<RoomItem>(); } //int furniCount; IWiredCondition handler = null; switch (type) { case InteractionType.conditionfurnishaveusers: { handler = new FurniHasUser(item, items, room.GetWiredHandler()); break; } case InteractionType.conditionstatepos: { handler = new FurniStatePosMatch(item, items, room.GetWiredHandler(), booleans[0] == 1, booleans[1] == 1, booleans[2] == 1); break; } case InteractionType.conditiontimelessthan: { handler = new LessThanTimer(500, room, item, room.GetWiredHandler()); break; } case InteractionType.conditiontimemorethan: { handler = new MoreThanTimer(500, room, item, room.GetWiredHandler()); break; } case InteractionType.conditiontriggeronfurni: { handler = new TriggerUserIsOnFurni(item, items, room.GetWiredHandler()); break; } case InteractionType.conditionhasfurnionfurni: { handler = new FurniHasFurni(item, items, room.GetWiredHandler(), booleans[0] == 1); break; } default: return; } item.wiredCondition = handler; room.GetWiredHandler().conditionHandler.AddOrIgnoreRefferance(item); using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor()) { WiredSaverHandler.UpdateInDatabase(handler, dbClient); } }
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.ReadInt(); int points = clientMessage.ReadInt(); int games = clientMessage.ReadInt(); IWiredTrigger action = new GiveScore(games, points, room.GetGameManager(), item, room.GetWiredHandler()); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); break; } case InteractionType.actionmoverotate: { //clientMessage.AdvancePointer(1); clientMessage.ReadInt(); MovementState movement = (MovementState)clientMessage.ReadInt(); RotationState rotation = (RotationState)clientMessage.ReadInt(); clientMessage.ReadString(); //clientMessage.ReadInt(); //clientMessage.ReadInt(); //clientMessage.AdvancePointer(2); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger action = new MoveRotate(movement, rotation, items, delay, room, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); break; } case InteractionType.actionposreset: { clientMessage.ReadInt(); clientMessage.ReadString(); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger action = new PositionReset(items, delay, room.GetRoomItemHandler(), room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); break; } case InteractionType.actionresettimer: { clientMessage.ReadInt(); clientMessage.ReadString(); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger action = new TimerReset(room, room.GetWiredHandler(), items, delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); break; } case InteractionType.actionshowmessage: { clientMessage.ReadInt(); string message = clientMessage.ReadString(); IWiredTrigger action = new ShowMessage(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); break; } case InteractionType.actionkick: { clientMessage.ReadInt(); string message = clientMessage.ReadString(); IWiredTrigger action = new Kick(message, room.GetWiredHandler(), item); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); break; } case InteractionType.actionteleportto: { clientMessage.ReadInt(); clientMessage.ReadString(); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger action = new TeleportToItem(room.GetGameMap(), room.GetWiredHandler(), items, delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); break; } case InteractionType.actiontogglestate: { clientMessage.ReadInt(); clientMessage.ReadString(); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger action = new ToggleItemState(room.GetGameMap(), room.GetWiredHandler(), items, delay, item); HandleTriggerSave(action, room.GetWiredHandler(), room, itemID); 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.ReadInt(); bool isOnlyOwner = clientMessage.ReadInt() == 1; //clientMessage.AdvancePointer(0); string message = clientMessage.ReadString(); //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.ReadInt(); int cycleTimes = clientMessage.ReadInt(); IWiredTrigger handler = new Repeater(room.GetWiredHandler(), item, cycleTimes); HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID); break; } case InteractionType.triggerroomenter: { clientMessage.ReadInt(); 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: { clientMessage.ReadInt(); int score = clientMessage.ReadInt(); IWiredTrigger handler = new ScoreAchieved(item, room.GetWiredHandler(), score, room.GetGameManager()); HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID); break; } case InteractionType.triggertimer: { clientMessage.ReadInt(); int cycles = clientMessage.ReadInt(); IWiredTrigger handler = new Timer(item, room.GetWiredHandler(), cycles, room.GetGameManager()); HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID); break; } case InteractionType.triggerstatechanged: { clientMessage.ReadInt(); clientMessage.ReadString(); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger handler = new StateChanged(room.GetWiredHandler(), item, items, delay); HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID); break; } case InteractionType.triggerwalkofffurni: { clientMessage.ReadInt(); clientMessage.ReadString(); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger handler = new WalksOffFurni(item, room.GetWiredHandler(), items, delay); HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID); break; } case InteractionType.triggerwalkonfurni: { clientMessage.ReadInt(); clientMessage.ReadString(); List<RoomItem> items = GetItems(clientMessage, room); int delay = clientMessage.ReadInt(); IWiredTrigger handler = new WalksOnFurni(item, room.GetWiredHandler(), items, delay); HandleTriggerSave(handler, room.GetWiredHandler(), room, itemID); break; } } }