work on second test chamber

This commit is contained in:
James Lambert 2022-06-24 22:30:12 -06:00
parent 7ee68bb904
commit e788782e57
9 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -246,6 +246,7 @@ std::shared_ptr<TriggerGeneratorOutput> generateTriggers(const aiScene* scene, C
button.roomIndex = roomOutput.RoomForNode(nodeInfo.node);
button.signalIndex = nodeInfo.arguments.size() ? signals.SignalIndexForName(nodeInfo.arguments[0]) : -1;
button.cubeSignalIndex = nodeInfo.arguments.size() > 1 ? signals.SignalIndexForName(nodeInfo.arguments[1]) : -1;
output->buttons.push_back(button);
}
@ -262,6 +263,7 @@ void generateButtonsDefinition(CFileDefinition& fileDefinition, StructureDataChu
singleButton->Add(std::unique_ptr<StructureDataChunk>(new StructureDataChunk(ref.position)));
singleButton->AddPrimitive(ref.roomIndex);
singleButton->AddPrimitive(ref.signalIndex);
singleButton->AddPrimitive(ref.cubeSignalIndex);
buttonData->Add(std::move(singleButton));
}

View file

@ -17,6 +17,7 @@ struct Button {
aiVector3D position;
int roomIndex;
int signalIndex;
int cubeSignalIndex;
};
struct TriggerGeneratorOutput {

View file

@ -97,6 +97,7 @@ struct ButtonDefinition {
struct Vector3 location;
short roomIndex;
short signalIndex;
short cubeSignalIndex;
};
struct DecorDefinition {

View file

@ -40,6 +40,8 @@ struct ColliderTypeData gButtonCollider = {
#define BUTTON_MOVEMENT_AMOUNT 0.1f
#define BUTTON_MOVE_VELOCTY 0.3f
#define PRESSED_WITH_CUBE 2
void buttonRender(void* data, struct RenderScene* renderScene) {
struct Button* button = (struct Button*)data;
Mtx* matrix = renderStateRequestMatrices(renderScene->renderState, 1);
@ -72,6 +74,7 @@ void buttonInit(struct Button* button, struct ButtonDefinition* definition) {
button->signalIndex = definition->signalIndex;
button->originalPos = definition->location;
button->cubeSignalIndex = definition->cubeSignalIndex;
}
void buttonUpdate(struct Button* button) {
@ -84,6 +87,11 @@ void buttonUpdate(struct Button* button) {
if (other->body && other->body->mass > MASS_BUTTON_PRESS_THRESHOLD) {
shouldPress = 1;
if (other->body->flags & RigidBodyFlagsGrabbable) {
shouldPress = PRESSED_WITH_CUBE;
}
break;
}
@ -95,6 +103,10 @@ void buttonUpdate(struct Button* button) {
if (shouldPress) {
targetPos.y -= BUTTON_MOVEMENT_AMOUNT;
signalsSend(button->signalIndex);
if (shouldPress == PRESSED_WITH_CUBE) {
signalsSend(button->cubeSignalIndex);
}
}
if (targetPos.y != button->rigidBody.transform.position.y) {

View file

@ -10,6 +10,7 @@ struct Button {
struct RigidBody rigidBody;
short dynamicId;
short signalIndex;
short cubeSignalIndex;
struct Vector3 originalPos;
};