Files
MinecraftConsoles/Minecraft.Client/Common/Tutorial/TutorialTask.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

73 lines
1.8 KiB
C++

#include "stdafx.h"
#include "Tutorial.h"
#include "TutorialConstraints.h"
#include "TutorialTask.h"
TutorialTask::TutorialTask(Tutorial *tutorial, int descriptionId, bool enablePreCompletion, vector<TutorialConstraint *> *inConstraints,
bool bShowMinimumTime, bool bAllowFade, bool bTaskReminders)
: tutorial( tutorial ), descriptionId( descriptionId ), m_promptId( -1 ), enablePreCompletion( enablePreCompletion ),
areConstraintsEnabled( false ), bIsCompleted( false ), bHasBeenActivated( false ),
m_bAllowFade(bAllowFade), m_bTaskReminders(bTaskReminders), m_bShowMinimumTime( bShowMinimumTime), m_bShownForMinimumTime( false )
{
if(inConstraints != nullptr)
{
for(auto& constraint : *inConstraints)
{
constraints.push_back( constraint );
}
delete inConstraints;
}
tutorial->addMessage(descriptionId);
}
TutorialTask::~TutorialTask()
{
enableConstraints(false);
for(auto& constraint : constraints)
{
if( constraint->getQueuedForRemoval() )
{
constraint->setDeleteOnDeactivate(true);
}
else
{
delete constraint;
}
}
}
void TutorialTask::taskCompleted()
{
if( areConstraintsEnabled == true )
enableConstraints( false );
}
void TutorialTask::enableConstraints(bool enable, bool delayRemove /*= false*/)
{
if( !enable && (areConstraintsEnabled || !delayRemove) )
{
// Remove
for(auto& constraint : constraints)
{
//app.DebugPrintf(">>>>>>>> %i\n", constraints.size());
tutorial->RemoveConstraint( constraint, delayRemove );
}
areConstraintsEnabled = false;
}
else if( !areConstraintsEnabled && enable )
{
// Add
for(auto& constraint : constraints)
{
tutorial->AddConstraint( constraint );
}
areConstraintsEnabled = true;
}
}
void TutorialTask::setAsCurrentTask(bool active /*= true*/)
{
bHasBeenActivated = active;
}