26 lines
1.1 KiB
C#
26 lines
1.1 KiB
C#
|
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<BehaviourDTO> ToDTO(this IBehaviourController behaviourController)
|
||
|
{
|
||
|
List<BehaviourDTO> dtos = [];
|
||
|
foreach (var behaviour in behaviourController)
|
||
|
dtos.Add(new(behaviour.GetType().FullName ?? throw new System.Exception(), behaviour.Priority, behaviour.StateEnable.ToDTO()));
|
||
|
return dtos;
|
||
|
}
|
||
|
}
|