2022-03-21 21:54:48 -04:00
|
|
|
#include "SetActorList.h"
|
|
|
|
|
2023-05-07 19:58:50 -04:00
|
|
|
#include <cassert>
|
|
|
|
|
2022-03-21 21:54:48 -04:00
|
|
|
#include "Globals.h"
|
|
|
|
#include "Utils/BitConverter.h"
|
|
|
|
#include "Utils/StringHelper.h"
|
|
|
|
#include "ZRoom/ZRoom.h"
|
|
|
|
|
|
|
|
SetActorList::SetActorList(ZFile* nParent) : ZRoomCommand(nParent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetActorList::ParseRawData()
|
|
|
|
{
|
|
|
|
ZRoomCommand::ParseRawData();
|
|
|
|
numActors = cmdArg1;
|
|
|
|
|
2023-05-07 19:58:50 -04:00
|
|
|
actorList = new ZActorList(parent);
|
|
|
|
actorList->ExtractFromBinary(segmentOffset, numActors);
|
2022-03-21 21:54:48 -04:00
|
|
|
}
|
|
|
|
|
2023-05-07 19:58:50 -04:00
|
|
|
void SetActorList::DeclareReferences(const std::string& prefix)
|
2022-03-21 21:54:48 -04:00
|
|
|
{
|
2023-05-07 19:58:50 -04:00
|
|
|
if (parent->HasDeclaration(segmentOffset))
|
2022-03-21 21:54:48 -04:00
|
|
|
{
|
2023-05-07 19:58:50 -04:00
|
|
|
delete actorList;
|
|
|
|
actorList = static_cast<ZActorList*>(parent->FindResource(segmentOffset));
|
|
|
|
assert(actorList != nullptr);
|
|
|
|
assert(actorList->GetResourceType() == ZResourceType::ActorList);
|
2022-03-21 21:54:48 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-07 19:58:50 -04:00
|
|
|
if (actorList->GetName() == "")
|
2022-03-21 21:54:48 -04:00
|
|
|
{
|
2023-05-07 19:58:50 -04:00
|
|
|
actorList->SetName(actorList->GetDefaultName(prefix));
|
2022-03-21 21:54:48 -04:00
|
|
|
}
|
2023-05-07 19:58:50 -04:00
|
|
|
actorList->DeclareVar(prefix, "");
|
|
|
|
parent->AddResource(actorList);
|
2022-03-21 21:54:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SetActorList::GetBodySourceCode() const
|
|
|
|
{
|
|
|
|
std::string listName;
|
2022-03-31 19:42:44 -04:00
|
|
|
Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName,
|
|
|
|
parent->workerID);
|
2022-03-21 21:54:48 -04:00
|
|
|
|
2023-05-07 19:58:50 -04:00
|
|
|
return StringHelper::Sprintf("SCENE_CMD_ACTOR_LIST(%i, %s)", numActors, listName.c_str());
|
2022-03-21 21:54:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string SetActorList::GetCommandCName() const
|
|
|
|
{
|
|
|
|
return "SCmdActorList";
|
|
|
|
}
|
|
|
|
|
|
|
|
RoomCommand SetActorList::GetRoomCommand() const
|
|
|
|
{
|
|
|
|
return RoomCommand::SetActorList;
|
|
|
|
}
|