1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-13 16:44:50 +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_HANDLE ) \
E( HAMMER_BLOCK ) \ E( HAMMER_BLOCK ) \
E( LIGHTNING ) \ E( LIGHTNING ) \
E( DOOR_LATCH ) \ E( MOVING_OBJECT ) \
E( BLOCK_1 ) \ E( BLOCK_1 ) \
E( BLOCK_2 ) \ E( BLOCK_2 ) \
E( BLOCK_3 ) \ E( BLOCK_3 ) \
@@ -674,7 +674,8 @@ namespace TR {
(type == DRAWBRIDGE && flags.active != ACTIVE) || (type == DRAWBRIDGE && flags.active != ACTIVE) ||
(type == SCION_HOLDER) || (type == SCION_HOLDER) ||
((type == HAMMER_HANDLE || type == HAMMER_BLOCK) && flags.collision) || ((type == HAMMER_HANDLE || type == HAMMER_BLOCK) && flags.collision) ||
(type == CRYSTAL); (type == CRYSTAL) ||
(type == MOVING_OBJECT);
} }
bool isPickup() const { bool isPickup() const {

View File

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

View File

@@ -518,7 +518,7 @@ struct Level : IGame {
case TR::Entity::TRAP_SWORD : return new TrapSword(this, index); case TR::Entity::TRAP_SWORD : return new TrapSword(this, index);
case TR::Entity::HAMMER_HANDLE : return new ThorHammer(this, index); case TR::Entity::HAMMER_HANDLE : return new ThorHammer(this, index);
case TR::Entity::LIGHTNING : return new Lightning(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 :
case TR::Entity::SWITCH_WATER : return new Switch(this, index); case TR::Entity::SWITCH_WATER : return new Switch(this, index);
case TR::Entity::PUZZLE_HOLE_1 : case TR::Entity::PUZZLE_HOLE_1 :

View File

@@ -1145,19 +1145,26 @@ struct TrapLava : Controller {
}; };
struct DoorLatch : Controller { struct MovingObject : Controller {
enum { enum {
STATE_CLOSE, STATE_CLOSE,
STATE_OPEN, STATE_OPEN,
}; };
DoorLatch(IGame *game, int entity) : Controller(game, entity) { MovingObject(IGame *game, int entity) : Controller(game, entity) {
getEntity().flags.collision = true; getEntity().flags.collision = true;
} }
virtual void update() { virtual void update() {
updateAnimation(true); updateAnimation(true);
animation.setState(isActive() ? STATE_OPEN : STATE_CLOSE); 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();
} }
}; };