2024-07-25 05:40:31 +00:00
|
|
|
using Godot;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
public class SceneFileObject
|
|
|
|
{
|
|
|
|
protected SceneFileEntry _headerEntry;
|
|
|
|
protected List<SceneFileHeaderAttributeValue> _attributes = new List<SceneFileHeaderAttributeValue>();
|
2025-02-12 16:48:15 +00:00
|
|
|
protected List<SceneFileEntry> _data = new List<SceneFileEntry>();
|
|
|
|
|
|
|
|
public List<SceneFileEntry> data => _data;
|
2024-07-25 05:40:31 +00:00
|
|
|
|
|
|
|
public SceneFileObject()
|
|
|
|
{
|
|
|
|
SetAttributes();
|
|
|
|
}
|
|
|
|
|
2025-02-12 16:48:15 +00:00
|
|
|
public SceneFileNamedValue GetMember( string name )
|
|
|
|
{
|
|
|
|
var entry = _data.Find( d => d.member != null && d.member.name == name );
|
|
|
|
return entry == null ? null : entry.member;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddData( SceneFileEntry se )
|
|
|
|
{
|
|
|
|
if ( SceneFileLinesLexer.SeperatorMatcher.Matches( se.type ) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_data.Add( se );
|
|
|
|
}
|
|
|
|
|
2024-07-25 05:40:31 +00:00
|
|
|
public void CreateFromHeaderEntry( SceneFileEntry headerEntry )
|
|
|
|
{
|
|
|
|
ReadAttributes( headerEntry.header );
|
|
|
|
|
2025-02-12 16:48:15 +00:00
|
|
|
_CreateFromHeaderEntry( headerEntry );
|
2024-07-25 05:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void _CreateFromHeaderEntry( SceneFileEntry headerEntry )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void SetAttributes()
|
|
|
|
{
|
2024-11-12 08:03:36 +00:00
|
|
|
_attributes = ReflectionHelper.GetFieldValuesOfType<SceneFileHeaderAttributeValue>( this );
|
2024-07-25 05:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void ReadAttributes( SceneFileHeader entry )
|
|
|
|
{
|
|
|
|
_attributes.ForEach( a => a.GetValue( entry ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|