Match and link CScriptSwitch

This commit is contained in:
Phillip Stephens 2022-10-07 23:55:54 -07:00
parent b841756b36
commit 9cfd7f1776
6 changed files with 60 additions and 1 deletions

View File

@ -10,6 +10,7 @@
"editor.tabSize": 2,
"files.associations": {
"source_location": "cpp",
"math.h": "c"
},
"files.autoSave": "onFocusChange",
"files.insertFinalNewline": true,

View File

@ -151,6 +151,7 @@ $(DTK_FILES): MWCC_VERSION := 1.2.5
$(DTK_FILES): CFLAGS := $(CFLAGS_BASE)
$(SI_FILES): MWCC_VERSION := 1.2.5
$(SI_FILES): CFLAGS := $(CFLAGS_BASE)
#-------------------------------------------------------------------------------
# Recipes
#-------------------------------------------------------------------------------

View File

@ -32,6 +32,7 @@ COMPLETE_OBJECTS = [
"MetroidPrime/HUD/CHUDMemoParms",
"MetroidPrime/ScriptObjects/CScriptDebugCameraWaypoint",
"MetroidPrime/ScriptObjects/CScriptPickup",
"MetroidPrime/ScriptObjects/CScriptSwitch",
"Weapons/IWeaponRenderer",
"Collision/CMaterialList",
"Collision/CMaterialFilter",

View File

@ -0,0 +1,20 @@
#ifndef __CSCRIPTSWITCH_HPP__
#define __CSCRIPTSWITCH_HPP__
#include "MetroidPrime/CEntity.hpp"
class CScriptSwitch : public CEntity {
public:
CScriptSwitch(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, bool, bool, bool);
void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr);
~CScriptSwitch();
private:
u8 mOpened;
u8 mCloseOnOpened;
};
#endif // __CSCRIPTSWITCH_HPP__

View File

@ -254,7 +254,7 @@ METROIDPRIME :=\
$(BUILD_DIR)/asm/MetroidPrime/Enemies/CJellyZap.o\
$(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptControllerAction.o\
$(BUILD_DIR)/asm/MetroidPrime/Weapons/GunController/CGunMotion.o\
$(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptSwitch.o\
$(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptSwitch.o\
$(BUILD_DIR)/asm/MetroidPrime/BodyState/CABSIdle.o\
$(BUILD_DIR)/asm/MetroidPrime/BodyState/CABSFlinch.o\
$(BUILD_DIR)/asm/MetroidPrime/BodyState/CABSAim.o\

View File

@ -0,0 +1,36 @@
#include "MetroidPrime/ScriptObjects/CScriptSwitch.hpp"
CScriptSwitch::CScriptSwitch(TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
bool active, bool opened, bool closeOnOpened)
: CEntity(uid, info, active, name) {
mOpened = opened;
mCloseOnOpened = closeOnOpened;
}
void CScriptSwitch::Accept(IVisitor& visitor) { visitor.Visit(*this); }
void CScriptSwitch::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) {
if (GetActive()) {
switch (msg) {
case kSM_Open:
mOpened = true;
break;
case kSM_Close:
mOpened = false;
break;
case kSM_SetToZero: {
if (mOpened) {
SendScriptMsgs(kSS_Open, mgr, kSM_None);
if (mCloseOnOpened)
mOpened = false;
} else {
SendScriptMsgs(kSS_Closed, mgr, kSM_None);
}
break;
}
}
}
CEntity::AcceptScriptMsg(msg, objId, mgr);
}
CScriptSwitch::~CScriptSwitch() {}