Action nodes handling

This commit is contained in:
2026-02-01 23:25:38 +03:00
parent e6efd89bb0
commit 69035351a6
7 changed files with 81 additions and 40 deletions

View File

@@ -452,10 +452,14 @@ out:;
{
if (placeLocalOffset.find(place) == placeLocalOffset.end())
return;
std::cout << "local offset: " << placeLocalOffset[place]
<< std::endl;
std::cout << "parent offset: " << anode.position << std::endl;
Ogre::Quaternion newRotation =
anode.rotation * placeLocalRotation[place];
Ogre::Vector3 newPosition =
anode.position + newRotation * placeLocalOffset[place];
anode.position +
anode.rotation * placeLocalOffset[place];
if (ch.is_valid() && ch.has<CharacterBase>()) {
ch.get<CharacterBase>()
.mBodyNode->_setDerivedOrientation(newRotation);
@@ -478,38 +482,57 @@ out:;
delay += delta;
// activate anly after delay
if (ECS::get<Input>().act == 0 && delay > 0.2f) {
delay = 0.0f;
state = 10;
// Yay!!!
std::cout << "Node data: " << std::endl;
std::cout << anode.props.dump(4) << std::endl;
if (ch.is_valid()) {
PhysicsModule::controlPhysics(ch,
false);
// no control by player or ai
ch.add<CharacterControlDisable>();
if (word == "sit")
ch.set<CharacterInActuator>(
{ "sitting-chair",
{ 0, 0, 0 } });
// else
// ch.set<CharacterInActuator>(
// { "idle", { 0, 0, 0 } });
}
teleport("enter");
delay = 0.0f;
state = 5;
} else if (ECS::get<Input>().act == 0 &&
delay <= 0.2f) {
delay = 0.0f;
state = 10;
state = 100;
}
break;
case 5:
case 10:
if (ch.is_valid()) {
PhysicsModule::controlPhysics(ch, false);
// no control by player or ai
ch.add<CharacterControlDisable>();
// else
// ch.set<CharacterInActuator>(
// { "idle", { 0, 0, 0 } });
}
delay = 0.0f;
state++;
break;
case 11:
teleport("enter");
delay = 0.0f;
state++;
break;
case 12:
if (ch.is_valid()) {
if (word == "sit")
ch.set<CharacterInActuator>(
{ "sitting-chair",
{ 0, 0, 0 } });
}
teleport("enter");
delay = 0.0f;
state++;
break;
case 13:
teleport("enter");
delay = 0.0f;
state = 50;
break;
case 50:
// teleport again to handle possible problems caused by root motion
delay = 0.0f;
teleport("enter");
state++;
break;
case 6:
case 51:
// do not move anywhere until we depress key and wait a bit
if (ECS::get<Input>().act == 0)
delay += delta;
@@ -518,7 +541,7 @@ out:;
state++;
}
break;
case 7:
case 52:
// if the key is pressed for a second move to next state
if (ECS::get<Input>().act)
delay += delta;
@@ -527,15 +550,15 @@ out:;
state++;
}
break;
case 8:
case 53:
delay = 0.0;
state = 10;
state = 100;
break;
case 10:
case 100:
delay = 0.0;
state++;
break;
case 11:
case 101:
// wait until key is depressed for a second
if (ECS::get<Input>().act == 0)
delay += delta;
@@ -544,7 +567,7 @@ out:;
state++;
}
break;
case 12:
case 102:
delay = 0.0f;
state = 0;
return OK;