triggers -- exposes trigger states to other code.

This commit is contained in:
Marc Chapman 2017-07-27 01:34:44 +01:00
parent b5539a45e3
commit 9682ba318b
2 changed files with 83 additions and 1 deletions

View file

@ -2076,6 +2076,32 @@ void Player::processTick(const Move* move)
} }
Parent::processTick(move); Parent::processTick(move);
// Check for state changes in the standard move triggers and
// set bits for any triggers that switched on this tick in
// the fx_s_triggers mask. Flag any changes to be packed to
// clients.
if (isServerObject())
{
fx_s_triggers = 0;
if (move)
{
U8 on_bits = 0;
for (S32 i = 0; i < MaxTriggerKeys; i++)
if (move->trigger[i])
on_bits |= BIT(i);
if (on_bits != move_trigger_states)
{
U8 switched_on_bits = (on_bits & ~move_trigger_states);
if (switched_on_bits)
{
fx_s_triggers |= (U32)switched_on_bits;
setMaskBits(TriggerMask);
}
move_trigger_states = on_bits;
}
}
}
// Warp to catch up to server // Warp to catch up to server
if (delta.warpTicks > 0) { if (delta.warpTicks > 0) {
delta.warpTicks--; delta.warpTicks--;
@ -2214,6 +2240,9 @@ void Player::advanceTime(F32 dt)
{ {
// Client side animations // Client side animations
Parent::advanceTime(dt); Parent::advanceTime(dt);
// Increment timer for triggering idle events.
if (idle_timer >= 0.0f)
idle_timer += dt;
updateActionThread(); updateActionThread();
updateAnimation(dt); updateAnimation(dt);
updateSplash(); updateSplash();
@ -3089,6 +3118,9 @@ void Player::updateMove(const Move* move)
setActionThread( seq, true, false, true ); setActionThread( seq, true, false, true );
mJumpSurfaceLastContact = JumpSkipContactsMax; mJumpSurfaceLastContact = JumpSkipContactsMax;
// Flag the jump event trigger.
fx_s_triggers |= PLAYER_JUMP_S_TRIGGER;
setMaskBits(TriggerMask);
} }
} }
else else
@ -3783,6 +3815,11 @@ void Player::setActionThread(U32 action,bool forward,bool hold,bool wait,bool fs
return; return;
} }
if (isClientObject())
{
mark_idle = (action == PlayerData::RootAnim);
idle_timer = (mark_idle) ? 0.0f : -1.0f;
}
PlayerData::ActionAnimation &anim = mDataBlock->actionList[action]; PlayerData::ActionAnimation &anim = mDataBlock->actionList[action];
if (anim.sequence != -1) if (anim.sequence != -1)
{ {
@ -3875,7 +3912,8 @@ void Player::updateActionThread()
offset = mDataBlock->decalOffset * getScale().x; offset = mDataBlock->decalOffset * getScale().x;
} }
if( triggeredLeft || triggeredRight ) process_client_triggers(triggeredLeft, triggeredRight);
if ((triggeredLeft || triggeredRight) && !noFootfallFX)
{ {
Point3F rot, pos; Point3F rot, pos;
RayInfo rInfo; RayInfo rInfo;
@ -4906,6 +4944,11 @@ Point3F Player::_move( const F32 travelTime, Collision *outCol )
// we can use it to do impacts // we can use it to do impacts
// and query collision. // and query collision.
*outCol = *collision; *outCol = *collision;
if (isServerObject() && bd > 6.8f && collision->normal.z > 0.7f)
{
fx_s_triggers |= PLAYER_LANDING_S_TRIGGER;
setMaskBits(TriggerMask);
}
// Subtract out velocity // Subtract out velocity
VectorF dv = collision->normal * (bd + sNormalElasticity); VectorF dv = collision->normal * (bd + sNormalElasticity);
@ -7430,6 +7473,38 @@ ConsoleMethod(Player, isAnimationLocked, bool, 2, 2, "isAnimationLocked()")
} }
void Player::process_client_triggers(bool triggeredLeft, bool triggeredRight)
{
bool mark_landing = false;
Point3F my_vel = getVelocity();
if (my_vel.z > 5.0f)
z_velocity = 1;
else if (my_vel.z < -5.0f)
z_velocity = -1;
else
{
if (z_velocity < 0)
mark_landing = true;
z_velocity = 0.0f;
}
fx_c_triggers = mark_fx_c_triggers;
if (triggeredLeft)
fx_c_triggers |= PLAYER_LF_FOOT_C_TRIGGER;
if (triggeredRight)
fx_c_triggers |= PLAYER_RT_FOOT_C_TRIGGER;
if (mark_landing)
fx_c_triggers |= PLAYER_LANDING_C_TRIGGER;
if (idle_timer > 10.0f)
{
fx_c_triggers |= PLAYER_IDLE_C_TRIGGER;
idle_timer = 0.0f;
}
if (fx_c_triggers & PLAYER_LANDING_S_TRIGGER)
{
fx_c_triggers &= ~(PLAYER_LANDING_S_TRIGGER);
}
}
#ifdef TORQUE_OPENVR #ifdef TORQUE_OPENVR
void Player::setControllers(Vector<OpenVRTrackedObject*> controllerList) void Player::setControllers(Vector<OpenVRTrackedObject*> controllerList)
{ {

View file

@ -20,6 +20,11 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _TSSHAPEINSTANCE_H_ #ifndef _TSSHAPEINSTANCE_H_
#define _TSSHAPEINSTANCE_H_ #define _TSSHAPEINSTANCE_H_
@ -690,6 +695,8 @@ protected:
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
bool hasAccumulation(); bool hasAccumulation();
// provides access to full mTriggerStates mask.
U32 getTriggerStateMask() const { return mTriggerStates; }
}; };