Exemplo n.º 1
0
        /// <summary>
        /// Handle create messages.
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="packet"></param>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected virtual Error HandleMessage(CreateMessage msg, PacketBuffer packet, BinaryReader reader)
        {
            TextEntry text = new TextEntry();

            text.ID          = msg.ObjectID;
            text.ObjectFlags = msg.Flags;
            text.Category    = msg.Category;
            text.Position    = new Vector3(msg.Attributes.X, msg.Attributes.Y, msg.Attributes.Z);
            text.Colour      = ShapeComponent.ConvertColour(msg.Attributes.Colour);
            text.Active      = CategoryCheck(text.Category);

            // Read the text.
            int textLength = reader.ReadUInt16();

            if (textLength > 0)
            {
                byte[] textBytes = reader.ReadBytes(textLength);
                text.Text = System.Text.Encoding.UTF8.GetString(textBytes);
            }

            if (msg.ObjectID == 0)
            {
                TransientText.Add(text);
            }
            else
            {
                PersistentText.Add(text);
            }

            return(new Error());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Start the frame by flushing transient objects.
 /// </summary>
 /// <param name="frameNumber">A monotonic frame number.</param>
 /// <param name="maintainTransient">True to disable transient flush.</param>
 public override void BeginFrame(uint frameNumber, bool maintainTransient)
 {
     if (!maintainTransient)
     {
         TransientText.Clear();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Handle create messages.
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="packet"></param>
        /// <param name="reader"></param>
        /// <returns></returns>
        protected virtual Error HandleMessage(CreateMessage msg, PacketBuffer packet, BinaryReader reader)
        {
            TextEntry text = new TextEntry();

            text.ID          = msg.ObjectID;
            text.ObjectFlags = msg.Flags;
            text.Category    = msg.Category;
            text.Position    = new Vector3(msg.Attributes.X, msg.Attributes.Y, msg.Attributes.Z);
            text.Colour      = Maths.ColourExt.ToUnity32(new Maths.Colour(msg.Attributes.Colour));

            // Read the text.
            int textLength = reader.ReadUInt16();

            if (textLength > 0)
            {
                byte[] textBytes = reader.ReadBytes(textLength);
                text.Text = System.Text.Encoding.UTF8.GetString(textBytes);
            }

            if (msg.ObjectID == 0)
            {
                TransientText.Add(text);
            }
            else
            {
                if (PersistentText.ContainsEntry(text.ID))
                {
                    // Object ID already present. Check for replace flag.
                    if ((msg.Flags & (ushort)ObjectFlag.Replace) == 0)
                    {
                        // Not replace flag => error.
                        return(new Error(ErrorCode.DuplicateShape, msg.ObjectID));
                    }

                    // Replace.
                    PersistentText.Remove(text.ID);
                }
                PersistentText.Add(text);
            }

            return(new Error());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Reset, clearing all text objects.
 /// </summary>
 public override void Reset()
 {
     PersistentText.Clear();
     TransientText.Clear();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Handle category activation changes.
 /// </summary>
 /// <param name="categoryId"></param>
 /// <param name="active"></param>
 public override void OnCategoryChange(ushort categoryId, bool active)
 {
     PersistentText.CategoryActive(categoryId, active);
     TransientText.CategoryActive(categoryId, active);
 }