Implement test chamber 2 logic
This commit is contained in:
parent
6c45c3437f
commit
7ee68bb904
Binary file not shown.
|
@ -34,7 +34,7 @@ float distanceFromStart(const CutsceneStep& startStep, const CutsceneStep& other
|
||||||
return relativeOffset.y;
|
return relativeOffset.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<StructureDataChunk> generateCutsceneStep(CutsceneStep& step, const RoomGeneratorOutput& roomOutput, Signals& signals) {
|
std::unique_ptr<StructureDataChunk> generateCutsceneStep(CutsceneStep& step, int stepIndex, std::map<std::string, int>& labels, const RoomGeneratorOutput& roomOutput, Signals& signals) {
|
||||||
std::unique_ptr<StructureDataChunk> result(new StructureDataChunk());
|
std::unique_ptr<StructureDataChunk> result(new StructureDataChunk());
|
||||||
|
|
||||||
if ((step.command == "play_sound" || step.command == "start_sound") && step.args.size() >= 1) {
|
if ((step.command == "play_sound" || step.command == "start_sound") && step.args.size() >= 1) {
|
||||||
|
@ -95,6 +95,17 @@ std::unique_ptr<StructureDataChunk> generateCutsceneStep(CutsceneStep& step, con
|
||||||
teleportPlayer->AddPrimitive(fromLocation);
|
teleportPlayer->AddPrimitive(fromLocation);
|
||||||
teleportPlayer->AddPrimitive(toLocation);
|
teleportPlayer->AddPrimitive(toLocation);
|
||||||
result->Add("teleportPlayer", std::move(teleportPlayer));
|
result->Add("teleportPlayer", std::move(teleportPlayer));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} else if (step.command == "goto" && step.args.size() >= 1) {
|
||||||
|
auto gotoLabel = labels.find(step.args[0]);
|
||||||
|
|
||||||
|
if (gotoLabel != labels.end()) {
|
||||||
|
result->AddPrimitive<const char*>("CutsceneStepTypeGoto");
|
||||||
|
std::unique_ptr<StructureDataChunk> gotoStep(new StructureDataChunk());
|
||||||
|
gotoStep->AddPrimitive(gotoLabel->second - stepIndex - 1);
|
||||||
|
result->Add("gotoStep", std::move(gotoStep));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,15 +116,31 @@ std::unique_ptr<StructureDataChunk> generateCutsceneStep(CutsceneStep& step, con
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void findLabelLocations(std::vector<std::shared_ptr<CutsceneStep>>& stepNodes, std::map<std::string, int>& labelLocations) {
|
||||||
|
std::size_t currIndex = 0;
|
||||||
|
|
||||||
|
while (currIndex < stepNodes.size()) {
|
||||||
|
auto curr = stepNodes.begin() + currIndex;
|
||||||
|
|
||||||
|
if ((*curr)->command == "label" && (*curr)->args.size() >= 1) {
|
||||||
|
labelLocations[(*curr)->args[0]] = (int)currIndex;
|
||||||
|
stepNodes.erase(curr);
|
||||||
|
} else {
|
||||||
|
++currIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void generateCutscenes(std::map<std::string, std::shared_ptr<Cutscene>>& output, CFileDefinition& fileDefinition, const RoomGeneratorOutput& roomOutput, Signals& signals, NodeGroups& nodeGroups) {
|
void generateCutscenes(std::map<std::string, std::shared_ptr<Cutscene>>& output, CFileDefinition& fileDefinition, const RoomGeneratorOutput& roomOutput, Signals& signals, NodeGroups& nodeGroups) {
|
||||||
std::vector<std::shared_ptr<CutsceneStep>> steps;
|
std::vector<std::shared_ptr<CutsceneStep>> steps;
|
||||||
|
|
||||||
for (auto& nodeInfo : nodeGroups.NodesForType(CUTSCENE_PREFIX)) {
|
std::vector<NodeWithArguments> stepNodes = nodeGroups.NodesForType(CUTSCENE_PREFIX);
|
||||||
|
|
||||||
|
for (auto& nodeInfo : stepNodes) {
|
||||||
if (nodeInfo.arguments.size() == 0) {
|
if (nodeInfo.arguments.size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string command = nodeInfo.arguments[0];
|
std::string command = nodeInfo.arguments[0];
|
||||||
|
|
||||||
std::vector<std::string> cutsceneParts;
|
std::vector<std::string> cutsceneParts;
|
||||||
|
@ -155,10 +182,17 @@ void generateCutscenes(std::map<std::string, std::shared_ptr<Cutscene>>& output,
|
||||||
return distanceFromStart(*firstStep, *a) < distanceFromStart(*firstStep, *b);
|
return distanceFromStart(*firstStep, *a) < distanceFromStart(*firstStep, *b);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
std::map<std::string, int> labelLocations;
|
||||||
|
|
||||||
|
findLabelLocations(cutscene.steps, labelLocations);
|
||||||
|
|
||||||
std::unique_ptr<StructureDataChunk> steps(new StructureDataChunk());
|
std::unique_ptr<StructureDataChunk> steps(new StructureDataChunk());
|
||||||
|
|
||||||
|
int currStepIndex = 0;
|
||||||
|
|
||||||
for (auto& step : cutscene.steps) {
|
for (auto& step : cutscene.steps) {
|
||||||
steps->Add(std::move(generateCutsceneStep(*step, roomOutput, signals)));
|
steps->Add(std::move(generateCutsceneStep(*step, currStepIndex, labelLocations, roomOutput, signals)));
|
||||||
|
++currStepIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string stepsName = fileDefinition.GetUniqueName(cutscene.name + "_steps");
|
std::string stepsName = fileDefinition.GetUniqueName(cutscene.name + "_steps");
|
||||||
|
|
|
@ -43,6 +43,9 @@ void cutsceneRunnerStartStep(struct CutsceneRunner* runner) {
|
||||||
gCurrentLevel->locations[step->teleportPlayer.toLocation].roomIndex
|
gCurrentLevel->locations[step->teleportPlayer.toLocation].roomIndex
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case CutsceneStepTypeGoto:
|
||||||
|
runner->currentStep += step->gotoStep.relativeInstructionIndex;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ enum CutsceneStepType {
|
||||||
CutsceneStepTypeWaitForSignal,
|
CutsceneStepTypeWaitForSignal,
|
||||||
CutsceneStepTypeTeleportPlayer,
|
CutsceneStepTypeTeleportPlayer,
|
||||||
CutsceneStepTypeLoadLevel,
|
CutsceneStepTypeLoadLevel,
|
||||||
|
CutsceneStepTypeGoto,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CutsceneStep {
|
struct CutsceneStep {
|
||||||
|
@ -63,6 +64,9 @@ struct CutsceneStep {
|
||||||
u16 fromLocation;
|
u16 fromLocation;
|
||||||
u16 levelIndex;
|
u16 levelIndex;
|
||||||
} loadLevel;
|
} loadLevel;
|
||||||
|
struct {
|
||||||
|
s16 relativeInstructionIndex;
|
||||||
|
} gotoStep;
|
||||||
int noop;
|
int noop;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue