19static constexpr const TCHAR* MODELTYPES_DIR =
"data\\modeltypes\\";
24 : m_pAnimSoundBPsTRB(
TNULL )
25 , m_pSoundBreakpoints(
TNULL )
33 if ( m_pAnimSoundBPsTRB )
35 delete m_pAnimSoundBPsTRB;
36 m_pAnimSoundBPsTRB =
TNULL;
37 m_pSoundBreakpoints =
TNULL;
40 m_llObjectTypes.DeleteAll();
41 m_llAnimatableObjects.DeleteAll();
49 m_llAnimatableObjects.PushBack( pObject );
50 pObject->
Create( a_pObjectType, a_Unk1, a_eFlags );
59 strLibPath.
Format(
"%slibs\\%s.trb", MODELTYPES_DIR, a_szLibName );
67 const PBProperties* pProperties = PBProperties::LoadFromTRB( oTRB );
73 TINT iLoadScreenUpdateCounter = 0;
80 if ( ++iLoadScreenUpdateCounter > 5 )
82 iLoadScreenUpdateCounter = 0;
98 strAnimObjPath.
Format(
"%s%s.trb", MODELTYPES_DIR, a_rcName.
GetString() );
105 a_pProperties = PBProperties::LoadFromTRB( oTRB );
110 const PBProperties* pTypeProperties =
TNULL;
112 AAnimatableObjectType* pObjectType =
TNULL;
119 pObjectType =
new AAnimatableObjectTypeBunch();
125 pObjectType =
new AAnimatableObjectType();
129 m_llObjectTypes.PushBack( pObjectType );
131 TBOOL bCreated = ( pTypeProperties ) ?
133 pObjectType->
Create( a_rcName );
135 if ( bCreated && !a_bNoBreakpoints )
136 AttachSoundBreakpoints( pObjectType );
152 if ( it->GetName() == a_rcName )
156 TERROR(
"AAnimatableObjectManager: unable to find animatable type '%s'\n", a_rcName.GetString() );
165 a_pParent->m_llAttachedObjects.Erase( a_pObject );
178 AModelRepos::GetSingleton()->UnloadUnusedModels();
185 if ( !a_pAnimatableObject )
188 if ( m_llAnimatableObjects.Exists( a_pAnimatableObject ) )
197 a_pAnimatableObject->Remove();
198 delete a_pAnimatableObject;
205 if ( !a_pAnimatableObject )
208 while ( a_pAnimatableObject->m_llAttachedObjects.IsLinked() )
210 AAnimatableObject* pAttachedObject = a_pAnimatableObject->m_llAttachedObjects.Begin();
222 m_pAnimSoundBPsTRB =
new TTRB();
231 TASSERT( !
"Unable to load info about sound breakpoints" );
245 for (
TUINT i = 0; i < m_pSoundBreakpoints->uiCount; i++ )
263 TBOOL bUpdateAnim = it->IsAnimated();
270 if ( !modelInstance->IsUpdatingSkeleton() && it->GetQueuedAnimations().Size() <= 0 )
275 it->Update( a_fDeltaTime );
284 if ( m_pSoundBreakpoints )
290 while ( iModelNameStartPos > 0 && ( pszModelName[ iModelNameStartPos - 1 ] !=
'\\' && pszModelName[ iModelNameStartPos - 1 ] !=
'/' ) )
292 iModelNameStartPos--;
295 TCHAR szModelName[ 512 ];
300 for (
TUINT i = 0; i < m_pSoundBreakpoints->uiCount; i++ )
302 ASoundBreakpoint* pSoundBreakpoint = &m_pSoundBreakpoints->pBreakpoints[ i ];
310 pAnimationSet->AddSoundBreakpoint( pSoundBreakpoint, pSkeleton );
#define TOSHI_NAMESPACE_USING
#define T2_FOREACH(vecName, iteratorName)
#define TDEFINE_CLASS(...)
ALoadScreen g_oLoadScreen
Toshi::T2ObjectPool< AToshiAnimationRef, 100 > g_oAnimationRefPool
Toshi::TRef< AModelInstance > AModelInstanceRef
Toshi::TRef< ANamedAnimationSet > ANamedAnimationSetRef
ERROR Load(const TCHAR *a_szFilePath, TUINT32 a_uiUnknown=0)
const TCHAR * GetString() const
TBOOL GetOptionalPropertyValue(T &a_rOutValue, const TCHAR *a_szName) const
PBPropertyName & GetName()
static TSIZE Length(const TCHAR *str)
static TINT CompareNoCase(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)
static TCHAR * Copy(TCHAR *dst, const TCHAR *src, TSIZE size=-1)
TFORCEINLINE const TCHAR * GetString() const
TString8 & Format(const TCHAR *a_pcFormat,...)
TBOOL Create(AAnimatableObjectType *a_pObjectType, void *a_Unk1, CREATE_FLAGS a_eFlags=CREATE_FLAGS_NONE)
AAnimatableObject * pParentObject
AAnimatableObject * CreateAnimatableObject(AAnimatableObjectType *a_pObjectType, void *a_Unk1=nullptr, TUINT a_eFlags=0)
void LoadAnimObjType(const TCHAR *a_szName, const PBProperties *a_pProperties, TBOOL a_bNoBreakpoints)
void DestroyAnimatableObject(AAnimatableObject *a_pAnimatableObject)
TBOOL LoadAnimSoundBreakpoints(const TCHAR *a_szFilePath)
AAnimatableObjectManager()
AAnimatableObjectType * FindType(const Toshi::TPString8 &a_rcName)
void DetachObject(AAnimatableObject *a_pObject, AAnimatableObject *a_pParent)
void LoadTypesFromLibrary(const TCHAR *a_szLibName)
void DestroyType(const Toshi::TPString8 &a_rcName)
void DestroyAttachedObjects(AAnimatableObject *a_pAnimatableObject)
TINT FindNumAnimationSoundBreakpoints(const Toshi::TPString8 &a_rcModelName, ANamedAnimation *a_pAnimation)
~AAnimatableObjectManager()
virtual TBOOL OnUpdate(TFLOAT a_fDeltaTime) override
ANamedAnimationSetRef GetAnimationSet(TINT a_iIndex) const
AModel * GetModel() const
virtual TBOOL Create(const Toshi::TPString8 &a_rcName)
virtual TBOOL CreateFromProperties(const PBProperties *a_pProperties, const Toshi::TPString8 &a_rcName)
TINT GetNumAnimationSets() const
const Toshi::TPString8 & GetName() const
Toshi::TSkeleton * GetSkeleton() const
const Toshi::TPString8 & GetExportedName() const