Beispiel #1
0
        public override TemplateObject Handle(TagData data)
        {
            if (data.Remaining == 0)
            {
                return(this);
            }
            switch (data[0])
            {
            // <--[tag]
            // @Name ColorTag.red
            // @Group General Information
            // @ReturnType NumberTag
            // @Returns the red value of this color.
            // @Example "0.1,0.2,0.3,1" .red returns "0.1".
            // -->
            case "red":
                return(new NumberTag(Internal.r).Handle(data.Shrink()));

            // <--[tag]
            // @Name ColorTag.green
            // @Group General Information
            // @ReturnType NumberTag
            // @Returns the green value of this color.
            // @Example "0.1,0.2,0.3,1" .green returns "0.2".
            // -->
            case "green":
                return(new NumberTag(Internal.g).Handle(data.Shrink()));

            // <--[tag]
            // @Name ColorTag.blue
            // @Group General Information
            // @ReturnType NumberTag
            // @Returns the blue value of this color.
            // @Example "0.1,0.2,0.3,1" .red returns "0.3".
            // -->
            case "blue":
                return(new NumberTag(Internal.b).Handle(data.Shrink()));

            // <--[tag]
            // @Name ColorTag.alpha
            // @Group General Information
            // @ReturnType NumberTag
            // @Returns the alpha value of this color.
            // @Example "0.1,0.2,0.3,1" .red returns "1".
            // -->
            case "alpha":
                return(new NumberTag(Internal.a).Handle(data.Shrink()));

            // <--[tag]
            // @Name ColorTag.mix[<ColorTag>|...]
            // @Group Mathematics
            // @ReturnType ColorTag
            // @Returns the result of mixing the specified color(s) with this one.
            // @Example "blue" .mix[red] returns "0.5,0,0.5,1"
            // -->
            case "mix":
            {
                ListTag list       = ListTag.For(data.GetModifierObject(0));
                Color   mixedColor = Internal;
                foreach (TemplateObject tcolor in list.ListEntries)
                {
                    ColorTag color = ColorTag.For(tcolor);
                    if (color == null)
                    {
                        SysConsole.Output(OutputType.ERROR, "Invalid color: " + TagParser.Escape(tcolor.ToString()));
                        continue;
                    }
                    mixedColor += color.Internal;
                }
                return(new ColorTag(mixedColor / list.ListEntries.Count).Handle(data.Shrink()));
            }

            default:
                return(new TextTag(ToString()).Handle(data));
            }
        }
 public override void UpdateVariables(Dictionary<string, TemplateObject> vars)
 {
     Color = ColorTag.For(vars["color"]);
     Text = new TextTag(vars["text"].ToString());
     ChatMode = new TextTag(vars["chat_mode"].ToString());
     base.UpdateVariables(vars);
 }