Ejemplo n.º 1
0
        public string method_7()
        {
            MoodlightPreset @class        = this.method_4(this.CurrentPreset);
            StringBuilder   stringBuilder = new StringBuilder();

            if (this.Enabled)
            {
                stringBuilder.Append(2);
            }
            else
            {
                stringBuilder.Append(1);
            }
            stringBuilder.Append(",");
            stringBuilder.Append(this.CurrentPreset);
            stringBuilder.Append(",");
            if (@class.BackgroundOnly)
            {
                stringBuilder.Append(2);
            }
            else
            {
                stringBuilder.Append(1);
            }
            stringBuilder.Append(",");
            stringBuilder.Append(@class.ColorCode);
            stringBuilder.Append(",");
            stringBuilder.Append(@class.ColorIntensity);
            return(stringBuilder.ToString());
        }
Ejemplo n.º 2
0
        private static void UpdateMoodlight(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session, true))
            {
                return;
            }

            Item Item = Instance.MoodlightItem;

            if (Item == null)
            {
                return;
            }

            MoodlightData   Data     = MoodlightData.GenerateFromFlags(Item.Flags);
            int             PresetId = Message.PopWiredInt32();
            MoodlightPreset Preset   = null;

            if (Data.Presets.ContainsKey(PresetId))
            {
                Preset = Data.Presets[PresetId];
            }

            if (Preset == null)
            {
                return;
            }

            Preset.BackgroundOnly = !Message.PopWiredBoolean();
            Preset.ColorCode      = UserInputFilter.FilterString(Message.PopString().Trim());
            Preset.ColorIntensity = Message.PopWiredInt32();

            if (!MoodlightData.IsValidColor(Preset.ColorCode))
            {
                return;
            }

            Item.Flags        = Data.ToItemFlagData();
            Item.DisplayFlags = Data.ToDisplayData();

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                Item.SynchronizeDatabase(MySqlClient, true);
            }

            Item.BroadcastStateUpdate(Instance);
        }
Ejemplo n.º 3
0
        public MoodlightPreset method_4(int int_1)
        {
            int_1--;
            MoodlightPreset result;

            if (this.Presets[int_1] != null)
            {
                result = this.Presets[int_1];
            }
            else
            {
                result = new MoodlightPreset("#000000", 255, false);
            }
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Generates the extra data.
        /// </summary>
        /// <returns>System.String.</returns>
        internal string GenerateExtraData()
        {
            MoodlightPreset preset        = GetPreset(CurrentPreset);
            StringBuilder   stringBuilder = new StringBuilder();

            stringBuilder.Append(Enabled ? 2 : 1);
            stringBuilder.Append(",");
            stringBuilder.Append(CurrentPreset);
            stringBuilder.Append(",");
            stringBuilder.Append(preset.BackgroundOnly ? 2 : 1);
            stringBuilder.Append(",");
            stringBuilder.Append(preset.ColorCode);
            stringBuilder.Append(",");
            stringBuilder.Append(preset.ColorIntensity);
            return(stringBuilder.ToString());
        }
Ejemplo n.º 5
0
        public override void Compose(Yupi.Protocol.ISender session, MoodlightData moodlight)
        {
            using (ServerMessage message = Pool.GetMessageBuffer(Id))
            {
                message.AppendInteger(moodlight.Presets.Count);
                message.AppendInteger(moodlight.CurrentPreset.Id);

                for (int i = 0; i < moodlight.Presets.Count; ++i)
                {
                    MoodlightPreset preset = moodlight.Presets[i];
                    message.AppendInteger(i);
                    message.AppendInteger(preset.BackgroundOnly ? 2 : 1);
                    message.AppendString(preset.ColorCode);
                    message.AppendInteger(preset.ColorIntensity);
                }
                session.Send(message);
            }
        }