4jcraft/Minecraft.Client/Platform/Common/Tutorial/InfoTask.cpp
MatthewBeshay a0fdc643d1 Merge branch 'upstream-dev' into cleanup/nullptr-replacement
# Conflicts:
#	Minecraft.Client/Network/PlayerChunkMap.cpp
#	Minecraft.Client/Network/PlayerList.cpp
#	Minecraft.Client/Network/ServerChunkCache.cpp
#	Minecraft.Client/Platform/Common/Consoles_App.cpp
#	Minecraft.Client/Platform/Common/DLC/DLCManager.cpp
#	Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp
#	Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp
#	Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp
#	Minecraft.Client/Platform/Common/Tutorial/TutorialTask.cpp
#	Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp
#	Minecraft.Client/Platform/Common/UI/UIComponent_Panorama.cpp
#	Minecraft.Client/Platform/Common/UI/UIController.cpp
#	Minecraft.Client/Platform/Common/UI/UIController.h
#	Minecraft.Client/Platform/Extrax64Stubs.cpp
#	Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h
#	Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h
#	Minecraft.Client/Player/EntityTracker.cpp
#	Minecraft.Client/Player/ServerPlayer.cpp
#	Minecraft.Client/Rendering/EntityRenderers/PlayerRenderer.cpp
#	Minecraft.Client/Textures/Packs/DLCTexturePack.cpp
#	Minecraft.Client/Textures/Stitching/StitchedTexture.cpp
#	Minecraft.Client/Textures/Stitching/TextureMap.cpp
#	Minecraft.Client/Textures/Textures.cpp
#	Minecraft.World/Blocks/NotGateTile.cpp
#	Minecraft.World/Blocks/PressurePlateTile.cpp
#	Minecraft.World/Blocks/TileEntities/PotionBrewing.cpp
#	Minecraft.World/Enchantments/EnchantmentHelper.cpp
#	Minecraft.World/Entities/HangingEntity.cpp
#	Minecraft.World/Entities/LeashFenceKnotEntity.cpp
#	Minecraft.World/Entities/LivingEntity.cpp
#	Minecraft.World/Entities/Mobs/Boat.cpp
#	Minecraft.World/Entities/Mobs/Minecart.cpp
#	Minecraft.World/Entities/Mobs/Witch.cpp
#	Minecraft.World/Entities/SyncedEntityData.cpp
#	Minecraft.World/Items/LeashItem.cpp
#	Minecraft.World/Items/PotionItem.cpp
#	Minecraft.World/Level/BaseMobSpawner.cpp
#	Minecraft.World/Level/CustomLevelSource.cpp
#	Minecraft.World/Level/Level.cpp
#	Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp
#	Minecraft.World/Level/Storage/McRegionLevelStorage.cpp
#	Minecraft.World/Level/Storage/RegionFileCache.cpp
#	Minecraft.World/Player/Player.cpp
#	Minecraft.World/WorldGen/Biomes/BiomeCache.cpp
#	Minecraft.World/WorldGen/Features/RandomScatteredLargeFeature.cpp
#	Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp
2026-03-30 16:28:40 +11:00

126 lines
3.7 KiB
C++

#include "../../Minecraft.World/Platform/stdafx.h"
#include <string>
#include <unordered_map>
#include "../../Minecraft.Client/Minecraft.h"
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
#include "Tutorial.h"
#include "TutorialConstraints.h"
#include "InfoTask.h"
#include "../../Minecraft.World/Blocks/Material.h"
InfoTask::InfoTask(
Tutorial* tutorial, int descriptionId, int promptId /*= -1*/,
bool requiresUserInput /*= false*/, int iMapping /*= 0*/,
ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
: TutorialTask(tutorial, descriptionId, false, nullptr, true, false, false) {
if (requiresUserInput == true) {
constraints.push_back(new InputConstraint(iMapping));
}
completedMappings[iMapping] = false;
m_promptId = promptId;
tutorial->addMessage(m_promptId);
m_eTelemetryEvent = telemetryEvent;
}
bool InfoTask::isCompleted() {
if (bIsCompleted) return true;
if (tutorial->m_hintDisplayed) return false;
if (!bHasBeenActivated || !m_bShownForMinimumTime) return false;
bool bAllComplete = true;
Minecraft* pMinecraft = Minecraft::GetInstance();
// If the player is under water then allow all keypresses so they can jump
// out
if (pMinecraft->localplayers[tutorial->getPad()]->isUnderLiquid(
Material::water))
return false;
if (ui.GetMenuDisplayed(tutorial->getPad())) {
// If a menu is displayed, then we use the handleUIInput to complete the
// task
bAllComplete = true;
for (auto it = completedMappings.begin();
it != completedMappings.end(); ++it) {
bool current = (*it).second;
if (!current) {
bAllComplete = false;
break;
}
}
} else {
int iCurrent = 0;
for (auto it = completedMappings.begin();
it != completedMappings.end(); ++it) {
bool current = (*it).second;
if (!current) {
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(),
(*it).first) > 0) {
(*it).second = true;
bAllComplete = true;
} else {
bAllComplete = false;
}
}
iCurrent++;
}
}
if (bAllComplete == true) {
sendTelemetry();
enableConstraints(false, true);
}
bIsCompleted = bAllComplete;
return bAllComplete;
}
int InfoTask::getPromptId() {
if (m_bShownForMinimumTime)
return m_promptId;
else
return -1;
}
void InfoTask::setAsCurrentTask(bool active /*= true*/) {
enableConstraints(active);
TutorialTask::setAsCurrentTask(active);
}
void InfoTask::handleUIInput(int iAction) {
if (bHasBeenActivated) {
for (auto it = completedMappings.begin();
it != completedMappings.end(); ++it) {
if (iAction == (*it).first) {
(*it).second = true;
}
}
}
}
void InfoTask::sendTelemetry() {
Minecraft* pMinecraft = Minecraft::GetInstance();
if (m_eTelemetryEvent != eTelemetryChallenges_Unknown) {
bool firstPlay = true;
// We only store first play for some of the events
switch (m_eTelemetryEvent) {
case eTelemetryTutorial_Complete:
firstPlay =
!tutorial->getCompleted(eTutorial_Telemetry_Complete);
tutorial->setCompleted(eTutorial_Telemetry_Complete);
break;
default:
break;
};
TelemetryManager->RecordEnemyKilledOrOvercome(
pMinecraft->player->GetXboxPad(), 0, 0, 0, 0, 0, 0,
m_eTelemetryEvent);
}
}