-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from ckawell/die-roll-anims-ckawell
Implemented die roll animations for the Lego Dice item
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "LegoDieRoll.h" | ||
#include "Entity.h" | ||
#include "dLogger.h" | ||
#include "GameMessages.h" | ||
|
||
void LegoDieRoll::OnStartup(Entity* self) { | ||
self->AddTimer("DoneRolling", 10.0f); | ||
self->AddTimer("ThrowDice", LegoDieRoll::animTime); | ||
} | ||
|
||
void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) { | ||
if (timerName == "DoneRolling") { | ||
self->Smash(self->GetObjectID(), SILENT); | ||
} | ||
else if (timerName == "ThrowDice") { | ||
int dieRoll = GeneralUtils::GenerateRandomNumber<int>(1, 6); | ||
|
||
switch (dieRoll) | ||
{ | ||
case 1: | ||
GameMessages::SendPlayAnimation(self, u"roll-die-1"); | ||
break; | ||
case 2: | ||
GameMessages::SendPlayAnimation(self, u"roll-die-2"); | ||
break; | ||
case 3: | ||
GameMessages::SendPlayAnimation(self, u"roll-die-3"); | ||
break; | ||
case 4: | ||
GameMessages::SendPlayAnimation(self, u"roll-die-4"); | ||
break; | ||
case 5: | ||
GameMessages::SendPlayAnimation(self, u"roll-die-5"); | ||
break; | ||
case 6: | ||
{ | ||
GameMessages::SendPlayAnimation(self, u"roll-die-6"); | ||
// tracking the It's Truly Random Achievement | ||
auto* owner = self->GetOwner(); | ||
auto* missionComponent = owner->GetComponent<MissionComponent>(); | ||
|
||
if (missionComponent != nullptr) { | ||
const auto rollMissionState = missionComponent->GetMissionState(756); | ||
if (rollMissionState == MissionState::MISSION_STATE_ACTIVE) { | ||
missionComponent->ForceProgress(756, 1103, 1); | ||
} | ||
} | ||
break; | ||
} | ||
default: | ||
Game::logger->LogDebug("LegoDieRoll", "Invalid animation: roll-die-%i\n", dieRoll); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include "CppScripts.h" | ||
|
||
class LegoDieRoll : public CppScripts::Script { | ||
public: | ||
void OnStartup(Entity* self); | ||
void OnTimerDone(Entity* self, std::string timerName); | ||
private: | ||
constexpr static const float animTime = 2.0f; | ||
}; | ||
|
Submodule utils
added at
74508f