mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 10:53:54 +00:00
Add swimming states
This commit is contained in:
parent
18b7008409
commit
fc307e64b0
2 changed files with 19 additions and 5 deletions
|
@ -46,12 +46,18 @@ static const struct {
|
||||||
{ CharState_Idle7, "idle7" },
|
{ CharState_Idle7, "idle7" },
|
||||||
{ CharState_Idle8, "idle8" },
|
{ CharState_Idle8, "idle8" },
|
||||||
{ CharState_Idle9, "idle9" },
|
{ CharState_Idle9, "idle9" },
|
||||||
|
{ CharState_IdleSwim, "idleswim" },
|
||||||
|
|
||||||
{ CharState_WalkForward, "walkforward" },
|
{ CharState_WalkForward, "walkforward" },
|
||||||
{ CharState_WalkBack, "walkback" },
|
{ CharState_WalkBack, "walkback" },
|
||||||
{ CharState_WalkLeft, "walkleft" },
|
{ CharState_WalkLeft, "walkleft" },
|
||||||
{ CharState_WalkRight, "walkright" },
|
{ CharState_WalkRight, "walkright" },
|
||||||
|
|
||||||
|
{ CharState_SwimWalkForward, "swimwalkforward" },
|
||||||
|
{ CharState_SwimWalkBack, "swimwalkback" },
|
||||||
|
{ CharState_SwimWalkLeft, "swimwalkleft" },
|
||||||
|
{ CharState_SwimWalkRight, "swimwalkright" },
|
||||||
|
|
||||||
{ CharState_Death1, "death1" },
|
{ CharState_Death1, "death1" },
|
||||||
{ CharState_Death2, "death2" },
|
{ CharState_Death2, "death2" },
|
||||||
{ CharState_Death3, "death3" },
|
{ CharState_Death3, "death3" },
|
||||||
|
@ -157,21 +163,23 @@ Ogre::Vector3 CharacterController::update(float duration)
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
||||||
const Ogre::Vector3 &vec = cls.getMovementVector(mPtr);
|
const Ogre::Vector3 &vec = cls.getMovementVector(mPtr);
|
||||||
|
|
||||||
|
bool inwater = MWBase::Environment::get().getWorld()->isSwimming(mPtr);
|
||||||
|
|
||||||
if(std::abs(vec.x/2.0f) > std::abs(vec.y))
|
if(std::abs(vec.x/2.0f) > std::abs(vec.y))
|
||||||
{
|
{
|
||||||
if(vec.x > 0.0f)
|
if(vec.x > 0.0f)
|
||||||
setState(CharState_WalkRight, true);
|
setState((inwater ? CharState_SwimWalkRight : CharState_WalkRight), true);
|
||||||
else if(vec.x < 0.0f)
|
else if(vec.x < 0.0f)
|
||||||
setState(CharState_WalkLeft, true);
|
setState((inwater ? CharState_SwimWalkLeft : CharState_WalkLeft), true);
|
||||||
}
|
}
|
||||||
else if(vec.y > 0.0f)
|
else if(vec.y > 0.0f)
|
||||||
setState(CharState_WalkForward, true);
|
setState((inwater ? CharState_SwimWalkForward : CharState_WalkForward), true);
|
||||||
else if(vec.y < 0.0f)
|
else if(vec.y < 0.0f)
|
||||||
setState(CharState_WalkBack, true);
|
setState((inwater ? CharState_SwimWalkBack : CharState_WalkBack), true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!(getState() >= CharState_Death1))
|
if(!(getState() >= CharState_Death1))
|
||||||
setState(CharState_Idle, true);
|
setState((inwater ? CharState_IdleSwim : CharState_Idle), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::Vector3 movement = Ogre::Vector3::ZERO;
|
Ogre::Vector3 movement = Ogre::Vector3::ZERO;
|
||||||
|
|
|
@ -23,12 +23,18 @@ enum CharacterState {
|
||||||
CharState_Idle7,
|
CharState_Idle7,
|
||||||
CharState_Idle8,
|
CharState_Idle8,
|
||||||
CharState_Idle9,
|
CharState_Idle9,
|
||||||
|
CharState_IdleSwim,
|
||||||
|
|
||||||
CharState_WalkForward,
|
CharState_WalkForward,
|
||||||
CharState_WalkBack,
|
CharState_WalkBack,
|
||||||
CharState_WalkLeft,
|
CharState_WalkLeft,
|
||||||
CharState_WalkRight,
|
CharState_WalkRight,
|
||||||
|
|
||||||
|
CharState_SwimWalkForward,
|
||||||
|
CharState_SwimWalkBack,
|
||||||
|
CharState_SwimWalkLeft,
|
||||||
|
CharState_SwimWalkRight,
|
||||||
|
|
||||||
/* Must be last! */
|
/* Must be last! */
|
||||||
CharState_Death1,
|
CharState_Death1,
|
||||||
CharState_Death2,
|
CharState_Death2,
|
||||||
|
|
Loading…
Reference in a new issue