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.GetType().FullName ?? throw new System.Exception(), transform.Parent?.GameObject.Id, transform.Position, transform.Scale, transform.Rotation); public static GameObjectDTO ToDTO(this IGameObject gameObject) => new(gameObject.GetType().FullName ?? throw new System.Exception(), 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 BehaviourControllerDTO 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 new(behaviourController.GetType().FullName ?? throw new System.Exception(), dtos); } public static BehaviourDTO ToDTO(this IBehaviour behaviour) => new(behaviour.GetType().FullName ?? throw new System.Exception(), behaviour.Priority, behaviour.StateEnable.ToDTO()); }