1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-06-25 23:42:09 +02:00
SpaceCadetPinball/SpaceCadetPinball/TBlocker.cpp
Muzychenko Andrey 98f234fce3 Replaced GlobalAlloc with malloc.
WaveMix keeps GlobalAlloc for authenticity.
Fixed float to double casts.
Some cleanup.
2021-02-18 12:53:25 +03:00

74 lines
1.4 KiB
C++

#include "pch.h"
#include "TBlocker.h"
#include "control.h"
#include "loader.h"
#include "objlist_class.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;
TurnOnMsgValue = 55;
TurnOffMsgValue = 5;
Threshold = 1000000000.0f;
Timer = 0;
MessageField = 0;
ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr);
}
int TBlocker::Message(int code, float value)
{
switch (code)
{
case 1011:
case 1020:
case 1024:
case 51:
if (Timer)
{
timer::kill(Timer);
Timer = 0;
}
MessageField = 0;
ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr);
if (code == 51)
loader::play_sound(SoundIndex3);
return 0;
case 52:
ActiveFlag = 1;
loader::play_sound(SoundIndex4);
render::sprite_set_bitmap(RenderSprite, ListBitmap->Get(0));
break;
case 59:
break;
default:
return 0;
}
if (Timer)
timer::kill(Timer);
float timerTime;
if (value <= 0.0f)
timerTime = 0.0;
else
timerTime = value;
Timer = timer::set(timerTime, this, TimerExpired);
return 0;
}
void TBlocker::TimerExpired(int timerId, void* caller)
{
auto blocker = static_cast<TBlocker*>(caller);
blocker->Timer = 0;
control::handler(60, blocker);
}