mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
PINK: added random to methods which need it.
This commit is contained in:
parent
a22ebbb54e
commit
7facc7543f
@ -27,6 +27,8 @@
|
||||
#include <engines/pink/objects/sequences/sequencer.h>
|
||||
#include <engines/pink/objects/sequences/sequence.h>
|
||||
#include <engines/pink/objects/actors/lead_actor.h>
|
||||
#include <engines/pink/objects/pages/game_page.h>
|
||||
#include <engines/pink/pink.h>
|
||||
#include <common/debug.h>
|
||||
|
||||
namespace Pink {
|
||||
@ -64,7 +66,13 @@ void HandlerSequences::onMessage(LeadActor *actor) {
|
||||
Handler::onMessage(actor);
|
||||
Sequencer *sequencer = actor->getSequencer();
|
||||
|
||||
Sequence *sequence = sequencer->findSequence(_sequences[0]); //actually we must pick random sequence
|
||||
assert(_sequences.size());
|
||||
|
||||
Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
|
||||
uint index = rnd.getRandomNumber(_sequences.size() - 1);
|
||||
|
||||
Sequence *sequence = sequencer->findSequence(_sequences[index]);
|
||||
|
||||
assert(sequence);
|
||||
sequencer->authorSequence(sequence, 0);
|
||||
|
||||
|
@ -28,6 +28,9 @@
|
||||
#include <engines/pink/objects/sequences/sequence.h>
|
||||
#include <engines/pink/objects/side_effect.h>
|
||||
#include <engines/pink/objects/actors/lead_actor.h>
|
||||
#include <engines/pink/objects/pages/game_page.h>
|
||||
#include <engines/pink/pink.h>
|
||||
|
||||
|
||||
namespace Pink {
|
||||
|
||||
@ -58,9 +61,11 @@ void HandlerTimerActions::toConsole() {
|
||||
|
||||
void HandlerTimerActions::onMessage(LeadActor *actor) {
|
||||
Handler::onMessage(actor);
|
||||
assert(_actions.size() > 0);
|
||||
assert(_actions.size());
|
||||
if (!actor->isPlaying()){
|
||||
Action *action = actor->findAction(_actions[0]);// we must pick random
|
||||
Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
|
||||
uint index = rnd.getRandomNumber(_actions.size() - 1);
|
||||
Action *action = actor->findAction(_actions[index]);
|
||||
assert(action);
|
||||
actor->setAction(action, 0);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace Pink {
|
||||
|
||||
class LeadActor;
|
||||
|
||||
//TODO in Peril create HandlerTimerActions when it is request for HandlerTimer
|
||||
//TODO: in Peril create HandlerTimerActions when it is request for HandlerTimer
|
||||
|
||||
// This class has differences in games
|
||||
class HandlerTimer : public Handler {
|
||||
|
@ -89,7 +89,7 @@ void GamePage::loadManagers() {
|
||||
}
|
||||
|
||||
PinkEngine *GamePage::getGame() {
|
||||
return _module->getGame();
|
||||
return _resMgr.getGame();
|
||||
}
|
||||
|
||||
Sequencer *GamePage::getSequencer() {
|
||||
|
@ -45,8 +45,8 @@ public:
|
||||
PinkEngine *getGame();
|
||||
Sequencer *getSequencer();
|
||||
WalkMgr *getWalkMgr();
|
||||
|
||||
Module *getModule() const;
|
||||
|
||||
bool checkValueOfVariable(Common::String &variable, Common::String &value);
|
||||
void setVariable(Common::String &variable, Common::String &value);
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <engines/pink/objects/walk/walk_location.h>
|
||||
#include <engines/pink/objects/walk/walk_mgr.h>
|
||||
|
||||
|
||||
namespace Pink {
|
||||
|
||||
void SideEffectExit::deserialize(Archive &archive) {
|
||||
@ -109,8 +110,12 @@ void SideEffectRandomPageVariable::deserialize(Archive &archive) {
|
||||
}
|
||||
|
||||
void SideEffectRandomPageVariable::execute(LeadActor *actor) {
|
||||
// TODO think how to get rand gen here
|
||||
actor->getPage()->setVariable(_name, _values[0]); // temporary solution
|
||||
assert(_values.size());
|
||||
|
||||
Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
|
||||
uint index = rnd.getRandomNumber(_values.size() - 1);
|
||||
|
||||
actor->getPage()->setVariable(_name, _values[index]);
|
||||
}
|
||||
|
||||
void SideEffectRandomPageVariable::toConsole() {
|
||||
|
@ -199,4 +199,8 @@ void PinkEngine::setVariable(Common::String &variable, Common::String &value) {
|
||||
_variables[variable] = value;
|
||||
}
|
||||
|
||||
Common::RandomSource &PinkEngine::getRnd() {
|
||||
return _rnd;
|
||||
}
|
||||
|
||||
}
|
@ -75,6 +75,7 @@ public:
|
||||
|
||||
OrbFile *getOrb() { return &_orb; }
|
||||
BroFile *getBro() { return _bro; }
|
||||
Common::RandomSource &getRnd();
|
||||
|
||||
bool checkValueOfVariable(Common::String &variable, Common::String &value);
|
||||
void setVariable(Common::String &variable, Common::String &value);
|
||||
|
@ -73,4 +73,8 @@ Common::SeekableReadStream *ResourceMgr::getResourceStream(Common::String &name)
|
||||
_resDescTable[i].offset + _resDescTable[i].size);
|
||||
}
|
||||
|
||||
PinkEngine *ResourceMgr::getGame() const {
|
||||
return _game;
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
//Common::String loadText(Common::String &name);
|
||||
Sound *loadSound(Common::String &name);
|
||||
// loadCEL();
|
||||
PinkEngine *getGame() const;
|
||||
|
||||
private:
|
||||
Common::SeekableReadStream *getResourceStream(Common::String &name);
|
||||
|
Loading…
Reference in New Issue
Block a user