22 #ifndef LASTEXPRESS_ENTITY_H 23 #define LASTEXPRESS_ENTITY_H 25 #include "lastexpress/shared.h" 27 #include "lastexpress/sound/sound.h" 29 #include "lastexpress/helpers.h" 31 #include "common/array.h" 32 #include "common/func.h" 33 #include "common/serializer.h" 34 #include "common/textconsole.h" 38 class LastExpressEngine;
46 #define DECLARE_FUNCTION(name) \ 47 void setup_##name(); \ 48 void name(const SavePoint &savepoint); 50 #define DECLARE_VFUNCTION(name) \ 51 void setup_##name() override; \ 52 void name(const SavePoint &savepoint); 54 #define DECLARE_FUNCTION_1(name, param1) \ 55 void setup_##name(param1); \ 56 void name(const SavePoint &savepoint); 58 #define DECLARE_VFUNCTION_1(name, param1) \ 59 void setup_##name(param1) override; \ 60 void name(const SavePoint &savepoint); 62 #define DECLARE_FUNCTION_2(name, param1, param2) \ 63 void setup_##name(param1, param2); \ 64 void name(const SavePoint &savepoint); 66 #define DECLARE_VFUNCTION_2(name, param1, param2) \ 67 void setup_##name(param1, param2) override; \ 68 void name(const SavePoint &savepoint); 70 #define DECLARE_FUNCTION_3(name, param1, param2, param3) \ 71 void setup_##name(param1, param2, param3); \ 72 void name(const SavePoint &savepoint); 74 #define DECLARE_FUNCTION_4(name, param1, param2, param3, param4) \ 75 void setup_##name(param1, param2, param3, param4); \ 76 void name(const SavePoint &savepoint); 78 #define DECLARE_FUNCTION_NOSETUP(name) \ 79 void name(const SavePoint &savepoint); 81 #define DECLARE_NULL_FUNCTION() \ 82 void setup_nullfunction(); 87 #define ENTITY_CALLBACK(class, name, pointer) \ 88 Common::Functor1Mem<const SavePoint&, void, class>(pointer, &class::name) 90 #define ADD_CALLBACK_FUNCTION_TYPE(class, name, type) \ 91 _callbacks.push_back(new ENTITY_CALLBACK(class, name, this)); \ 92 _paramsTypeSetters.push_back(&EntityData::resetParametersType<EntityData::type, EntityData::EntityParametersIIII, EntityData::EntityParametersIIII>); 94 #define ADD_CALLBACK_FUNCTION_TYPE2(class, name, type1, type2) \ 95 _callbacks.push_back(new ENTITY_CALLBACK(class, name, this)); \ 96 _paramsTypeSetters.push_back(&EntityData::resetParametersType<EntityData::type1, EntityData::type2, EntityData::EntityParametersIIII>); 98 #define ADD_CALLBACK_FUNCTION_TYPE3(class, name, type1, type2, type3) \ 99 _callbacks.push_back(new ENTITY_CALLBACK(class, name, this)); \ 100 _paramsTypeSetters.push_back(&EntityData::resetParametersType<EntityData::type1, EntityData::type2, EntityData::type3>); 102 #define ADD_CALLBACK_FUNCTION(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersIIII) 103 #define ADD_CALLBACK_FUNCTION_I(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersIIII) 104 #define ADD_CALLBACK_FUNCTION_II(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersIIII) 105 #define ADD_CALLBACK_FUNCTION_III(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersIIII) 106 #define ADD_CALLBACK_FUNCTION_S(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersSIIS) 107 #define ADD_CALLBACK_FUNCTION_SI(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersSIIS) 108 #define ADD_CALLBACK_FUNCTION_SII(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersSIII) 109 #define ADD_CALLBACK_FUNCTION_SIII(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersSIII) 110 #define ADD_CALLBACK_FUNCTION_SIIS(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersSIIS) 111 #define ADD_CALLBACK_FUNCTION_SS(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersSSII) 112 #define ADD_CALLBACK_FUNCTION_SSI(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersSSII) 113 #define ADD_CALLBACK_FUNCTION_IS(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersISII) 114 #define ADD_CALLBACK_FUNCTION_ISS(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersISSI) 115 #define ADD_CALLBACK_FUNCTION_IIS(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersIISI) 116 #define ADD_CALLBACK_FUNCTION_IISS(class, name) ADD_CALLBACK_FUNCTION_TYPE(class, name, EntityParametersIISS) 118 #define ADD_NULL_FUNCTION() \ 119 _callbacks.push_back(new ENTITY_CALLBACK(Entity, nullfunction, this)); \ 120 _paramsTypeSetters.push_back(&(EntityData::resetParametersType<EntityData::EntityParametersIIII, EntityData::EntityParametersIIII, EntityData::EntityParametersIIII>)); 122 #define WRAP_SETUP_FUNCTION(className, method) \ 123 new Common::Functor0Mem<void, className>(this, &className::method) 125 #define WRAP_SETUP_FUNCTION_S(className, method) \ 126 new Common::Functor1Mem<const char *, void, className>(this, &className::method) 128 #define WRAP_SETUP_FUNCTION_B(className, method) \ 129 new Common::Functor1Mem<bool, void, className>(this, &className::method) 134 #define CURRENT_PARAM(index, id) \ 135 ((EntityData::EntityParametersIIII*)_data->getCurrentParameters(index))->param##id 137 #define ENTITY_PARAM(index, id) \ 138 ((EntityData::EntityParametersIIII*)_data->getParameters(8, index))->param##id 143 #define RESET_ENTITY_STATE(entity, class, function) \ 144 getEntities()->resetState(entity); \ 145 ((class *)getEntities()->get(entity))->function(); 152 #define EXPOSE_PARAMS(type) \ 153 type *params = (type *)_data->getCurrentParameters(); \ 155 error("[EXPOSE_PARAMS] Trying to call an entity function with invalid parameters"); \ 158 #define IMPLEMENT_FUNCTION_NOSETUP(index, class, name) \ 159 void class::name(const SavePoint &savepoint) { \ 160 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(index=" #index ")"); 163 #define IMPLEMENT_FUNCTION(index, class, name) \ 164 void class::setup_##name() { \ 165 Entity::setup(#class "::setup_" #name, index, _paramsTypeSetters[index]); \ 167 void class::name(const SavePoint &savepoint) { \ 168 EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ 169 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "() - action: %s", ACTION_NAME(savepoint.action)); 171 #define IMPLEMENT_FUNCTION_END } 174 #define IMPLEMENT_NULL_FUNCTION(index, class) \ 175 void class::setup_nullfunction() { \ 176 Entity::setup(#class "::setup_nullfunction", index, _paramsTypeSetters[index]); \ 180 #define IMPLEMENT_FUNCTION_I(index, class, name, paramType) \ 181 void class::setup_##name(paramType param1) { \ 182 Entity::setupI(#class "::setup_" #name, index, _paramsTypeSetters[index], param1); \ 184 void class::name(const SavePoint &savepoint) { \ 185 EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ 186 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d) - action: %s", params->param1, ACTION_NAME(savepoint.action)); 189 #define IMPLEMENT_FUNCTION_II(index, class, name, paramType1, paramType2) \ 190 void class::setup_##name(paramType1 param1, paramType2 param2) { \ 191 Entity::setupII(#class "::setup_" #name, index, _paramsTypeSetters[index], param1, param2); \ 193 void class::name(const SavePoint &savepoint) { \ 194 EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ 195 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d) - action: %s", params->param1, params->param2, ACTION_NAME(savepoint.action)); 198 #define IMPLEMENT_FUNCTION_III(index, class, name, paramType1, paramType2, paramType3) \ 199 void class::setup_##name(paramType1 param1, paramType2 param2, paramType3 param3) { \ 200 Entity::setupIII(#class "::setup_" #name, index, _paramsTypeSetters[index], param1, param2, param3); \ 202 void class::name(const SavePoint &savepoint) { \ 203 EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ 204 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %d) - action: %s", params->param1, params->param2, params->param3, ACTION_NAME(savepoint.action)); 207 #define IMPLEMENT_FUNCTION_S(index, class, name) \ 208 void class::setup_##name(const char *seq1) { \ 209 Entity::setupS(#class "::setup_" #name, index, _paramsTypeSetters[index], seq1); \ 211 void class::name(const SavePoint &savepoint) { \ 212 EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ 213 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s) - action: %s", (char *)¶ms->seq1, ACTION_NAME(savepoint.action)); 216 #define IMPLEMENT_FUNCTION_SI(index, class, name, paramType2) \ 217 void class::setup_##name(const char *seq1, paramType2 param4) { \ 218 Entity::setupSI(#class "::setup_" #name, index, _paramsTypeSetters[index], seq1, param4); \ 220 void class::name(const SavePoint &savepoint) { \ 221 EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ 222 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d) - action: %s", (char *)¶ms->seq1, params->param4, ACTION_NAME(savepoint.action)); 225 #define IMPLEMENT_FUNCTION_SII(index, class, name, paramType2, paramType3) \ 226 void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5) { \ 227 Entity::setupSII(#class "::setup_" #name, index, _paramsTypeSetters[index], seq1, param4, param5); \ 229 void class::name(const SavePoint &savepoint) { \ 230 EXPOSE_PARAMS(EntityData::EntityParametersSIII) \ 231 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d) - action: %s", (char *)¶ms->seq, params->param4, params->param5, ACTION_NAME(savepoint.action)); 234 #define IMPLEMENT_FUNCTION_SIII(index, class, name, paramType2, paramType3, paramType4) \ 235 void class::setup_##name(const char *seq, paramType2 param4, paramType3 param5, paramType4 param6) { \ 236 Entity::setupSIII(#class "::setup_" #name, index, _paramsTypeSetters[index], seq, param4, param5, param6); \ 238 void class::name(const SavePoint &savepoint) { \ 239 EXPOSE_PARAMS(EntityData::EntityParametersSIII) \ 240 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %d) - action: %s", (char *)¶ms->seq, params->param4, params->param5, params->param6, ACTION_NAME(savepoint.action)); 242 #define IMPLEMENT_FUNCTION_SIIS(index, class, name, paramType2, paramType3) \ 243 void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5, const char *seq2) { \ 244 Entity::setupSIIS(#class "::setup_" #name, index, _paramsTypeSetters[index], seq1, param4, param5, seq2); \ 246 void class::name(const SavePoint &savepoint) { \ 247 EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ 248 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %s) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); 250 #define IMPLEMENT_FUNCTION_SS(index, class, name) \ 251 void class::setup_##name(const char *seq1, const char *seq2) { \ 252 Entity::setupSS(#class "::setup_" #name, index, _paramsTypeSetters[index], seq1, seq2); \ 254 void class::name(const SavePoint &savepoint) { \ 255 EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ 256 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); 258 #define IMPLEMENT_FUNCTION_SSI(index, class, name, paramType3) \ 259 void class::setup_##name(const char *seq1, const char *seq2, paramType3 param7) { \ 260 Entity::setupSSI(#class "::setup_" #name, index, _paramsTypeSetters[index], seq1, seq2, param7); \ 262 void class::name(const SavePoint &savepoint) { \ 263 EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ 264 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s, %d) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, params->param7, ACTION_NAME(savepoint.action)); 266 #define IMPLEMENT_FUNCTION_IS(index, class, name, paramType) \ 267 void class::setup_##name(paramType param1, const char *seq) { \ 268 Entity::setupIS(#class "::setup_" #name, index, _paramsTypeSetters[index], param1, seq); \ 270 void class::name(const SavePoint &savepoint) { \ 271 EXPOSE_PARAMS(EntityData::EntityParametersISII) \ 272 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s) - action: %s", params->param1, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); 274 #define IMPLEMENT_FUNCTION_ISS(index, class, name, paramType) \ 275 void class::setup_##name(paramType param1, const char *seq1, const char *seq2) { \ 276 Entity::setupISS(#class "::setup_" #name, index, _paramsTypeSetters[index], param1, seq1, seq2); \ 278 void class::name(const SavePoint &savepoint) { \ 279 EXPOSE_PARAMS(EntityData::EntityParametersISSI) \ 280 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s, %s) - action: %s", params->param1, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); 282 #define IMPLEMENT_FUNCTION_IIS(index, class, name, paramType1, paramType2) \ 283 void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq) { \ 284 Entity::setupIIS(#class "::setup_" #name, index, _paramsTypeSetters[index], param1, param2, seq); \ 286 void class::name(const SavePoint &savepoint) { \ 287 EXPOSE_PARAMS(EntityData::EntityParametersIISI) \ 288 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); 290 #define IMPLEMENT_FUNCTION_IISS(index, class, name, paramType1, paramType2) \ 291 void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq1, const char *seq2) { \ 292 Entity::setupIISS(#class "::setup_" #name, index, _paramsTypeSetters[index], param1, param2, seq1, seq2); \ 294 void class::name(const SavePoint &savepoint) { \ 295 EXPOSE_PARAMS(EntityData::EntityParametersIISS) \ 296 debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); 307 virtual void update(uint32 index) = 0;
333 bool hasNonNullParameter() {
334 return param1 || param2 || param3 || param4 || param5 || param6 || param7 || param8;
338 return Common::String::format(
"IIII: %d %d %d %d %d %d %d %d\n", param1, param2, param3, param4, param5, param6, param7, param8);
341 void update(uint32 index)
override {
344 error(
"[EntityParametersIIII::update] Invalid index (was: %d)", index);
346 case 0: param1 = 1;
break;
347 case 1: param2 = 1;
break;
348 case 2: param3 = 1;
break;
349 case 3: param4 = 1;
break;
350 case 4: param5 = 1;
break;
351 case 5: param6 = 1;
break;
352 case 6: param7 = 1;
break;
353 case 7: param8 = 1;
break;
358 s.syncAsUint32LE(param1);
359 s.syncAsUint32LE(param2);
360 s.syncAsUint32LE(param3);
361 s.syncAsUint32LE(param4);
362 s.syncAsUint32LE(param5);
363 s.syncAsUint32LE(param6);
364 s.syncAsUint32LE(param7);
365 s.syncAsUint32LE(param8);
390 void update(uint32 index)
override {
393 error(
"[EntityParametersSIII::update] Invalid index (was: %d)", index);
395 case 3: param4 = 1;
break;
396 case 4: param5 = 1;
break;
397 case 5: param6 = 1;
break;
398 case 6: param7 = 1;
break;
399 case 7: param8 = 1;
break;
405 s.syncAsUint32LE(param4);
406 s.syncAsUint32LE(param5);
407 s.syncAsUint32LE(param6);
408 s.syncAsUint32LE(param7);
409 s.syncAsUint32LE(param8);
420 memset(&seq1, 0, 13);
423 memset(&seq2, 0, 13);
430 void update(uint32 index)
override {
433 error(
"[EntityParametersSIIS::update] Invalid index (was: %d)", index);
435 case 3: param4 = 1;
break;
436 case 4: param5 = 1;
break;
442 s.syncAsUint32LE(param4);
443 s.syncAsUint32LE(param5);
456 memset(&seq1, 0, 13);
457 memset(&seq2, 0, 13);
465 void update(uint32 index)
override {
468 error(
"[EntityParametersISSI::update] Invalid index (was: %d)", index);
470 case 0: param1 = 1;
break;
471 case 7: param8 = 1;
break;
476 s.syncAsUint32LE(param1);
479 s.syncAsUint32LE(param8);
504 void update(uint32 index)
override {
507 error(
"[EntityParametersISII::update] Invalid index (was: %d)", index);
509 case 0: param1 = 1;
break;
510 case 4: param5 = 1;
break;
511 case 5: param6 = 1;
break;
512 case 6: param7 = 1;
break;
513 case 7: param8 = 1;
break;
518 s.syncAsUint32LE(param1);
520 s.syncAsUint32LE(param5);
521 s.syncAsUint32LE(param6);
522 s.syncAsUint32LE(param7);
523 s.syncAsUint32LE(param8);
534 memset(&seq1, 0, 13);
535 memset(&seq2, 0, 13);
544 void update(uint32 index)
override {
547 error(
"[EntityParametersSSII::update] Invalid index (was: %d)", index);
549 case 6: param7 = 1;
break;
550 case 7: param8 = 1;
break;
557 s.syncAsUint32LE(param7);
558 s.syncAsUint32LE(param8);
568 memset(&seq1, 0, 13);
569 memset(&seq2, 0, 13);
577 void update(uint32)
override {
578 error(
"[EntityParametersSSS::update] Cannot update this type of parameters");
597 memset(&seq1, 0, 13);
598 memset(&seq2, 0, 13);
605 void update(uint32 index)
override {
608 error(
"[EntityParametersIISS::update] Invalid index (was: %d)", index);
610 case 0: param1 = 1;
break;
611 case 1: param2 = 1;
break;
616 s.syncAsUint32LE(param1);
617 s.syncAsUint32LE(param2);
644 void update(uint32 index)
override {
647 error(
"[EntityParametersIISI::update] Invalid index (was: %d)", index);
649 case 0: param1 = 1;
break;
650 case 1: param2 = 1;
break;
651 case 5: param6 = 1;
break;
652 case 6: param7 = 1;
break;
653 case 7: param8 = 1;
break;
658 s.syncAsUint32LE(param1);
659 s.syncAsUint32LE(param2);
661 s.syncAsUint32LE(param6);
662 s.syncAsUint32LE(param7);
663 s.syncAsUint32LE(param8);
688 void update(uint32 index)
override {
691 error(
"[EntityParametersIIIS::update] Invalid index (was: %d)", index);
693 case 0: param1 = 1;
break;
694 case 1: param2 = 1;
break;
695 case 2: param3 = 1;
break;
696 case 6: param7 = 1;
break;
697 case 7: param8 = 1;
break;
702 s.syncAsUint32LE(param1);
703 s.syncAsUint32LE(param2);
704 s.syncAsUint32LE(param3);
706 s.syncAsUint32LE(param7);
707 s.syncAsUint32LE(param8);
732 void update(uint32 index)
override {
735 error(
"[EntityParametersI5S::update] Invalid index (was: %d)", index);
737 case 0: param1 = 1;
break;
738 case 1: param2 = 1;
break;
739 case 2: param3 = 1;
break;
740 case 3: param4 = 1;
break;
741 case 4: param5 = 1;
break;
746 s.syncAsUint32LE(param1);
747 s.syncAsUint32LE(param2);
748 s.syncAsUint32LE(param3);
749 s.syncAsUint32LE(param4);
750 s.syncAsUint32LE(param5);
760 for (
int i = 0; i < 4; i++)
769 for (
int i = 0; i < 4; i++)
770 SAFE_DELETE(parameters[i]);
775 for (uint i = 0; i <
ARRAYSIZE(parameters); i++)
776 parameters[i]->saveLoadWithSerializer(s);
783 EntityPosition entityPosition;
788 InventoryItem inventoryItem;
789 EntityDirection direction;
795 ClothesIndex clothes;
798 bool doProcessEntity;
801 EntityDirection directionSwitch;
816 memset(&callbacks, 0, 16 *
sizeof(byte));
818 entityPosition = kPositionNone;
819 location = kLocationOutsideCompartment;
822 entity = kEntityPlayer;
823 inventoryItem = kItemNone;
824 direction = kDirectionNone;
830 clothes = kClothesDefault;
833 doProcessEntity =
false;
836 directionSwitch = kDirectionNone;
854 str +=
Common::String::format(
"Entity position: %d - Location: %d - Car: %d\n", entityPosition, location, car);
855 str +=
Common::String::format(
"Entity: %d - Item: %d - Direction: %d\n", entity, inventoryItem, direction);
856 str +=
Common::String::format(
"Clothes: %d - Position: %d - Direction switch: %d\n", clothes, position, directionSwitch);
858 str +=
Common::String::format(
"field_497: %02d - field_49B: %i - field_4A1: %i\n", field_497, field_49B, field_4A1);
859 str +=
Common::String::format(
"field_4A9: %02d - field_4AA: %i - Car 2: %d\n", field_4A9, field_4AA, car2);
861 str +=
"Sequence: " + sequenceName +
" - Sequence 2: " + sequenceName2 +
"\n";
862 str +=
"Sequence prefix: " + sequenceNamePrefix +
" - Sequence copy: " + sequenceNameCopy +
"\n";
863 str +=
Common::String::format(
"Current frame: %i - Current frame 2: %i - Process entity: %d\n", currentFrame, currentFrame2, doProcessEntity);
866 str +=
Common::String::format(
"Functions: %d %d %d %d %d %d %d %d\n", callbacks[0], callbacks[1], callbacks[2], callbacks[3], callbacks[4], callbacks[5], callbacks[6], callbacks[7]);
867 str +=
Common::String::format(
"Callbacks: %d %d %d %d %d %d %d %d\n", callbacks[8], callbacks[9], callbacks[10], callbacks[11], callbacks[12], callbacks[13], callbacks[14], callbacks[15]);
887 template<
class T1,
class T2,
class T3>
890 params->parameters[0] =
new T1();
891 params->parameters[1] =
new T2();
892 params->parameters[2] =
new T3();
899 EntityParameters *getCurrentParameters(byte index = 0) {
return getParameters(_data.currentCall, index); }
902 byte getCallback(uint callback)
const;
903 byte getCurrentCallback() {
return getCallback(_data.currentCall); }
904 void setCallback(uint callback, byte index);
905 void setCurrentCallback(uint index) { setCallback(_data.currentCall, index); }
907 void updateParameters(uint32 index)
const;
929 byte getCallback() {
return _data->getCallback(_data->getCallData()->currentCall + 8); }
930 void setCallback(byte index) { _data->setCallback(_data->getCallData()->currentCall + 8, index); getData()->currentCall++; }
933 void setup(ChapterIndex index);
935 virtual void setup_chapter1() = 0;
936 virtual void setup_chapter2() = 0;
937 virtual void setup_chapter3() = 0;
938 virtual void setup_chapter4() = 0;
939 virtual void setup_chapter5() = 0;
942 virtual void setup_savegame(SavegameType, uint32) {
error(
"[Entity::setup_savegame] Trying to call the parent setup function. Use the specific entity function directly"); }
943 virtual void setup_enterExitCompartment(
const char *, ObjectIndex) {
error(
"[Entity::setup_enterExitCompartment] Trying to call the parent setup function. Use the specific entity function directly"); }
944 virtual void setup_updateEntity(CarIndex, EntityPosition) {
error(
"[Entity::setup_updateEntity] Trying to call the parent setup function. Use the specific entity function directly"); }
945 virtual void setup_playSound(
const char*) {
error(
"[Entity::setup_playSound] Trying to call the parent setup function. Use the specific entity function directly"); }
948 void saveLoadWithSerializer(
Common::Serializer &ser)
override { _data->saveLoadWithSerializer(ser, &_paramsTypeSetters); }
950 void nullfunction(
const SavePoint &savepoint) {}
956 EntityIndex _entityIndex;
968 void savegame(
const SavePoint &savepoint);
976 bool savegameBloodJacket(byte callback);
986 void playSound(
const SavePoint &savepoint,
bool resetItem =
false, SoundFlag flag = kSoundVolumeEntityDefault);
996 void draw(
const SavePoint &savepoint,
bool handleExcuseMe =
false);
1014 void updateFromTicks(
const SavePoint &savepoint);
1022 void updateFromTime(
const SavePoint &savepoint);
1031 void reset(
const SavePoint &savepoint, ClothesIndex maxClothes = kClothesDefault,
bool resetItem =
false);
1038 void callbackActionOnDirection(
const SavePoint &savepoint);
1045 void callbackActionRestaurantOrSalon(
const SavePoint &savepoint);
1055 void updateEntity(
const SavePoint &savepoint,
bool handleExcuseMe =
false);
1067 void callSavepoint(
const SavePoint &savepoint,
bool handleExcuseMe =
false);
1079 void enterExitCompartment(
const SavePoint &savepoint, EntityPosition position1 = kPositionNone, EntityPosition position2 = kPositionNone, CarIndex car = kCarNone, ObjectIndex compartment = kObjectNone,
bool alternate =
false,
bool updateLocation =
false);
1103 void goToCompartmentFromCompartment(
const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom,
Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo,
Common::String sequenceTo);
1114 void updatePosition(
const SavePoint &savepoint,
bool handleExcuseMe =
false);
1119 void callbackAction();
1124 void setup(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter);
1125 void setupI(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter, uint param1);
1126 void setupII(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter, uint param1, uint param2);
1127 void setupIII(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter, uint param1, uint param2, uint param3);
1128 void setupS(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter,
const char *seq1);
1129 void setupSS(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter,
const char *seq1,
const char *seq2);
1130 void setupSI(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter,
const char *seq1, uint param4);
1131 void setupSII(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter,
const char *seq1, uint param4, uint param5);
1132 void setupSIII(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter,
const char *seq, uint param4, uint param5, uint param6);
1133 void setupSIIS(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter,
const char *seq1, uint param4, uint param5,
const char *seq2);
1134 void setupSSI(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter,
const char *seq1,
const char *seq2, uint param7);
1135 void setupIS(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter, uint param1,
const char *seq);
1136 void setupISS(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter, uint param1,
const char *seq1,
const char *seq2);
1137 void setupIIS(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter, uint param1, uint param2,
const char *seq);
1138 void setupIISS(
const char *name, uint index, EntityData::TypeSetter paramsTypeSetter, uint param1, uint param2,
const char *seq1,
const char *seq2);
1144 bool updateParameter(uint ¶meter, uint timeType, uint delta)
const;
1145 bool updateParameterCheck(uint ¶meter, uint timeType, uint delta)
const;
1146 bool updateParameterTime(TimeValue timeValue,
bool check, uint ¶meter, uint delta)
const;
1149 bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback,
Common::Functor0<void> *
function);
1152 bool timeCheckCallbackInventory(TimeValue timeValue, uint ¶meter, byte callback,
Common::Functor0<void> *
function);
1153 bool timeCheckCar(TimeValue timeValue, uint ¶meter, byte callback,
Common::Functor0<void> *
function);
1154 void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action)
const;
1155 void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectModel model)
const;
1156 bool timeCheckCallbackAction(TimeValue timeValue, uint ¶meter);
1157 bool timeCheckPlaySoundUpdatePosition(TimeValue timeValue, uint ¶meter, byte callback,
const char* sound, EntityPosition position);
1164 #endif // LASTEXPRESS_ENTITY_H #define ARRAYSIZE(x)
Definition: util.h:91
void syncBytes(byte *buf, uint32 size, Version minVersion=0, Version maxVersion=kLastVersion)
Definition: serializer.h:204
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: lastexpress.h:69
Definition: animation.h:45
Definition: serializer.h:79
Common::String toString()
Definition: entity.h:851
Definition: savepoint.h:54
EntityCallData()
Definition: entity.h:815
Definition: sequence.h:151
Definition: serializer.h:308
Definition: sequence.h:183
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1