IVSmoke 1.0
Loading...
Searching...
No Matches
IVSmokeHolePreset.cpp
1// Copyright (c) 2026, Team SDB. All rights reserved.
2
3#include "IVSmokeHolePreset.h"
4
5static TMap<uint8, TWeakObjectPtr<UIVSmokeHolePreset>> GHolePresetRegistry;
6
7void UIVSmokeHolePreset::PostLoad()
8{
9 Super::PostLoad();
10
11 RegisterToGlobalRegistry();
12}
13
14void UIVSmokeHolePreset::BeginDestroy()
15{
16 UnregisterFromGlobalRegistry();
17
18 Super::BeginDestroy();
19}
20
21void UIVSmokeHolePreset::RegisterToGlobalRegistry()
22{
23 uint8 ID = static_cast<uint8>(GetTypeHash(GetPathName()));
24 const uint8 StartID = ID;
25 TObjectPtr<UIVSmokeHolePreset> ToInsert = this;
26
27 while (TObjectPtr<UIVSmokeHolePreset> Existing = GHolePresetRegistry.FindRef(ID).Get())
28 {
29 if (Existing == ToInsert)
30 {
31 return;
32 }
33
34 if (ToInsert->GetPathName() < Existing->GetPathName())
35 {
36 GHolePresetRegistry.Remove(ID);
37 ToInsert->CachedID = ID;
38 GHolePresetRegistry.Add(ID, ToInsert);
39 ToInsert = Existing;
40 }
41
42 ID++;
43
44 if (ID == StartID)
45 {
46 ensureMsgf(false, TEXT("[UIVSmokeHolePreset] Registry full: %s"), *ToInsert->GetName());
47 return;
48 }
49 }
50
51 ToInsert->CachedID = ID;
52 GHolePresetRegistry.Add(ID, ToInsert);
53}
54
55void UIVSmokeHolePreset::UnregisterFromGlobalRegistry()
56{
57 GHolePresetRegistry.Remove(CachedID);
58}
59
60TObjectPtr<UIVSmokeHolePreset> UIVSmokeHolePreset::FindByID(const uint8 InPresetID)
61{
62 return GHolePresetRegistry.FindRef(InPresetID).Get();
63}
64
65float UIVSmokeHolePreset::GetFloatValue(const TObjectPtr<UCurveFloat> Curve, const float X)
66{
67 if (Curve.Get())
68 {
69 return Curve.Get()->GetFloatValue(X);
70 }
71 return 0;
72}
static float GetFloatValue(const TObjectPtr< UCurveFloat > Curve, const float X)
static TObjectPtr< UIVSmokeHolePreset > FindByID(const uint8 InPresetID)