Initial commit: AetherBags + KamiToolKit for FC Gitea
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using KamiToolKit.Classes;
|
||||
|
||||
namespace KamiToolKit.Timelines;
|
||||
|
||||
public unsafe class TimelineAnimationArray : IDisposable {
|
||||
|
||||
internal AtkTimelineAnimation* InternalTimelineArray = null;
|
||||
|
||||
private List<TimelineAnimation> timelineAnimations = [];
|
||||
public uint Count { get; private set; }
|
||||
|
||||
public List<TimelineAnimation> Animations {
|
||||
get => timelineAnimations;
|
||||
set {
|
||||
timelineAnimations = value;
|
||||
Resync();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
foreach (var animation in timelineAnimations) {
|
||||
animation.Dispose();
|
||||
}
|
||||
|
||||
NativeMemoryHelper.UiFree(InternalTimelineArray, Count);
|
||||
InternalTimelineArray = null;
|
||||
}
|
||||
|
||||
private void Resync() {
|
||||
// Free existing array, we will completely rebuild it
|
||||
if (InternalTimelineArray is not null) {
|
||||
NativeMemoryHelper.UiFree(InternalTimelineArray, Count);
|
||||
InternalTimelineArray = null;
|
||||
}
|
||||
|
||||
// Allocate new array
|
||||
InternalTimelineArray = NativeMemoryHelper.UiAlloc<AtkTimelineAnimation>(timelineAnimations.Count);
|
||||
|
||||
// Copy all Animations into it
|
||||
foreach (var index in Enumerable.Range(0, timelineAnimations.Count)) {
|
||||
InternalTimelineArray[index] = *timelineAnimations[index].InternalAnimation;
|
||||
}
|
||||
|
||||
Count = (uint)timelineAnimations.Count;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user