Skip to content

Update packages and remove legacy particle system stuff #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ArrayEditing/ArrayEditing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageId>ArrayEditing</PackageId>
<Title>Array Editing</Title>
<Authors>Banane9, Nytra</Authors>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Description>Adds proxy list UI for editing arrays in inspectors. Also improves the look of list UI a bit.</Description>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/ResoniteModdingGroup/ArrayEditing</PackageProjectUrl>
Expand All @@ -36,18 +36,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MicroUtils.HarmonyAnalyzers" Version="1.3.0">
<PackageReference Include="MicroUtils.HarmonyAnalyzers" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MonkeyLoader.GamePacks.Resonite" Version="0.20.0-beta" GeneratePathProperty="true" />
<PackageReference Include="PolySharp" Version="1.14.1">
<PackageReference Include="MonkeyLoader.GamePacks.Resonite" Version="0.21.2-beta" GeneratePathProperty="true" />
<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Resonite.Elements.Core" Version="1.3.1" />
<PackageReference Include="Resonite.FrooxEngine" Version="2024.9.31.1216" />
<PackageReference Include="System.Text.Json" Version="8.0.4">
<PackageReference Include="Resonite.Elements.Core" Version="1.4.3" />
<PackageReference Include="Resonite.FrooxEngine" Version="2025.1.17.6" />
<PackageReference Include="System.Text.Json" Version="9.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
76 changes: 2 additions & 74 deletions ArrayEditing/ArrayEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
private static readonly MethodInfo _addListReferenceProxying = AccessTools.Method(typeof(ArrayEditor), nameof(AddListReferenceProxying));
private static readonly MethodInfo _addListValueProxying = AccessTools.Method(typeof(ArrayEditor), nameof(AddListValueProxying));
private static readonly Type _iWorldElementType = typeof(IWorldElement);
private static readonly Type _particleBurstType = typeof(ParticleBurst);

private static readonly MethodInfo _setLinearPoint = AccessTools.Method(typeof(ArrayEditor), nameof(SetLinearPoint));
private static readonly MethodInfo _setCurvePoint = AccessTools.Method(typeof(ArrayEditor), nameof(SetCurvePoint));
Expand Down Expand Up @@ -184,41 +183,6 @@
};
}

private static void AddParticleBurstListProxying(SyncArray<LinearKey<ParticleBurst>> array, SyncElementList<ValueGradientDriver<int2>.Point> list)
{
foreach (var burst in array)
{
var point = list.Add();
point.Position.Value = burst.time;
point.Value.Value = new int2(burst.value.minCount, burst.value.maxCount);
}

AddUpdateProxies(array, list, list.Elements);

list.ElementsAdded += (list, startIndex, count) =>
{
var addedElements = list.Elements.Skip(startIndex).Take(count).ToArray();
var buffer = addedElements.Select(point => new LinearKey<ParticleBurst>(point.Position, new ParticleBurst() { minCount = point.Value.Value.x, maxCount = point.Value.Value.y })).ToArray();

if (!_skipListChanges)
{
array.Changed -= ArrayChanged;
array.Insert(buffer, startIndex);
array.Changed += ArrayChanged;
}
AddUpdateProxies(array, list, addedElements);
};

list.ElementsRemoved += (list, startIndex, count) =>
{
if (_skipListChanges) return;
if (array.Count < startIndex + count) return;
array.Changed -= ArrayChanged;
array.Remove(startIndex, count);
array.Changed += ArrayChanged;
};
}

private static void AddTubePointProxying(SyncArray<TubePoint> array, SyncElementList<ValueGradientDriver<float3>.Point> list)
{
foreach (var tubePoint in array)
Expand Down Expand Up @@ -271,23 +235,6 @@
}
}

private static void AddUpdateProxies(SyncArray<LinearKey<ParticleBurst>> array,
SyncElementList<ValueGradientDriver<int2>.Point> list, IEnumerable<ValueGradientDriver<int2>.Point> elements)
{
foreach (var point in elements)
{
point.Changed += field =>
{
if (_skipListChanges) return;
var index = list.IndexOfElement(point);
var key = new LinearKey<ParticleBurst>(point.Position, new ParticleBurst() { minCount = point.Value.Value.x, maxCount = point.Value.Value.y });
array.Changed -= ArrayChanged;
array[index] = key;
array.Changed += ArrayChanged;
};
}
}

