mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Update source gen reference
This commit is contained in:
parent
bc861df741
commit
8c90f55be8
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetRipper.SourceGenerated" Version="1.0.12" />
|
||||
<PackageReference Include="AssetRipper.SourceGenerated" Version="1.0.13" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
|
||||
@ -110,65 +110,17 @@ internal sealed partial record class GameInitializer
|
||||
{
|
||||
IGameObject newGameObject = (IGameObject)replacement;
|
||||
PPtrConverter converter = new(gameObject, newGameObject);
|
||||
if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_3_5())
|
||||
if (newGameObject.Components.Count > 0 && newGameObject.Components[0].Has_ClassID() && !gameObject.Components[0].Has_ClassID())
|
||||
{
|
||||
if (newGameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_5())
|
||||
foreach (IComponentPair pair in newGameObject.Components)
|
||||
{
|
||||
foreach (AssetPair<int, PPtr_Component_3_5> pair in gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5)
|
||||
if (pair.Component.TryGetAsset(newGameObject.Collection, out IComponent? component))
|
||||
{
|
||||
AssetPair<int, PPtr_Component_5> newPair = newGameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5.AddNew();
|
||||
newPair.Key = pair.Key;
|
||||
newPair.Value.CopyValues(pair.Value, converter);
|
||||
pair.ClassID = component.ClassID;
|
||||
}
|
||||
}
|
||||
else if (newGameObject.Has_Component_AssetList_ComponentPair())
|
||||
{
|
||||
foreach (AssetPair<int, PPtr_Component_3_5> pair in gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5)
|
||||
else
|
||||
{
|
||||
newGameObject.Component_AssetList_ComponentPair.AddNew().Component.CopyValues(pair.Value, converter);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_5())
|
||||
{
|
||||
if (newGameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_3_5())
|
||||
{
|
||||
foreach (AssetPair<int, PPtr_Component_5> pair in gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5)
|
||||
{
|
||||
AssetPair<int, PPtr_Component_3_5> newPair = newGameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5.AddNew();
|
||||
newPair.Key = pair.Key;
|
||||
newPair.Value.CopyValues(pair.Value, converter);
|
||||
}
|
||||
}
|
||||
else if (newGameObject.Has_Component_AssetList_ComponentPair())
|
||||
{
|
||||
foreach (AssetPair<int, PPtr_Component_5> pair in gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5)
|
||||
{
|
||||
newGameObject.Component_AssetList_ComponentPair.AddNew().Component.CopyValues(pair.Value, converter);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(gameObject.Has_Component_AssetList_ComponentPair());
|
||||
if (newGameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_3_5())
|
||||
{
|
||||
foreach (ComponentPair pair in gameObject.Component_AssetList_ComponentPair)
|
||||
{
|
||||
IComponent? component = gameObject.Collection.TryGetAsset<IComponent>(pair.Component);
|
||||
AssetPair<int, PPtr_Component_3_5> newPair = newGameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5.AddNew();
|
||||
newPair.Key = component?.ClassID ?? (int)ClassIDType.Component;
|
||||
newPair.Value.SetAsset(newGameObject.Collection, component);
|
||||
}
|
||||
}
|
||||
else if (newGameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_5())
|
||||
{
|
||||
foreach (ComponentPair pair in gameObject.Component_AssetList_ComponentPair)
|
||||
{
|
||||
IComponent? component = gameObject.Collection.TryGetAsset<IComponent>(pair.Component);
|
||||
AssetPair<int, PPtr_Component_5> newPair = newGameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5.AddNew();
|
||||
newPair.Key = component?.ClassID ?? (int)ClassIDType.Component;
|
||||
newPair.Value.SetAsset(newGameObject.Collection, component);
|
||||
pair.ClassID = (int)ClassIDType.Component;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetRipper.SourceGenerated" Version="1.0.12" />
|
||||
<PackageReference Include="AssetRipper.SourceGenerated" Version="1.0.13" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -44,86 +44,24 @@ namespace AssetRipper.SourceGenerated.Extensions
|
||||
|
||||
public static IEnumerable<IPPtr_Component> FetchComponents(this IGameObject gameObject)
|
||||
{
|
||||
if (gameObject.Has_Component_AssetList_ComponentPair())
|
||||
{
|
||||
return gameObject.Component_AssetList_ComponentPair.Select(pair => pair.Component);
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_3_5())
|
||||
{
|
||||
return gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5.Select(pair => pair.Value);
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_5())
|
||||
{
|
||||
return gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5.Select(pair => pair.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("All three component properties returned null");
|
||||
}
|
||||
return gameObject.Components.Select(pair => pair.Component);
|
||||
}
|
||||
|
||||
public static AccessListBase<IPPtr_Component> GetComponentPPtrList(this IGameObject gameObject)
|
||||
{
|
||||
if (gameObject.Has_Component_AssetList_ComponentPair())
|
||||
{
|
||||
return new ComponentPairAccessList(gameObject.Component_AssetList_ComponentPair);
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_3_5())
|
||||
{
|
||||
return new AssetPairAccessList<PPtr_Component_3_5>(gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5);
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_5())
|
||||
{
|
||||
return new AssetPairAccessList<PPtr_Component_5>(gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("All three component properties returned null");
|
||||
}
|
||||
return new ComponentPairAccessList(gameObject.Components);
|
||||
}
|
||||
|
||||
public static int GetComponentCount(this IGameObject gameObject)
|
||||
{
|
||||
if (gameObject.Has_Component_AssetList_ComponentPair())
|
||||
{
|
||||
return gameObject.Component_AssetList_ComponentPair.Count;
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_3_5())
|
||||
{
|
||||
return gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5.Count;
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_5())
|
||||
{
|
||||
return gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("All three component properties returned null");
|
||||
}
|
||||
return gameObject.Components.Count;
|
||||
}
|
||||
|
||||
public static void AddComponent(this IGameObject gameObject, ClassIDType classID, IComponent component)
|
||||
{
|
||||
if (gameObject.Has_Component_AssetList_ComponentPair())
|
||||
{
|
||||
gameObject.Component_AssetList_ComponentPair.AddNew().Component.SetAsset(gameObject.Collection, component);
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_3_5())
|
||||
{
|
||||
AssetPair<int, PPtr_Component_3_5> pair = gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_3_5.AddNew();
|
||||
pair.Key = (int)classID;
|
||||
pair.Value.SetAsset(gameObject.Collection, component);
|
||||
}
|
||||
else if (gameObject.Has_Component_AssetList_AssetPair_Int32_PPtr_Component_5())
|
||||
{
|
||||
AssetPair<int, PPtr_Component_5> pair = gameObject.Component_AssetList_AssetPair_Int32_PPtr_Component_5.AddNew();
|
||||
pair.Key = (int)classID;
|
||||
pair.Value.SetAsset(gameObject.Collection, component);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("All three component properties returned null");
|
||||
}
|
||||
IComponentPair pair = gameObject.Components.AddNew();
|
||||
pair.ClassID = (int)classID;
|
||||
pair.Component.SetAsset(gameObject.Collection, component);
|
||||
}
|
||||
|
||||
public static PPtrAccessList<IPPtr_Component, IComponent> GetComponentAccessList(this IGameObject gameObject)
|
||||
@ -262,9 +200,9 @@ namespace AssetRipper.SourceGenerated.Extensions
|
||||
|
||||
private sealed class ComponentPairAccessList : AccessListBase<IPPtr_Component>
|
||||
{
|
||||
private readonly AssetList<ComponentPair> referenceList;
|
||||
private readonly AccessListBase<IComponentPair> referenceList;
|
||||
|
||||
public ComponentPairAccessList(AssetList<ComponentPair> referenceList)
|
||||
public ComponentPairAccessList(AccessListBase<IComponentPair> referenceList)
|
||||
{
|
||||
this.referenceList = referenceList;
|
||||
}
|
||||
@ -286,7 +224,11 @@ namespace AssetRipper.SourceGenerated.Extensions
|
||||
|
||||
public override IPPtr_Component AddNew()
|
||||
{
|
||||
return referenceList.AddNew().Component;
|
||||
IComponentPair componentPair = referenceList.AddNew();
|
||||
componentPair.ClassID = (int)ClassIDType.Component;
|
||||
return componentPair.Component;
|
||||
//throw new NotSupportedException();
|
||||
//Not sure the above code is safe since Unity might rely on the class id being correct.
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
@ -341,91 +283,5 @@ namespace AssetRipper.SourceGenerated.Extensions
|
||||
referenceList.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class AssetPairAccessList<T> : AccessListBase<IPPtr_Component> where T : IPPtr_Component, new()
|
||||
{
|
||||
private readonly AssetList<AssetPair<int, T>> referenceList;
|
||||
|
||||
public AssetPairAccessList(AssetList<AssetPair<int, T>> referenceList)
|
||||
{
|
||||
this.referenceList = referenceList;
|
||||
}
|
||||
|
||||
public override IPPtr_Component this[int index]
|
||||
{
|
||||
get => referenceList[index].Value;
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override int Count => referenceList.Count;
|
||||
|
||||
public override int Capacity { get => referenceList.Capacity; set => referenceList.Capacity = value; }
|
||||
|
||||
public override void Add(IPPtr_Component item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override IPPtr_Component AddNew()
|
||||
{
|
||||
//AssetPair<int, T> pair = referenceList.AddNew();
|
||||
//pair.Key = 2;
|
||||
//return pair.Value;
|
||||
throw new NotSupportedException();
|
||||
//Not sure the above code is safe since Unity might rely on the class id being correct.
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
referenceList.Clear();
|
||||
}
|
||||
|
||||
public override bool Contains(IPPtr_Component item)
|
||||
{
|
||||
return referenceList.Any(ptr => ptr.Value.Equals(item));
|
||||
}
|
||||
|
||||
public override void CopyTo(IPPtr_Component[] array, int arrayIndex)
|
||||
{
|
||||
for (int i = 0; i < referenceList.Count; i++)
|
||||
{
|
||||
array[i + arrayIndex] = referenceList[i].Value;
|
||||
}
|
||||
}
|
||||
|
||||
public override int EnsureCapacity(int capacity)
|
||||
{
|
||||
return referenceList.EnsureCapacity(capacity);
|
||||
}
|
||||
|
||||
public override int IndexOf(IPPtr_Component item)
|
||||
{
|
||||
return referenceList.IndexOf(pair => pair.Value.Equals(item));
|
||||
}
|
||||
|
||||
public override void Insert(int index, IPPtr_Component item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override bool Remove(IPPtr_Component item)
|
||||
{
|
||||
int index = IndexOf(item);
|
||||
if (index < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveAt(index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RemoveAt(int index)
|
||||
{
|
||||
referenceList.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ namespace AssetRipper.Tests.Traversal;
|
||||
|
||||
internal sealed class ComponentListObject : CustomInjectedObjectBase
|
||||
{
|
||||
private readonly AssetList<ComponentPair> m_Component = new();
|
||||
private readonly AssetList<ComponentPair_5_5> m_Component = new();
|
||||
|
||||
public const string Yaml = """
|
||||
%YAML 1.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user