mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-06-01 11:33:40 +00:00
refactor: extend ITutorial to cover MultiPlayerLocalPlayer event hooks
This commit is contained in:
parent
650c81db3d
commit
7513c37f52
|
|
@ -171,7 +171,7 @@ public:
|
|||
int y, int z, bool bTestUseOnly = false);
|
||||
void useItemOn(std::shared_ptr<ItemInstance> item,
|
||||
bool bTestUseOnly = false);
|
||||
void completeUsingItem(std::shared_ptr<ItemInstance> item);
|
||||
void completeUsingItem(std::shared_ptr<ItemInstance> item) override;
|
||||
void startDestroyBlock(std::shared_ptr<ItemInstance> item, Tile* tile);
|
||||
void destroyBlock(Tile* tile);
|
||||
void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
||||
|
|
@ -187,7 +187,7 @@ public:
|
|||
void onLookAt(int id, int iData = 0) override;
|
||||
void onLookAtEntity(std::shared_ptr<Entity> entity) override;
|
||||
void onRideEntity(std::shared_ptr<Entity> entity) override;
|
||||
void onEffectChanged(MobEffect* effect, bool bRemoved = false);
|
||||
void onEffectChanged(MobEffect* effect, bool bRemoved = false) override;
|
||||
|
||||
bool canMoveToPosition(double xo, double yo, double zo, double xt,
|
||||
double yt, double zt) override;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
#include <cmath>
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include "app/common/Tutorial/Tutorial.h"
|
||||
#include "app/common/Tutorial/TutorialMode.h"
|
||||
#include "minecraft/IGameServices.h"
|
||||
#include "minecraft/world/tutorial/ITutorial.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerGameMode.h"
|
||||
#include "minecraft/client/player/Input.h"
|
||||
|
|
@ -234,10 +233,11 @@ void MultiplayerLocalPlayer::actuallyHurt(DamageSource* source, float dmg) {
|
|||
void MultiplayerLocalPlayer::completeUsingItem() {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (useItem != nullptr && pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->completeUsingItem(useItem);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->completeUsingItem(useItem);
|
||||
}
|
||||
}
|
||||
Player::completeUsingItem();
|
||||
}
|
||||
|
|
@ -245,10 +245,11 @@ void MultiplayerLocalPlayer::completeUsingItem() {
|
|||
void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance* effect) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
}
|
||||
}
|
||||
Player::onEffectAdded(effect);
|
||||
}
|
||||
|
|
@ -257,10 +258,11 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect,
|
|||
bool doRefreshAttributes) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||
}
|
||||
}
|
||||
Player::onEffectUpdated(effect, doRefreshAttributes);
|
||||
}
|
||||
|
|
@ -268,10 +270,12 @@ void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect,
|
|||
void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance* effect) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
Tutorial* tutorial = gameMode->getTutorial();
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()], true);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()],
|
||||
true);
|
||||
}
|
||||
}
|
||||
Player::onEffectRemoved(effect);
|
||||
}
|
||||
|
|
@ -351,13 +355,14 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
|
|||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (pMinecraft->localgameModes[m_iPad] != nullptr) {
|
||||
TutorialMode* gameMode =
|
||||
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||
if (wasRiding && !isRiding) {
|
||||
gameMode->getTutorial()->changeTutorialState(
|
||||
e_Tutorial_State_Gameplay);
|
||||
} else if (!wasRiding && isRiding) {
|
||||
gameMode->getTutorial()->onRideEntity(e);
|
||||
ITutorial* tutorial =
|
||||
pMinecraft->localgameModes[m_iPad]->getTutorial();
|
||||
if (tutorial != nullptr) {
|
||||
if (wasRiding && !isRiding) {
|
||||
tutorial->changeTutorialState(e_Tutorial_State_Gameplay);
|
||||
} else if (!wasRiding && isRiding) {
|
||||
tutorial->onRideEntity(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
class Entity;
|
||||
class ItemInstance;
|
||||
class MobEffect;
|
||||
|
||||
// Domain interface for the player tutorial.
|
||||
//
|
||||
|
|
@ -44,6 +45,8 @@ public:
|
|||
virtual void onLookAt(int id, int iData = 0) = 0;
|
||||
virtual void onLookAtEntity(std::shared_ptr<Entity> entity) = 0;
|
||||
virtual void onRideEntity(std::shared_ptr<Entity> entity) = 0;
|
||||
virtual void completeUsingItem(std::shared_ptr<ItemInstance> item) = 0;
|
||||
virtual void onEffectChanged(MobEffect* effect, bool bRemoved = false) = 0;
|
||||
|
||||
[[nodiscard]] virtual bool canMoveToPosition(double xo, double yo,
|
||||
double zo, double xt,
|
||||
|
|
|
|||
Loading…
Reference in a new issue