296 lines
11 KiB
C++
296 lines
11 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2022 SenseGlove
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
* @section DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
#include "SGCore/SGTimedThumpCommand.h"
|
|
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
|
|
#include "SGCoreImpl/SGExportedFunctions.h"
|
|
#include "SGInterop/SGIC_FSGThumperCommandImpl.h"
|
|
#include "SGInterop/SGIC_FSGTimedThumpCommandImpl.h"
|
|
#include "SGInterop/SGIC_FString.h"
|
|
|
|
struct USGTimedThumpCommand::FImpl
|
|
{
|
|
/************************
|
|
* Member variables
|
|
************************/
|
|
|
|
FSGTimedThumpCommandImpl TimedThumpCommandImpl;
|
|
|
|
/************************
|
|
* Owner object
|
|
************************/
|
|
|
|
USGTimedThumpCommand* Owner;
|
|
|
|
/************************
|
|
* Constructor / Destructor
|
|
************************/
|
|
|
|
explicit FImpl(USGTimedThumpCommand* InOwner);
|
|
~FImpl();
|
|
|
|
/************************
|
|
* Default copy constructor & copy assignment operator
|
|
************************/
|
|
|
|
FImpl(const FImpl& Rhs) = default;
|
|
FImpl& operator=(const FImpl& Rhs) = default;
|
|
|
|
/************************
|
|
* Methods
|
|
************************/
|
|
|
|
void SyncUProperties();
|
|
void SyncImplObject();
|
|
};
|
|
|
|
USGTimedThumpCommand* USGTimedThumpCommand::NewTimedThumpCommand(
|
|
UObject* Outer, const FSGTimedThumpCommandImpl& TimedThumpCommandImpl)
|
|
{
|
|
USGTimedThumpCommand* Instance = NewObject<USGTimedThumpCommand>(Outer);
|
|
Instance->SetTimedThumpCommandImpl(TimedThumpCommandImpl);
|
|
return Instance;
|
|
}
|
|
|
|
USGTimedThumpCommand* USGTimedThumpCommand::NewTimedThumpCommand(UObject* Outer)
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandImplContainer;
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ctor(&OutTimedThumpCommandImplContainer);
|
|
|
|
return NewTimedThumpCommand(Outer, MoveTemp(OutTimedThumpCommandImplContainer.TimedThumpCommandImpl));
|
|
}
|
|
|
|
USGTimedThumpCommand* USGTimedThumpCommand::NewTimedThumpCommand(
|
|
UObject* Outer, const int32 Magnitude, const float DurationSeconds, const float StartTimeSeconds)
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandImplContainer;
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ctor_Magnitude_DurationSeconds_StartTimeSeconds(
|
|
&OutTimedThumpCommandImplContainer, Magnitude, DurationSeconds, StartTimeSeconds);
|
|
|
|
return NewTimedThumpCommand(Outer, MoveTemp(OutTimedThumpCommandImplContainer.TimedThumpCommandImpl));
|
|
}
|
|
|
|
USGTimedThumpCommand* USGTimedThumpCommand::NewTimedThumpCommand(
|
|
UObject* Outer, const USGThumperCommand* BaseCommand, const float DurationSeconds, const float StartTimeSeconds)
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandImplContainer;
|
|
FSGIC_FSGThumperCommandImpl BaseCommandContainer{BaseCommand->ToThumperCommandImpl()};
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ctor_BaseCommand_DurationSeconds_StartTimeSeconds(
|
|
&OutTimedThumpCommandImplContainer, &BaseCommandContainer, DurationSeconds, StartTimeSeconds);
|
|
|
|
return NewTimedThumpCommand(Outer, MoveTemp(OutTimedThumpCommandImplContainer.TimedThumpCommandImpl));
|
|
}
|
|
|
|
USGTimedThumpCommand::USGTimedThumpCommand()
|
|
:
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandImplContainer;
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ctor(&OutTimedThumpCommandImplContainer);
|
|
|
|
Pimpl->TimedThumpCommandImpl = MoveTemp(OutTimedThumpCommandImplContainer.TimedThumpCommandImpl);
|
|
Pimpl->SyncUProperties();
|
|
}
|
|
|
|
USGTimedThumpCommand::USGTimedThumpCommand(const int32 Magnitude,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
:
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandImplContainer;
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ctor_Magnitude_DurationSeconds_StartTimeSeconds(
|
|
&OutTimedThumpCommandImplContainer, Magnitude, DurationSeconds, StartTimeSeconds);
|
|
|
|
Pimpl->TimedThumpCommandImpl = MoveTemp(OutTimedThumpCommandImplContainer.TimedThumpCommandImpl);
|
|
Pimpl->SyncUProperties();
|
|
}
|
|
|
|
USGTimedThumpCommand::USGTimedThumpCommand(const USGThumperCommand* BaseCommand,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
:
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandImplContainer;
|
|
FSGIC_FSGThumperCommandImpl BaseCommandContainer{BaseCommand->ToThumperCommandImpl()};
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ctor_BaseCommand_DurationSeconds_StartTimeSeconds(
|
|
&OutTimedThumpCommandImplContainer, &BaseCommandContainer, DurationSeconds, StartTimeSeconds);
|
|
|
|
Pimpl->TimedThumpCommandImpl = MoveTemp(OutTimedThumpCommandImplContainer.TimedThumpCommandImpl);
|
|
Pimpl->SyncUProperties();
|
|
}
|
|
|
|
USGTimedThumpCommand::USGTimedThumpCommand(const FSGTimedThumpCommandImpl& TimedThumpCommandImpl)
|
|
:
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
#else
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
|
{
|
|
SetTimedThumpCommandImpl(TimedThumpCommandImpl);
|
|
Pimpl->SyncUProperties();
|
|
}
|
|
|
|
USGTimedThumpCommand::~USGTimedThumpCommand() = default;
|
|
|
|
void USGTimedThumpCommand::SetTimedThumpCommandImpl(const FSGTimedThumpCommandImpl& TimedThumpCommandImpl)
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandContainer;
|
|
FSGIC_FSGTimedThumpCommandImpl RhsContainer{TimedThumpCommandImpl};
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ctor_copy(&OutTimedThumpCommandContainer, &RhsContainer);
|
|
Pimpl->TimedThumpCommandImpl = MoveTemp(OutTimedThumpCommandContainer.TimedThumpCommandImpl);
|
|
}
|
|
|
|
const FSGTimedThumpCommandImpl& USGTimedThumpCommand::ToTimedThumpCommandImpl() const
|
|
{
|
|
Pimpl->SyncImplObject();
|
|
return Pimpl->TimedThumpCommandImpl;
|
|
}
|
|
|
|
int32 USGTimedThumpCommand::GetMagnitude() const
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
return SGCoreImpl_FSGTimedThumpCommandImpl_GetMagnitude(&InstanceContainer);
|
|
}
|
|
|
|
void USGTimedThumpCommand::SetMagnitude(int32 Magnitude)
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_SetMagnitude(&InstanceContainer, Magnitude);
|
|
}
|
|
|
|
float USGTimedThumpCommand::GetDuration() const
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
return SGCoreImpl_FSGTimedThumpCommandImpl_GetDuration(&InstanceContainer);
|
|
}
|
|
|
|
void USGTimedThumpCommand::SetDuration(const float Duration)
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_SetDuration(&InstanceContainer, Duration);
|
|
}
|
|
|
|
float USGTimedThumpCommand::GetElapsedTime() const
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
return SGCoreImpl_FSGTimedThumpCommandImpl_GetElapsedTime(&InstanceContainer);
|
|
}
|
|
|
|
void USGTimedThumpCommand::SetElapsedTime(const float ElapsedTime)
|
|
{
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_SetElapsedTime(&InstanceContainer, ElapsedTime);
|
|
}
|
|
|
|
bool USGTimedThumpCommand::HasTimeElapsed() const
|
|
{
|
|
Pimpl->SyncImplObject();
|
|
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
return SGCoreImpl_FSGTimedThumpCommandImpl_HasTimeElapsed(&InstanceContainer);
|
|
}
|
|
|
|
USGTimedThumpCommand* USGTimedThumpCommand::Copy(UObject* Outer, const bool bCopyElapsed) const
|
|
{
|
|
Pimpl->SyncImplObject();
|
|
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
FSGIC_FSGTimedThumpCommandImpl OutTimedThumpCommandImplContainer;
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_Copy(&InstanceContainer, &OutTimedThumpCommandImplContainer, bCopyElapsed);
|
|
|
|
return NewTimedThumpCommand(Outer, OutTimedThumpCommandImplContainer.TimedThumpCommandImpl);
|
|
}
|
|
|
|
void USGTimedThumpCommand::Update(const float DeltaSeconds)
|
|
{
|
|
Pimpl->SyncImplObject();
|
|
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_Update(&InstanceContainer, DeltaSeconds);
|
|
}
|
|
|
|
bool USGTimedThumpCommand::Equals(const USGTimedThumpCommand* TimedThumpCommand) const
|
|
{
|
|
Pimpl->SyncImplObject();
|
|
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
FSGIC_FSGTimedThumpCommandImpl TimedThumpCommandImplContainer{TimedThumpCommand->ToTimedThumpCommandImpl()};
|
|
return SGCoreImpl_FSGTimedThumpCommandImpl_Equals(&InstanceContainer, &TimedThumpCommandImplContainer);
|
|
}
|
|
|
|
FString USGTimedThumpCommand::ToString() const
|
|
{
|
|
Pimpl->SyncImplObject();
|
|
|
|
FSGIC_FSGTimedThumpCommandImpl InstanceContainer{ToTimedThumpCommandImpl()};
|
|
FSGIC_FString OutStringContainer;
|
|
SGCoreImpl_FSGTimedThumpCommandImpl_ToString(&InstanceContainer, &OutStringContainer);
|
|
return MoveTemp(OutStringContainer.String);
|
|
}
|
|
|
|
USGTimedThumpCommand::FImpl::FImpl(USGTimedThumpCommand* InOwner)
|
|
: Owner(InOwner)
|
|
{
|
|
}
|
|
|
|
USGTimedThumpCommand::FImpl::~FImpl() = default;
|
|
|
|
void USGTimedThumpCommand::FImplDeleter::operator()(const FImpl* P) const
|
|
{
|
|
delete P;
|
|
}
|
|
|
|
void USGTimedThumpCommand::FImpl::SyncImplObject()
|
|
{
|
|
}
|
|
|
|
void USGTimedThumpCommand::FImpl::SyncUProperties()
|
|
{
|
|
} |