mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 15:02:34 +02:00
Add more opcodes
This commit is contained in:
parent
7963becbd1
commit
e3c78fd09c
@ -158,6 +158,7 @@ public:
|
||||
void loadWeaponDAT(const std::string& name);
|
||||
|
||||
bool loadAudio(MADStream &music, const std::string& name);
|
||||
bool loadAudio(sf::SoundBuffer& sound, const std::string& name);
|
||||
|
||||
void loadSplash(const std::string& name);
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class GameObject;
|
||||
class PlayerController;
|
||||
struct CutsceneData;
|
||||
|
||||
@ -21,6 +22,7 @@ struct TextDisplayData
|
||||
|
||||
struct OnscreenText
|
||||
{
|
||||
std::string id;
|
||||
std::string osTextString;
|
||||
float osTextStart;
|
||||
float osTextTime;
|
||||
@ -77,7 +79,7 @@ struct GameState
|
||||
|
||||
std::string currentSplash;
|
||||
|
||||
|
||||
bool skipCutscene;
|
||||
bool isIntroPlaying;
|
||||
CutsceneData* currentCutscene;
|
||||
float cutsceneStartTime;
|
||||
@ -103,6 +105,8 @@ struct GameState
|
||||
glm::vec3 cameraPosition;
|
||||
glm::quat cameraRotation;
|
||||
|
||||
GameObject* cameraTarget;
|
||||
|
||||
std::vector<VehicleGenerator> vehicleGenerators;
|
||||
|
||||
GameState() :
|
||||
@ -120,6 +124,7 @@ struct GameState
|
||||
fadeStart(0.f),
|
||||
fadeTime(0.f),
|
||||
fadeSound(false),
|
||||
skipCutscene(false),
|
||||
isIntroPlaying(false),
|
||||
currentCutscene(nullptr),
|
||||
cutsceneStartTime(-1.f),
|
||||
@ -127,7 +132,8 @@ struct GameState
|
||||
hour(0),
|
||||
minute(0),
|
||||
cameraNear(0.1f),
|
||||
cameraFixed(false)
|
||||
cameraFixed(false),
|
||||
cameraTarget(nullptr)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -245,6 +245,8 @@ public:
|
||||
|
||||
MADStream fgAudio;
|
||||
bool cutsceneAudioLoaded;
|
||||
sf::SoundBuffer missionAudio;
|
||||
sf::Sound missionSound;
|
||||
|
||||
/**
|
||||
* @brief loads a model into a special character slot.
|
||||
|
@ -49,17 +49,20 @@ void CharacterController::setNextActivity(CharacterController::Activity* activit
|
||||
void CharacterController::update(float dt)
|
||||
{
|
||||
auto d = rawMovement;
|
||||
|
||||
|
||||
if( character->getCurrentVehicle() ) {
|
||||
// Nevermind, the player is in a vehicle.
|
||||
|
||||
character->getCurrentVehicle()->setSteeringAngle(d.y);
|
||||
|
||||
if( std::abs(d.x) > 0.01f )
|
||||
if( character->getCurrentSeat() == 0 )
|
||||
{
|
||||
character->getCurrentVehicle()->setHandbraking(false);
|
||||
character->getCurrentVehicle()->setSteeringAngle(d.y);
|
||||
|
||||
if( std::abs(d.x) > 0.01f )
|
||||
{
|
||||
character->getCurrentVehicle()->setHandbraking(false);
|
||||
}
|
||||
character->getCurrentVehicle()->setThrottle(d.x);
|
||||
}
|
||||
character->getCurrentVehicle()->setThrottle(d.x);
|
||||
|
||||
// if the character isn't doing anything, play sitting anim.
|
||||
if( _currentActivity == nullptr ) {
|
||||
|
@ -495,6 +495,12 @@ bool GameData::loadAudio(MADStream& music, const std::string &name)
|
||||
return music.open(datpath + "/audio/" + name);
|
||||
}
|
||||
|
||||
bool GameData::loadAudio(sf::SoundBuffer& sound, const std::string& name)
|
||||
{
|
||||
auto fname = findPathRealCase(datpath + "/audio/", name);
|
||||
return sound.loadFromFile(fname);
|
||||
}
|
||||
|
||||
void GameData::loadSplash(const std::string &name)
|
||||
{
|
||||
std::string lower(name);
|
||||
|
@ -683,6 +683,7 @@ void GameWorld::loadCutscene(const std::string &name)
|
||||
void GameWorld::startCutscene()
|
||||
{
|
||||
state.cutsceneStartTime = gameTime;
|
||||
state.skipCutscene = false;
|
||||
if( cutsceneAudioLoaded ) {
|
||||
fgAudio.play();
|
||||
}
|
||||
|
@ -144,8 +144,8 @@ void VehicleObject::tickPhysics(float dt)
|
||||
{
|
||||
if(physVehicle) {
|
||||
// todo: a real engine function
|
||||
float velFac = (info->handling.maxVelocity - physVehicle->getCurrentSpeedKmHour()) / info->handling.maxVelocity;
|
||||
float engineForce = info->handling.acceleration * 150.f * throttle * velFac;
|
||||
float velFac = info->handling.maxVelocity;
|
||||
float engineForce = info->handling.acceleration * throttle * velFac;
|
||||
if( fabs(engineForce) >= 0.001f ) physBody->activate(true);
|
||||
|
||||
float brakeF = getBraking();
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include <render/Model.hpp>
|
||||
#include <engine/Animator.hpp>
|
||||
#include <engine/GameWorld.hpp>
|
||||
#include <engine/GameWorld.hpp>
|
||||
#include <ai/PlayerController.hpp>
|
||||
#include <ai/DefaultAIController.hpp>
|
||||
|
||||
@ -122,10 +124,11 @@ VM_OPCODE_DEF( 0x00A5 )
|
||||
|
||||
VM_OPCODE_DEF( 0x00BA )
|
||||
{
|
||||
std::string str(p->at(0).string);
|
||||
str = m->getWorld()->gameData.texts.text(str);
|
||||
std::string id(p->at(0).string);
|
||||
std::string str = m->getWorld()->gameData.texts.text(id);
|
||||
unsigned short style = p->at(2).integer;
|
||||
m->getWorld()->state.text.push_back({
|
||||
id,
|
||||
str,
|
||||
m->getWorld()->gameTime,
|
||||
p->at(1).integer / 1000.f,
|
||||
@ -135,10 +138,11 @@ VM_OPCODE_DEF( 0x00BA )
|
||||
|
||||
VM_OPCODE_DEF( 0x00BC )
|
||||
{
|
||||
std::string str(p->at(0).string);
|
||||
str = m->getWorld()->gameData.texts.text(str);
|
||||
std::string id(p->at(0).string);
|
||||
std::string str = m->getWorld()->gameData.texts.text(id);
|
||||
int flags = p->at(2).integer;
|
||||
m->getWorld()->state.text.push_back({
|
||||
id,
|
||||
str,
|
||||
m->getWorld()->gameTime,
|
||||
p->at(1).integer / 1000.f,
|
||||
@ -159,7 +163,27 @@ VM_OPCODE_DEF( 0x00C0 )
|
||||
|
||||
VM_CONDOPCODE_DEF( 0x00DB )
|
||||
{
|
||||
return false;
|
||||
auto controller = static_cast<CharacterController*>(*p->at(0).handle);
|
||||
auto vehicle = static_cast<VehicleObject*>(*p->at(1).handle);
|
||||
|
||||
if( controller == nullptr || vehicle == nullptr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return controller->getCharacter()->getCurrentVehicle() == vehicle;
|
||||
}
|
||||
VM_CONDOPCODE_DEF( 0x00DC )
|
||||
{
|
||||
auto controller = static_cast<CharacterController*>(*p->at(0).handle);
|
||||
auto vehicle = static_cast<VehicleObject*>(*p->at(1).handle);
|
||||
|
||||
if( controller == nullptr || vehicle == nullptr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return controller->getCharacter()->getCurrentVehicle() == vehicle;
|
||||
}
|
||||
|
||||
VM_CONDOPCODE_DEF( 0x00DE )
|
||||
@ -192,6 +216,29 @@ VM_CONDOPCODE_DEF( 0x00E1 )
|
||||
return false;
|
||||
}
|
||||
|
||||
VM_CONDOPCODE_DEF( 0x00E5 )
|
||||
{
|
||||
auto character = static_cast<CharacterController*>(*p->at(0).handle);
|
||||
glm::vec2 position(p->at(1).real, p->at(2).real);
|
||||
glm::vec2 radius(p->at(3).real, p->at(4).real);
|
||||
bool show = p->at(5).integer;
|
||||
|
||||
if( character->getCharacter()->getCurrentVehicle() == nullptr )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto vp = character->getCharacter()->getCurrentVehicle()->getPosition();
|
||||
glm::vec2 distance = glm::abs(position - glm::vec2(vp));
|
||||
|
||||
if(distance.x <= radius.x && distance.y <= radius.y)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
VM_CONDOPCODE_DEF( 0x0100 )
|
||||
{
|
||||
auto controller = static_cast<CharacterController*>(*p->at(0).handle);
|
||||
@ -304,6 +351,22 @@ VM_OPCODE_DEF( 0x0152 )
|
||||
}
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x0159 )
|
||||
{
|
||||
auto controller = static_cast<CharacterController*>(*p->at(0).handle);
|
||||
if( controller != nullptr )
|
||||
{
|
||||
m->getWorld()->state.cameraTarget = controller->getCharacter();
|
||||
m->getWorld()->state.cameraFixed = false;
|
||||
}
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x015A )
|
||||
{
|
||||
m->getWorld()->state.cameraTarget = nullptr;
|
||||
m->getWorld()->state.cameraFixed = false;
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x015C )
|
||||
{
|
||||
auto it = m->getWorld()->gameData.zones.find(p->at(0).string);
|
||||
@ -646,7 +709,7 @@ VM_CONDOPCODE_DEF( 0x02DE )
|
||||
|
||||
VM_OPCODE_DEF( 0x02E3 )
|
||||
{
|
||||
auto vehicle = (VehicleObject*)(*p->at(0).handle);
|
||||
auto vehicle = static_cast<VehicleObject*>(*p->at(0).handle);
|
||||
if( vehicle )
|
||||
{
|
||||
*p->at(1).globalReal = vehicle->physVehicle->getCurrentSpeedKmHour();
|
||||
@ -688,12 +751,22 @@ VM_OPCODE_DEF( 0x02E7 )
|
||||
VM_OPCODE_DEF( 0x02E8 )
|
||||
{
|
||||
float time = m->getWorld()->gameTime - m->getWorld()->state.cutsceneStartTime;
|
||||
*p->at(0).globalInteger = time * 1000;
|
||||
if( m->getWorld()->state.skipCutscene )
|
||||
{
|
||||
*p->at(0).globalInteger = m->getWorld()->state.currentCutscene->tracks.duration * 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p->at(0).globalInteger = time * 1000;
|
||||
}
|
||||
}
|
||||
VM_CONDOPCODE_DEF( 0x02E9 )
|
||||
{
|
||||
if( m->getWorld()->state.currentCutscene ) {
|
||||
float time = m->getWorld()->gameTime - m->getWorld()->state.cutsceneStartTime;
|
||||
if( m->getWorld()->state.skipCutscene ) {
|
||||
return true;
|
||||
}
|
||||
return time > m->getWorld()->state.currentCutscene->tracks.duration;
|
||||
}
|
||||
return true;
|
||||
@ -865,20 +938,65 @@ VM_CONDOPCODE_DEF( 0x03C6 )
|
||||
return true;
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x03CF )
|
||||
{
|
||||
std::string name = p->at(0).string;
|
||||
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
|
||||
if(! m->getWorld()->gameData.loadAudio(m->getWorld()->missionAudio, name + ".wav"))
|
||||
{
|
||||
std::cerr << "Couldn't load mission audio " << name << std::endl;
|
||||
}
|
||||
}
|
||||
VM_CONDOPCODE_DEF( 0x03D0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x03D1 )
|
||||
{
|
||||
m->getWorld()->missionSound.setBuffer(m->getWorld()->missionAudio);
|
||||
m->getWorld()->missionSound.play();
|
||||
m->getWorld()->missionSound.setLoop(false);
|
||||
}
|
||||
VM_CONDOPCODE_DEF( 0x03D2 )
|
||||
{
|
||||
return true;
|
||||
return m->getWorld()->missionSound.getStatus() == sf::SoundSource::Stopped;
|
||||
}
|
||||
VM_OPCODE_DEF( 0x03D5 )
|
||||
{
|
||||
std::string id(p->at(0).string);
|
||||
|
||||
for( int i = 0; i < m->getWorld()->state.text.size(); )
|
||||
{
|
||||
if( m->getWorld()->state.text[i].id == id )
|
||||
{
|
||||
m->getWorld()->state.text.erase(m->getWorld()->state.text.begin() + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x03E1 )
|
||||
{
|
||||
*p->at(0).globalInteger = m->getWorld()->state.numHiddenPackagesDiscovered;
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x03E5 )
|
||||
{
|
||||
std::string id(p->at(0).string);
|
||||
std::string str = m->getWorld()->gameData.texts.text(id);
|
||||
unsigned short style = 12;
|
||||
m->getWorld()->state.text.push_back({
|
||||
id,
|
||||
str,
|
||||
m->getWorld()->gameTime,
|
||||
2.5f,
|
||||
style
|
||||
});
|
||||
}
|
||||
|
||||
VM_CONDOPCODE_DEF( 0x03EE )
|
||||
{
|
||||
return true;
|
||||
@ -939,6 +1057,11 @@ Opcodes3::Opcodes3()
|
||||
|
||||
VM_OPCODE_DEC( 0x00A5, 5, "Create Vehicle" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x00A7, 4, "Drive To" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x00AD, 2, "Set Driving Speed" );
|
||||
VM_OPCODE_DEC_U( 0x00AE, 2, "Set Driving Style" );
|
||||
|
||||
VM_OPCODE_DEC( 0x00BA, 3, "Print big" );
|
||||
VM_OPCODE_DEC( 0x00BC, 3, "Print Message Now" );
|
||||
|
||||
@ -948,12 +1071,15 @@ Opcodes3::Opcodes3()
|
||||
|
||||
VM_OPCODE_DEC_U( 0x00DA, 2, "Store Player Car" );
|
||||
VM_CONDOPCODE_DEC( 0x00DB, 2, "Is Character in Vehicle" );
|
||||
VM_CONDOPCODE_DEC( 0x00DC, 2, "Is Player in Vehicle" );
|
||||
|
||||
VM_CONDOPCODE_DEC( 0x00DE, 2, "Is Player In Model" );
|
||||
|
||||
VM_CONDOPCODE_DEC( 0x00E0, 1, "Is Player In Any Vehicle" );
|
||||
VM_CONDOPCODE_DEC( 0x00E1, 2, "Is Button Pressed" );
|
||||
|
||||
VM_CONDOPCODE_DEC( 0x00E5, 6, "Is Player in 2D Area in Vehicle" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0E4, 6, "Locate Player on foot 2D" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x00F5, 8, "Locate Player In Sphere" );
|
||||
@ -970,6 +1096,8 @@ Opcodes3::Opcodes3()
|
||||
VM_CONDOPCODE_DEC( 0x0119, 1, "Is Vehicle Dead" );
|
||||
|
||||
VM_CONDOPCODE_DEC( 0x0121, 2, "Is Player In Zone" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0129, 4, "Create Character In Car" );
|
||||
|
||||
VM_OPCODE_DEC( 0x014B, 13, "Create Car Generator" );
|
||||
VM_OPCODE_DEC( 0x014C, 2, "Set Car Generator count" );
|
||||
@ -982,9 +1110,9 @@ Opcodes3::Opcodes3()
|
||||
VM_OPCODE_DEC( 0x0152, 17, "Set zone car info" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0158, 3, "Camera Follow Vehicle" );
|
||||
VM_OPCODE_DEC_U( 0x0159, 3, "Camera Follow Character" );
|
||||
VM_OPCODE_DEC( 0x0159, 3, "Camera Follow Character" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x015A, 0, "Reset Camera" );
|
||||
VM_OPCODE_DEC( 0x015A, 0, "Reset Camera" );
|
||||
|
||||
VM_OPCODE_DEC( 0x015C, 11, "Set zone ped info" );
|
||||
|
||||
@ -1012,14 +1140,17 @@ Opcodes3::Opcodes3()
|
||||
VM_OPCODE_DEC_U( 0x0181, 2, "Link Character Mission Flag" );
|
||||
VM_OPCODE_DEC_U( 0x0182, 2, "Unknown Character Opcode" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0186, 2, "Add Blip for Vehicle" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x018A, 4, "Add Blip for Coord" );
|
||||
VM_OPCODE_DEC_U( 0x018B, 2, "Change Blip Display Mode" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x018D, 5, "Create soundscape" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x018E, 1, "Remove Sound" );
|
||||
|
||||
VM_CONDOPCODE_DEC( 0x019C, 8, "Is Player in Area on Foot" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x018B, 2, "Change Blip Display Mode" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x018D, 5, "Create soundscape" );
|
||||
|
||||
VM_OPCODE_DEC( 0x01B4, 2, "Set Player Input Enabled" );
|
||||
|
||||
VM_OPCODE_DEC( 0x01B6, 1, "Set Weather Now" );
|
||||
@ -1171,10 +1302,13 @@ Opcodes3::Opcodes3()
|
||||
VM_OPCODE_DEC_U( 0x038B, 0, "Load Requested Models Now" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0395, 5, "Clear Area Vehicles and Pedestrians" );
|
||||
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0397, 2, "Set Vehicle Siren" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0399, 7, "Disable ped paths in angled cube" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x039D, 12, "Scatter Particles" );
|
||||
VM_OPCODE_DEC_U( 0x039E, 2, "Set Character can be dragged out" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x03AD, 1, "Set Garbage Enabled" );
|
||||
|
||||
@ -1196,20 +1330,20 @@ Opcodes3::Opcodes3()
|
||||
|
||||
VM_OPCODE_DEC_U( 0x03CB, 3, "Load Area Near" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x03CF, 1, "Load Audio" );
|
||||
VM_OPCODE_DEC( 0x03CF, 1, "Load Audio" );
|
||||
|
||||
VM_CONDOPCODE_DEC( 0x03D0, 0, "Is Audio Loaded" );
|
||||
VM_OPCODE_DEC_U( 0x03D1, 0, "Play Mission Audio" );
|
||||
VM_OPCODE_DEC( 0x03D1, 0, "Play Mission Audio" );
|
||||
VM_CONDOPCODE_DEC( 0x03D2, 0, "Is Mission Audio Finished" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x03D5, 1, "Clear This Print" );
|
||||
VM_OPCODE_DEC( 0x03D5, 1, "Clear This Print" );
|
||||
VM_OPCODE_DEC_U( 0x03D6, 1, "Clear This Big Print" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x03DA, 1, "Set Garage Camera Follows Player" );
|
||||
|
||||
VM_OPCODE_DEC( 0x03E1, 1, "Get Hidden Packages Found" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x03E5, 1, "Display Help Text" );
|
||||
VM_OPCODE_DEC( 0x03E5, 1, "Display Help Text" );
|
||||
VM_OPCODE_DEC_U( 0x03E6, 0, "Clear Help Text" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x03EB, 0, "Clear Small Prints" );
|
||||
@ -1230,6 +1364,7 @@ Opcodes3::Opcodes3()
|
||||
VM_OPCODE_DEC_U( 0x0418, 2, "Set Object Draw Ontop" );
|
||||
|
||||
VM_OPCODE_DEC( 0x041D, 1, "Set Camera Near Clip" );
|
||||
VM_OPCODE_DEC_U( 0x041E, 2, "Set Radio Station" );
|
||||
|
||||
VM_OPCODE_DEC_U( 0x0421, 1, "Force Rain" );
|
||||
|
||||
|
@ -73,6 +73,10 @@ VM_OPCODE_DEF( 0x001A ) {
|
||||
t->conditionResult = p->at(0).integer > *p->at(1).globalInteger;
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x001B ) {
|
||||
t->conditionResult = p->at(0).integer > *p->at(1).globalInteger;
|
||||
}
|
||||
|
||||
VM_OPCODE_DEF( 0x0020 ) {
|
||||
t->conditionResult = *p->at(0).globalReal > p->at(1).integer;
|
||||
}
|
||||
@ -205,6 +209,7 @@ VM::VM()
|
||||
VM_OPCODE_DEC( 0x0019, 2, "Local Int Greater than Int" );
|
||||
|
||||
VM_OPCODE_DEC( 0x001A, 2, "Int Greater Than Global Int" );
|
||||
VM_OPCODE_DEC( 0x001B, 2, "Int Greater Than Var Int" );
|
||||
|
||||
VM_OPCODE_DEC( 0x0020, 2, "Global Float Greather than Float" );
|
||||
|
||||
|
@ -199,6 +199,10 @@ ScriptMachine::ScriptMachine(GameWorld *world, SCMFile *file, SCMOpcodes *ops)
|
||||
startThread(0);
|
||||
auto globals = _file->getGlobalsSize() / 4;
|
||||
_globals = new SCMByte[globals * SCM_VARIABLE_SIZE];
|
||||
for(int i = 0; i < globals * SCM_VARIABLE_SIZE; ++i)
|
||||
{
|
||||
_globals[i] = 0;
|
||||
}
|
||||
std::cout << globals << " " << SCM_VARIABLE_SIZE << std::endl;
|
||||
}
|
||||
|
||||
|
@ -306,6 +306,16 @@ void RWGame::render(float alpha)
|
||||
{
|
||||
messageText.setPosition(sz.x * 0.9f - std::round(b.width), sz.y * 0.8f - std::round(b.height / 2.f));
|
||||
}
|
||||
else if(t.osTextStyle == 12)
|
||||
{
|
||||
messageText.setPosition(10.f, 10.f);
|
||||
|
||||
auto bds = messageText.getGlobalBounds();
|
||||
sf::RectangleShape bg(sf::Vector2f(bds.width, bds.height));
|
||||
bg.setFillColor(sf::Color::Black);
|
||||
bg.setPosition(sf::Vector2f(bds.left, bds.top));
|
||||
window.draw(bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
float lowerBar = sz.y - sz.y * 0.1f;
|
||||
|
@ -139,12 +139,19 @@ void IngameState::tick(float dt)
|
||||
auto angle = glm::angleAxis(-_lookAngles.x, glm::vec3(0.f, 0.f, 1.f));
|
||||
|
||||
player->updateMovementDirection(angle * _movement, _movement);
|
||||
|
||||
auto target = getWorld()->state.cameraTarget;
|
||||
|
||||
if( target == nullptr )
|
||||
{
|
||||
target = player->getCharacter();
|
||||
}
|
||||
|
||||
auto position = player->getCharacter()->getPosition();
|
||||
auto position = target->getPosition();
|
||||
|
||||
float viewDistance = 4.f;
|
||||
|
||||
auto vehicle = player->getCharacter()->getCurrentVehicle();
|
||||
auto vehicle = ( target->type() == GameObject::Character ) ? static_cast<CharacterObject*>(target)->getCurrentVehicle() : nullptr;
|
||||
if( vehicle ) {
|
||||
auto model = vehicle->model;
|
||||
for(auto& g : model->model->geometries) {
|
||||
@ -190,7 +197,11 @@ void IngameState::handleEvent(const sf::Event &event)
|
||||
StateManager::get().enter(new DebugState(game, _look.position, _look.rotation));
|
||||
break;
|
||||
case sf::Keyboard::Space:
|
||||
if( player ) {
|
||||
if( getWorld()->state.currentCutscene )
|
||||
{
|
||||
getWorld()->state.skipCutscene = true;
|
||||
}
|
||||
else if( player ) {
|
||||
if( player->getCharacter()->getCurrentVehicle() ) {
|
||||
player->getCharacter()->getCurrentVehicle()->setHandbraking(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user