using System.Collections.Generic; using Engine.Serialization.DTOs; using Syntriax.Engine.Core.Abstract; namespace Engine.Serialization; internal static class InternalExtensions { public static TransformDTO ToDTO(this ITransform transform) => new(transform.Parent?.GameObject.Id, transform.Position, transform.Scale, transform.Rotation); public static GameObjectDTO ToDTO(this IGameObject gameObject) => new(gameObject.Id, gameObject.Name, gameObject.Transform.ToDTO(), gameObject.BehaviourController.ToDTO(), gameObject.StateEnable.ToDTO()); public static StateEnableDTO ToDTO(this IStateEnable stateEnable) => new(stateEnable.GetType().FullName ?? throw new System.Exception(), stateEnable.Enabled); public static List ToDTO(this IBehaviourController behaviourController) { List dtos = []; foreach (var behaviour in behaviourController) dtos.Add(new(behaviour.GetType().FullName ?? throw new System.Exception(), behaviour.Priority, behaviour.StateEnable.ToDTO())); return dtos; } }