Compare commits
	
		
			6 Commits
		
	
	
		
			988a6f67f2
			...
			2ef7fa6577
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2ef7fa6577 | |||
| 193b2c5af0 | |||
| a859c0cbff | |||
| fba64c3854 | |||
| a975cbb56b | |||
| 1664a9ccf7 | 
@@ -333,13 +333,13 @@ public readonly struct Quaternion(float x, float y, float z, float w) : IEquatab
 | 
			
		||||
    /// Generates a hash code for the <see cref="Quaternion"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns>A hash code for the <see cref="Quaternion"/>.</returns>
 | 
			
		||||
    public override int GetHashCode() => System.HashCode.Combine(W, X, Y, Z);
 | 
			
		||||
    public override int GetHashCode() => System.HashCode.Combine(X, Y, Z, W);
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Converts the <see cref="Quaternion"/> to its string representation.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <returns>A string representation of the <see cref="Quaternion"/>.</returns>
 | 
			
		||||
    public override string ToString() => $"{nameof(Quaternion)}({W}, {X}, {Y}, {Z})";
 | 
			
		||||
    public override string ToString() => $"{nameof(Quaternion)}({X}, {Y}, {Z}, {W})";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,12 @@ public class UniverseEntranceManager : Internal.BehaviourIndependent
 | 
			
		||||
 | 
			
		||||
    protected override void OnEnteredUniverse(IUniverse universe)
 | 
			
		||||
    {
 | 
			
		||||
        // FIXME: This causes an issue when the UniverseEntranceManager is already attached to a UniverseObject then registered into a Universe,
 | 
			
		||||
        // the enter/exit universe collectors call OnUniverseObjectRegistered internally on Assign, but since the Universe calls the OnUniverseObjectRegistered
 | 
			
		||||
        // event it tries to call OnUniverseObjectRegistered again on the same object, causing a duplicate entry error.
 | 
			
		||||
        Debug.Assert.AssertTrue(BehaviourController.Count == 1, $"{nameof(UniverseEntranceManager)} must be in it's own {nameof(IUniverseObject)} with no other {nameof(IBehaviour)}s attached at the moment. Failing to do so might cause instantiation or serialization issues.");
 | 
			
		||||
        enterUniverses.Assign(universe);
 | 
			
		||||
        exitUniverses.Assign(universe);
 | 
			
		||||
 | 
			
		||||
        foreach (IUniverseObject universeObject in universe.UniverseObjects)
 | 
			
		||||
            OnUniverseObjectRegistered(universe, new(universeObject));
 | 
			
		||||
@@ -28,6 +33,7 @@ public class UniverseEntranceManager : Internal.BehaviourIndependent
 | 
			
		||||
    protected override void OnExitedUniverse(IUniverse universe)
 | 
			
		||||
    {
 | 
			
		||||
        enterUniverses.Unassign();
 | 
			
		||||
        exitUniverses.Unassign();
 | 
			
		||||
 | 
			
		||||
        foreach (IUniverseObject universeObject in universe.UniverseObjects)
 | 
			
		||||
            OnUniverseObjectUnRegistered(universe, new(universeObject));
 | 
			
		||||
 
 | 
			
		||||
@@ -80,7 +80,7 @@ public class BehaviourControllerConverter : EngineTypeYamlSerializerBase<IBehavi
 | 
			
		||||
        serializer(behaviourController.StateEnable);
 | 
			
		||||
 | 
			
		||||
        emitter.Emit(new Scalar(BEHAVIOURS_SCALAR_NAME));
 | 
			
		||||
        serializer(behaviourController.GetBehaviours<IBehaviour>().Where(b => !b.GetType().HasAttribute<IgnoreSerializationAttribute>()));
 | 
			
		||||
        serializer(behaviourController.GetBehaviours<IBehaviour>().Where(b => !b.GetType().HasAttribute<IgnoreSerializationAttribute>()).Reverse());
 | 
			
		||||
 | 
			
		||||
        ProgressionTracker.Set(isTrackingController ? 1f : ProgressionTracker.Progression, $"Serialized behaviour controller");
 | 
			
		||||
        emitter.Emit(new MappingEnd());
 | 
			
		||||
 
 | 
			
		||||
@@ -20,8 +20,8 @@ public class SerializedClassConverter : EngineTypeYamlSerializerBase<SerializedC
 | 
			
		||||
        ProgressionTracker.Set(isTrackingController ? .1f : ProgressionTracker.Progression, $"Reading class");
 | 
			
		||||
 | 
			
		||||
        SerializedClass serializedClass = new();
 | 
			
		||||
        Dictionary<string, TypeContainer> publicDictionary = [];
 | 
			
		||||
        Dictionary<string, TypeContainer> privateDictionary = [];
 | 
			
		||||
        Dictionary<string, object> publicDictionary = [];
 | 
			
		||||
        Dictionary<string, object> privateDictionary = [];
 | 
			
		||||
 | 
			
		||||
        parser.Consume<MappingStart>();
 | 
			
		||||
 | 
			
		||||
@@ -32,16 +32,24 @@ public class SerializedClassConverter : EngineTypeYamlSerializerBase<SerializedC
 | 
			
		||||
            switch (key)
 | 
			
		||||
            {
 | 
			
		||||
                case nameof(SerializedClass.Type): serializedClass.Type = parser.Consume<Scalar>().Value; break;
 | 
			
		||||
                case nameof(SerializedClass.Public): publicDictionary = (Dictionary<string, TypeContainer>)rootDeserializer(typeof(Dictionary<string, TypeContainer>))!; break;
 | 
			
		||||
                case nameof(SerializedClass.Private): privateDictionary = (Dictionary<string, TypeContainer>)rootDeserializer(typeof(Dictionary<string, TypeContainer>))!; break;
 | 
			
		||||
                case nameof(SerializedClass.Public): publicDictionary = (Dictionary<string, object>)rootDeserializer(typeof(Dictionary<string, object>))!; break;
 | 
			
		||||
                case nameof(SerializedClass.Private): privateDictionary = (Dictionary<string, object>)rootDeserializer(typeof(Dictionary<string, object>))!; break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ((string key, TypeContainer typeContainer) in publicDictionary)
 | 
			
		||||
            serializedClass.Public.Add(key, Serializer.InternalDeserialize(typeContainer.Value!.ToString()!, TypeFactory.GetType(typeContainer.Type)));
 | 
			
		||||
        Type classType = TypeFactory.GetType(serializedClass.Type);
 | 
			
		||||
 | 
			
		||||
        foreach ((string key, TypeContainer typeContainer) in privateDictionary)
 | 
			
		||||
            serializedClass.Private.Add(key, Serializer.InternalDeserialize(typeContainer.Value!.ToString()!, TypeFactory.GetType(typeContainer.Type)));
 | 
			
		||||
        foreach ((string key, object @object) in publicDictionary)
 | 
			
		||||
            if (@object is TypeContainer typeContainer)
 | 
			
		||||
                serializedClass.Public.Add(key, Serializer.InternalDeserialize(typeContainer.Value!.ToString()!, TypeFactory.GetType(typeContainer.Type)));
 | 
			
		||||
            else
 | 
			
		||||
                serializedClass.Public.Add(key, Serializer.InternalDeserialize(@object.ToString()!, (classType.GetProperty(key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)?.PropertyType ?? classType.GetField(key, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)?.FieldType)!));
 | 
			
		||||
 | 
			
		||||
        foreach ((string key, object @object) in privateDictionary)
 | 
			
		||||
            if (@object is TypeContainer typeContainer)
 | 
			
		||||
                serializedClass.Private.Add(key, Serializer.InternalDeserialize(typeContainer.Value!.ToString()!, TypeFactory.GetType(typeContainer.Type)));
 | 
			
		||||
            else
 | 
			
		||||
                serializedClass.Private.Add(key, Serializer.InternalDeserialize(@object.ToString()!, (classType.GetProperty(key, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Default)?.PropertyType ?? classType.GetField(key, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Default)?.FieldType)!));
 | 
			
		||||
 | 
			
		||||
        ProgressionTracker.Set(isTrackingController ? 1f : ProgressionTracker.Progression, $"Read {serializedClass.Type}");
 | 
			
		||||
        return serializedClass;
 | 
			
		||||
@@ -54,14 +62,20 @@ public class SerializedClassConverter : EngineTypeYamlSerializerBase<SerializedC
 | 
			
		||||
        bool isTrackingController = ProgressionTracker.Progression.ApproximatelyEquals(0f);
 | 
			
		||||
        ProgressionTracker.Set(isTrackingController ? .25f : ProgressionTracker.Progression, $"Serializing {serializedClass.Type}");
 | 
			
		||||
 | 
			
		||||
        Dictionary<string, TypeContainer> publics = [];
 | 
			
		||||
        Dictionary<string, TypeContainer> privates = [];
 | 
			
		||||
        Dictionary<string, object> publics = [];
 | 
			
		||||
        Dictionary<string, object> privates = [];
 | 
			
		||||
 | 
			
		||||
        foreach ((string key, object? @object) in serializedClass.Public.Where(v => !v.GetType().HasAttribute<IgnoreSerializationAttribute>()))
 | 
			
		||||
            publics.Add(key, new TypeContainer(@object));
 | 
			
		||||
            if (@object?.GetType().IsClass == false)
 | 
			
		||||
                publics.Add(key, @object!);
 | 
			
		||||
            else
 | 
			
		||||
                publics.Add(key, new TypeContainer(@object));
 | 
			
		||||
 | 
			
		||||
        foreach ((string key, object? @object) in serializedClass.Private.Where(v => !v.GetType().HasAttribute<IgnoreSerializationAttribute>()))
 | 
			
		||||
            privates.Add(key, new TypeContainer(@object));
 | 
			
		||||
            if (@object?.GetType().IsClass == false)
 | 
			
		||||
                privates.Add(key, @object!);
 | 
			
		||||
            else
 | 
			
		||||
                privates.Add(key, new TypeContainer(@object));
 | 
			
		||||
 | 
			
		||||
        emitter.Emit(new MappingStart());
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user