private static void AddUpdateProxies<T>(SyncArray<T> array, SyncElementList<Sync<T>> list, IEnumerable<Sync<T>> elements)
where T : IEquatable<T>
{
Expand Down Expand Up @@ -366,11 +313,6 @@
var syncLinearType = syncLinearGenericParameters?.First();
var syncCurveType = syncCurveGenericParameters?.First();

var isParticleBurst = syncLinearType == _particleBurstType;

if (isSyncLinear && isParticleBurst)
syncLinearType = typeof(int2);

var proxySlotName = $"{name}-{array.ReferenceID}-Proxy";
var proxiesSlot = ui.World.AssetsSlot;
var newProxy = false;
Expand All @@ -395,10 +337,7 @@

if (attachedNew)
{
if (isParticleBurst)
AddParticleBurstListProxying((SyncArray<LinearKey<ParticleBurst>>)array, (SyncElementList<ValueGradientDriver<int2>.Point>)list);
else
_addLinearValueProxying.MakeGenericMethod(syncLinearType).Invoke(null, [array, list]);
_addLinearValueProxying.MakeGenericMethod(syncLinearType).Invoke(null, [array, list]);
}
}
else if (isSyncCurve && SupportsLerp(syncCurveType!))
Expand Down Expand Up @@ -494,13 +433,6 @@
return true;
}

// doesn't work?
static void SetParticlePoint(ValueGradientDriver<int2>.Point point, LinearKey<ParticleBurst> arrayElem)
{
point.Position.Value = arrayElem.time;
point.Value.Value = new int2(arrayElem.value.minCount, arrayElem.value.maxCount);
}

static void SetLinearPoint<T>(ValueGradientDriver<T>.Point point, LinearKey<T> arrayElem) where T : IEquatable<T>
{
point.Position.Value = arrayElem.time;
Expand Down Expand Up @@ -540,7 +472,7 @@
{
list = comp.GetSyncMember("Values") as ISyncList;
_skipListChanges = true;
list.World.RunSynchronously(() => _skipListChanges = false);

Check warning on line 475 in ArrayEditing/ArrayEditor.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.

Check warning on line 475 in ArrayEditing/ArrayEditor.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.
list.EnsureExactElementCount(array.Count);
for (int i = 0; i < array.Count; i++)
{
Expand All @@ -551,7 +483,7 @@
{
list = comp.GetSyncMember("References") as ISyncList;
_skipListChanges = true;
list.World.RunSynchronously(() => _skipListChanges = false);

Check warning on line 486 in ArrayEditing/ArrayEditor.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.

Check warning on line 486 in ArrayEditing/ArrayEditor.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.
list.EnsureExactElementCount(array.Count);
for (int i = 0; i < array.Count; i++)
{
Expand All @@ -562,14 +494,13 @@
{
list = comp.GetSyncMember("Points") as ISyncList;
_skipListChanges = true;
list.World.RunSynchronously(() => _skipListChanges = false);

Check warning on line 497 in ArrayEditing/ArrayEditor.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.

Check warning on line 497 in ArrayEditing/ArrayEditor.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.
list.EnsureExactElementCount(array.Count);

var isSyncLinear = TryGetGenericParameters(typeof(SyncLinear<>), array.GetType(), out var syncLinearGenericParameters);
var isSyncCurve = TryGetGenericParameters(typeof(SyncCurve<>), array.GetType(), out var syncCurveGenericParameters);
var syncLinearType = syncLinearGenericParameters?.First();
var syncCurveType = syncCurveGenericParameters?.First();
var isParticleBurst = syncLinearType == _particleBurstType;

if (!TryGetGenericParameters(typeof(SyncArray<>), array.GetType(), out var genericParameters))
return;
Expand All @@ -582,10 +513,7 @@

if (isSyncLinear && SupportsLerp(syncLinearType!))
{
if (isParticleBurst)
SetParticlePoint((ValueGradientDriver<int2>.Point)elem!, (LinearKey<ParticleBurst>)array.GetElement(i));
else
_setLinearPoint.MakeGenericMethod(syncLinearType).Invoke(null, [elem, array.GetElement(i)]);
_setLinearPoint.MakeGenericMethod(syncLinearType).Invoke(null, [elem, array.GetElement(i)]);
}
else if (isSyncCurve && SupportsLerp(syncCurveType!))
{
Expand Down
Loading