convert line ends
[canaan.git] / prj / cam / src / shock / shkaijsa.cpp
blobbe489de44f4e064d9432d393a22bbd81d50ca604
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 ///////////////////////////////////////////////////////////////////////////////
7 // $Header: r:/t2repos/thief2/src/shock/shkaijsa.cpp,v 1.1 1998/07/14 11:18:13 JON Exp $
8 //
9 // AI Joint Slide Action
12 #include <shkaijsa.h>
14 #include <aibascmp.h>
15 #include <rendprop.h>
16 #include <objpos.h>
18 #include <cfgdbg.h>
20 // Must be last header
21 #include <dbmem.h>
23 ///////////////////////////////////////////////////////////////////////////////
25 // CLASS: cAIJointSlideAction
28 void cAIJointSlideAction::Set(int jointID, float target, float speed)
30 m_jointID = jointID;
31 m_target = target;
32 m_speed = speed;
35 ////////////////////////////////////////
37 STDMETHODIMP_(eAIResult) cAIJointSlideAction::Update()
39 if (ObjJointPos(m_pAIState->GetID())[m_jointID]==m_target)
41 result = kAIR_Success;
42 return result;
44 result = kAIR_NoResultSwitch;
45 return result;
48 ////////////////////////////////////////
50 STDMETHODIMP_(eAIResult) cAIJointSlideAction::Enact(ulong deltaTime)
52 float *pJointPos;
53 float delta;
55 pJointPos = ObjJointPos(m_pAIState->GetID());
56 if (pJointPos[m_jointID]<m_target)
58 delta = m_target-pJointPos[m_jointID];
59 if (delta<m_speed)
60 pJointPos[m_jointID] = m_target;
61 else
62 pJointPos[m_jointID] += m_speed;
64 else
66 delta = pJointPos[m_jointID]-m_target;
67 if (delta<m_speed)
68 pJointPos[m_jointID] = m_target;
69 else
70 pJointPos[m_jointID] -= m_speed;
72 ObjSetJointPos(m_pAIState->GetID(), pJointPos);
73 result = kAIR_NoResultSwitch;
74 return result;