public void Run(Client client, MessageEvent msgEvent) { int itemId = client.CurrentRoom.GetWallItems().Where(x => x.Definition.HandleType == AuroraEmu.Game.Items.Handlers.HandleType.DIMMER).ToList()[0].Id; DimmerData data = Engine.Locator.ItemController.GetDimmerData(itemId); client.SendComposer(new RoomDimmerPresetsMessageComposer(data)); }
public DimmerData GetDimmerData(int itemId) { if (Dimmers.TryGetValue(itemId, out DimmerData data)) { return(data); } DimmerData dimmerData = null; using (DatabaseConnection dbConnection = Engine.Locator.ConnectionPool.PopConnection()) { dbConnection.SetQuery("SELECT * FROM room_dimmer WHERE item_id = @itemId"); dbConnection.AddParameter("@itemId", itemId); using (var reader = dbConnection.ExecuteReader()) if (reader.Read()) { dimmerData = new DimmerData(reader, false); Dimmers.Add(dimmerData.ItemId, dimmerData); return(dimmerData); } else { return(NewDimmerData(itemId)); } } }
public void UpdateDimmerPreset(DimmerData data) { using (DatabaseConnection dbConnection = Engine.Locator.ConnectionPool.PopConnection()) { dbConnection.SetQuery("UPDATE room_dimmer SET enabled = @enabled, current_preset = @cur_preset, preset_one = @pres_one, preset_two = @pres_two, preset_three = @pres_three WHERE item_id = @item_id"); dbConnection.AddParameter("@enabled", data.Enabled ? 1 : 0); dbConnection.AddParameter("@cur_preset", data.CurrentPreset); dbConnection.AddParameter("@pres_one", data.Presets[0].PresetData()); dbConnection.AddParameter("@pres_two", data.Presets[1].PresetData()); dbConnection.AddParameter("@pres_three", data.Presets[2].PresetData()); dbConnection.AddParameter("@item_id", data.ItemId); dbConnection.Execute(); } }
public RoomDimmerPresetsMessageComposer(DimmerData data) : base(365) { AppendVL64(data.Presets.Count); AppendVL64(data.CurrentPreset); int i = 0; foreach (DimmerPreset preset in data.Presets) { i++; AppendVL64(i); AppendVL64((preset.BackgroundOnly ? 1 : 0) + 1); AppendString(preset.ColorCode); AppendVL64(preset.ColorIntensity); } }
public void Run(Client client, MessageEvent msgEvent) { Item item = client.CurrentRoom.GetWallItems().Where(x => x.Definition.HandleType == AuroraEmu.Game.Items.Handlers.HandleType.DIMMER).ToList()[0]; DimmerData data = Engine.Locator.ItemController.GetDimmerData(item.Id); if (data.Enabled) { data.Enabled = false; } else { data.Enabled = true; } item.Data = data.GenerateExtradata(); client.CurrentRoom.SendComposer(new ItemUpdateMessageComposer(item)); Engine.Locator.ItemController.Dao.UpdateItemData(item.Id, item.Data); }
public void Run(Client client, MessageEvent msgEvent) { Item item = client.CurrentRoom.GetWallItems().Where(x => x.Definition.HandleType == AuroraEmu.Game.Items.Handlers.HandleType.DIMMER).ToList()[0]; DimmerData data = Engine.Locator.ItemController.GetDimmerData(item.Id); int preset = msgEvent.ReadVL64(); int bgMode = msgEvent.ReadVL64(); string colorCode = msgEvent.ReadString(); int intensity = msgEvent.ReadVL64(); data.Enabled = true; data.CurrentPreset = preset; DimmerPreset dimmerPreset = data.Presets[preset]; dimmerPreset.BackgroundOnly = bgMode >= 2 ? true : false; dimmerPreset.ColorIntensity = intensity; dimmerPreset.ColorCode = colorCode; item.Data = data.GenerateExtradata(); client.SendComposer(new ItemUpdateMessageComposer(item)); Engine.Locator.ItemController.Dao.UpdateDimmerPreset(data); }