using MoonSharp.Interpreter; using Ripple_Data.Control; using Ripple_Data.Control.Commands; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.Serialization; namespace Ripple_Data.Base { [MoonSharpUserData] public class Ripple : IIdentifyable { public string Name { get; private set; } public string? Description { get; private set; } public List<IIdentifyable> Objects { get; protected set; } = new List<IIdentifyable>(); public int ID { get; protected set; } private static bool InstancesCreated { get; set; } = false; public IIdentifyable Self { get; protected set; } public List<GameRule> Rules { get; protected set; } = new List<GameRule>(); public List<Condition> Conditions { get; protected set; } = new List<Condition>(); protected static int GiveID(Ripple obj) { RippleManager.Initialize(obj); var query = RippleManager.All.Where(x => x.GetType() == obj.GetType()).First(); return query == null ? throw new ArgumentNullException("No types initialized!") : query.Objects.Count; } public static IIdentifyable GetInstance<TRippleType>(TRippleType obj) where TRippleType : IIdentifyable { RippleManager.Initialize(obj); return RippleManager.All.Where(x => x.GetType() == typeof(TRippleType)).First(); } List<IIdentifyable> IIdentifyable.GetObjects() { return this.Objects; } List<List<IIdentifyable>> IIdentifyable.GetAll() { var list= new List<List<IIdentifyable>>(); foreach (var ripple in RippleManager.All.ToList()) { list.Add(ripple.Objects); } return list; } public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new NotImplementedException(); } //Full Constructor public Ripple(string Name, string? Description = null) { this.Name= Name; this.Description= Description; Self = this; } public Ripple() { Name = string.Empty; Self = this; } } }