mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
* yay, a start on data driven particles * added data driven support for all particle profiles * pretty much finished all of the particle serialization code * resolved an inconsistency with the interpolators
29 lines
982 B
C#
29 lines
982 B
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using MonoGame.Extended.Serialization;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace MonoGame.Extended.Particles.Serialization
|
|
{
|
|
public class HslColorJsonConverter : JsonConverter
|
|
{
|
|
private readonly ColorJsonConverter _colorConverter = new ColorJsonConverter();
|
|
|
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
|
{
|
|
var color = ((HslColor) value).ToRgb();
|
|
_colorConverter.WriteJson(writer, color, serializer);
|
|
}
|
|
|
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
|
{
|
|
var color = (Color)_colorConverter.ReadJson(reader, objectType, existingValue, serializer);
|
|
return HslColor.FromRgb(color);
|
|
}
|
|
|
|
public override bool CanConvert(Type objectType)
|
|
{
|
|
return objectType == typeof(HslColor);
|
|
}
|
|
}
|
|
} |