macrosoft3dpinball/SpaceCadetPinball/TBlocker.cpp
type-two b671975742 Vendor SpaceCadetPinball, build for Apple Silicon
Reverse-engineered reimplementation of 3D Pinball for Windows - Space Cadet
from k4zmu2a/SpaceCadetPinball (MIT), upstream cb9b7b8, vendored rather than
submoduled so local patches are just edits.

- CMakeLists: stop hard-setting CMAKE_OSX_ARCHITECTURES so the documented -D
  override works; brew's SDL2 is arm64-only and universal linking failed.
- gitignore original .DAT/.MID assets, which are not ours to redistribute.
- CLAUDE.md: build line, upstream deviation, and where game data goes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 19:05:12 +10:00

73 lines
1.5 KiB
C++

#include "pch.h"
#include "TBlocker.h"
#include "control.h"
#include "loader.h"
#include "render.h"
#include "timer.h"
TBlocker::TBlocker(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
{
visualStruct visual{};
loader::query_visual(groupIndex, 0, &visual);
SoundIndex4 = visual.SoundIndex4;
SoundIndex3 = visual.SoundIndex3;
InitialDuration = 55;
ExtendedDuration = 5;
Threshold = 1000000000.0f;
Timer = 0;
MessageField = 0;
ActiveFlag = 0;
SpriteSet(-1);
}
int TBlocker::Message(MessageCode code, float value)
{
switch (code)
{
case MessageCode::SetTiltLock:
case MessageCode::PlayerChanged:
case MessageCode::Reset:
case MessageCode::TBlockerDisable:
if (Timer)
{
timer::kill(Timer);
Timer = 0;
}
MessageField = 0;
ActiveFlag = 0;
SpriteSet(-1);
if (code == MessageCode::TBlockerDisable)
loader::play_sound(SoundIndex3, this, "TBlocker1");
break;
case MessageCode::TBlockerEnable:
ActiveFlag = 1;
loader::play_sound(SoundIndex4, this, "TBlocker2");
SpriteSet(0);
if (Timer)
timer::kill(Timer);
Timer = 0;
if (value >= 0)
Timer = timer::set(value, this, TimerExpired);
break;
case MessageCode::TBlockerRestartTimeout:
if (Timer)
timer::kill(Timer);
Timer = timer::set(std::max(value, 0.0f), this, TimerExpired);
break;
default:
break;
}
return 0;
}
void TBlocker::TimerExpired(int timerId, void* caller)
{
auto blocker = static_cast<TBlocker*>(caller);
blocker->Timer = 0;
control::handler(MessageCode::ControlTimerExpired, blocker);
}