mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 20:12:23 +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
28 lines
776 B
C#
28 lines
776 B
C#
using System;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace MonoGame.Extended.Particles.Serialization
|
|
{
|
|
public class TimeSpanJsonConverter : JsonConverter
|
|
{
|
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
|
{
|
|
}
|
|
|
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
|
{
|
|
if (reader.ValueType == typeof(double))
|
|
{
|
|
var seconds = (double) reader.Value;
|
|
return TimeSpan.FromSeconds(seconds);
|
|
}
|
|
|
|
return TimeSpan.Zero;
|
|
}
|
|
|
|
public override bool CanConvert(Type objectType)
|
|
{
|
|
return objectType == typeof(TimeSpan);
|
|
}
|
|
}
|
|
} |