1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-12 16:14:25 +02:00

#22 fix moving drill (LEVEL10A)

This commit is contained in:
XProger
2017-10-15 08:37:01 +03:00
parent 7d43b2426c
commit a50e0ccf61
4 changed files with 28 additions and 11 deletions

View File

@@ -58,7 +58,7 @@
E( HAMMER_HANDLE ) \
E( HAMMER_BLOCK ) \
E( LIGHTNING ) \
E( DOOR_LATCH ) \
E( MOVING_OBJECT ) \
E( BLOCK_1 ) \
E( BLOCK_2 ) \
E( BLOCK_3 ) \
@@ -674,7 +674,8 @@ namespace TR {
(type == DRAWBRIDGE && flags.active != ACTIVE) ||
(type == SCION_HOLDER) ||
((type == HAMMER_HANDLE || type == HAMMER_BLOCK) && flags.collision) ||
(type == CRYSTAL);
(type == CRYSTAL) ||
(type == MOVING_OBJECT);
}
bool isPickup() const {

View File

@@ -240,6 +240,7 @@ struct Lara : Character {
float hitTime;
int hitDir;
vec3 collisionOffset;
vec3 flowVelocity;
struct Braid {
Lara *lara;
@@ -1825,6 +1826,7 @@ struct Lara : Character {
break;
}
case TR::Action::FLOW :
applyFlow(level->cameras[cmd.args]);
break;
case TR::Action::FLIP : {
TR::Flags &flip = level->flipmap[cmd.args];
@@ -2516,6 +2518,8 @@ struct Lara : Character {
}
virtual void updateVelocity() {
flowVelocity = vec3(0);
if (getEntity().type != TR::Entity::LARA)
return;
@@ -2650,7 +2654,7 @@ struct Lara : Character {
collisionOffset = vec3(0.0f);
if (checkCollisions() || (velocity + collisionOffset).length2() >= 1.0f) // TODO: stop & smash anim
if (checkCollisions() || (velocity + flowVelocity + collisionOffset).length2() >= 1.0f) // TODO: stop & smash anim
move();
if (getEntity().type != TR::Entity::LARA) {
@@ -2754,7 +2758,7 @@ struct Lara : Character {
}
void move() {
vec3 vel = velocity * Core::deltaTime * 30.0f + collisionOffset;
vec3 vel = (velocity + flowVelocity) * Core::deltaTime * 30.0f + collisionOffset;
vec3 opos(pos), offset(0.0f);
float radius = stand == STAND_UNDERWATER ? LARA_RADIUS_WATER : LARA_RADIUS;
@@ -2899,10 +2903,15 @@ struct Lara : Character {
virtual void applyFlow(TR::Camera &sink) {
if (stand != STAND_UNDERWATER && stand != STAND_ONWATER) return;
vec3 v(0.0f);
v.x = (float)sign((sink.x / 1024 - (int)pos.x / 1024));
v.z = (float)sign((sink.z / 1024 - (int)pos.z / 1024));
velocity = v * (sink.speed * 8.0f);
vec3 target = vec3(sink.x, sink.y, sink.z);
flowVelocity = vec3(0);
float speed = sink.speed * 6.0f;
flowVelocity.x = clamp(target.x - pos.x, -speed, +speed);
flowVelocity.y = clamp(target.y - pos.y, -speed, +speed);
flowVelocity.z = clamp(target.z - pos.z, -speed, +speed);
}
uint32 getMidasMask() {

View File

@@ -518,7 +518,7 @@ struct Level : IGame {
case TR::Entity::TRAP_SWORD : return new TrapSword(this, index);
case TR::Entity::HAMMER_HANDLE : return new ThorHammer(this, index);
case TR::Entity::LIGHTNING : return new Lightning(this, index);
case TR::Entity::DOOR_LATCH : return new DoorLatch(this, index);
case TR::Entity::MOVING_OBJECT : return new MovingObject(this, index);
case TR::Entity::SWITCH :
case TR::Entity::SWITCH_WATER : return new Switch(this, index);
case TR::Entity::PUZZLE_HOLE_1 :

View File

@@ -1145,19 +1145,26 @@ struct TrapLava : Controller {
};
struct DoorLatch : Controller {
struct MovingObject : Controller {
enum {
STATE_CLOSE,
STATE_OPEN,
};
DoorLatch(IGame *game, int entity) : Controller(game, entity) {
MovingObject(IGame *game, int entity) : Controller(game, entity) {
getEntity().flags.collision = true;
}
virtual void update() {
updateAnimation(true);
animation.setState(isActive() ? STATE_OPEN : STATE_CLOSE);
pos += getDir() * (animation.getSpeed() * Core::deltaTime * 30.0f);
TR::Level::FloorInfo info;
level->getFloorInfo(getRoomIndex(), int(pos.x), int(pos.y), int(pos.z), info);
if (info.roomNext != TR::NO_ROOM)
getEntity().room = info.roomNext;
updateEntity();
}
};