22 #ifndef MTROPOLIS_MODIFIERS_H 23 #define MTROPOLIS_MODIFIERS_H 25 #include "common/events.h" 27 #include "mtropolis/render.h" 28 #include "mtropolis/runtime.h" 29 #include "mtropolis/data.h" 36 struct ModifierLoaderContext;
37 class MiniscriptProgram;
38 class MiniscriptReferences;
39 class MiniscriptThread;
47 bool isBehavior()
const override {
return true; }
51 void removeModifier(
const Modifier *modifier)
override;
56 bool respondsToEvent(
const Event &evt)
const override;
58 void disable(
Runtime *runtime)
override;
60 #ifdef MTROPOLIS_DEBUG_ENABLE 61 const char *debugGetTypeName()
const override {
return "Behavior Modifier"; }
62 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
67 struct SwitchTaskData {
68 SwitchTaskData() : targetState(
false), eventID(EventIDs::kNothing), runtime(
nullptr) {}
71 EventIDs::EventID eventID;
75 struct PropagateTaskData {
76 PropagateTaskData() : index(0), eventID(EventIDs::kNothing), runtime(
nullptr) {}
79 EventIDs::EventID eventID;
83 struct DisableTaskData {
84 DisableTaskData() : runtime(
nullptr) {}
89 VThreadState switchTask(
const SwitchTaskData &taskData);
90 VThreadState propagateTask(
const PropagateTaskData &taskData);
91 VThreadState disableTask(
const DisableTaskData &taskData);
94 const char *getDefaultName()
const override;
110 bool respondsToEvent(
const Event &evt)
const override;
113 void disable(
Runtime *runtime)
override {}
115 #ifdef MTROPOLIS_DEBUG_ENABLE 116 const char *debugGetTypeName()
const override {
return "Miniscript Modifier"; }
117 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
122 const char *getDefaultName()
const override;
138 bool respondsToEvent(
const Event &evt)
const override;
141 void disable(
Runtime *runtime)
override {}
143 #ifdef MTROPOLIS_DEBUG_ENABLE 144 const char *debugGetTypeName()
const override {
return "Color Table Modifier"; }
145 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
150 const char *getDefaultName()
const override;
163 bool respondsToEvent(
const Event &evt)
const override;
166 void disable(
Runtime *runtime)
override {}
168 #ifdef MTROPOLIS_DEBUG_ENABLE 169 const char *debugGetTypeName()
const override {
return "Sound Fade Modifier"; }
170 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusNone; }
175 const char *getDefaultName()
const override;
180 uint16 _fadeToVolume;
181 uint32 _durationMSec;
188 bool respondsToEvent(
const Event &evt)
const override;
191 void disable(
Runtime *runtime)
override {}
193 #ifdef MTROPOLIS_DEBUG_ENABLE 194 const char *debugGetTypeName()
const override {
return "Save And Restore Modifier"; }
195 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
204 const char *getDefaultName()
const override;
219 bool respondsToEvent(
const Event &evt)
const override;
222 void disable(
Runtime *runtime)
override {}
227 #ifdef MTROPOLIS_DEBUG_ENABLE 228 const char *debugGetTypeName()
const override {
return "Messenger Modifier"; }
229 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
234 const char *getDefaultName()
const override;
244 bool respondsToEvent(
const Event &evt)
const override;
247 void disable(
Runtime *runtime)
override {}
252 #ifdef MTROPOLIS_DEBUG_ENABLE 253 const char *debugGetTypeName()
const override {
return "Set Modifier"; }
254 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
259 const char *getDefaultName()
const override;
271 uint32 getAliasID()
const;
273 bool isAlias()
const override;
275 void disable(
Runtime *runtime)
override {}
277 #ifdef MTROPOLIS_DEBUG_ENABLE 278 const char *debugGetTypeName()
const override {
return "Alias Modifier"; }
279 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
284 const char *getDefaultName()
const override;
293 bool respondsToEvent(
const Event &evt)
const override;
296 void disable(
Runtime *runtime)
override {}
298 #ifdef MTROPOLIS_DEBUG_ENABLE 299 const char *debugGetTypeName()
const override {
return "Change Scene Modifier"; }
300 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
305 const char *getDefaultName()
const override;
307 enum SceneSelectionType {
308 kSceneSelectionTypeNext,
309 kSceneSelectionTypePrevious,
310 kSceneSelectionTypeSpecific,
314 SceneSelectionType _sceneSelectionType;
315 uint32 _targetSectionGUID;
316 uint32 _targetSubsectionGUID;
317 uint32 _targetSceneGUID;
318 bool _addToReturnList;
329 bool respondsToEvent(
const Event &evt)
const override;
331 void disable(
Runtime *runtime)
override;
333 #ifdef MTROPOLIS_DEBUG_ENABLE 334 const char *debugGetTypeName()
const override {
return "Sound Effect Modifier"; }
335 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
340 const char *getDefaultName()
const override;
344 kSoundTypeAudioAsset,
347 void loadAndCacheAudio(
Runtime *runtime);
350 Event _terminateWhen;
352 SoundType _soundType;
367 bool respondsToEvent(
const Event &evt)
const override;
369 void disable(
Runtime *runtime)
override;
374 #ifdef MTROPOLIS_DEBUG_ENABLE 375 const char *debugGetTypeName()
const override {
return "Path Motion Modifier"; }
376 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusPartial; }
390 struct ExecuteTaskData {
391 ExecuteTaskData() : runtime(
nullptr) {}
396 struct TerminateTaskData {
397 TerminateTaskData() : runtime(
nullptr) {}
402 struct ChangePointsTaskData {
403 ChangePointsTaskData() : runtime(
nullptr), prevPoint(0), newPoint(0), isTerminal(
false) {}
411 struct TriggerMessageTaskData {
412 TriggerMessageTaskData() : runtime(
nullptr), pointIndex(0) {}
418 struct SendMessageToParentTaskData {
419 SendMessageToParentTaskData() : runtime(
nullptr), eventID(EventIDs::kNothing) {}
422 EventIDs::EventID eventID;
425 struct ChangeCelTaskData {
426 ChangeCelTaskData() : runtime(
nullptr), pointIndex(0) {}
432 struct ChangePositionTaskData {
433 ChangePositionTaskData() : runtime(
nullptr) {}
439 struct AdvanceFrameTaskData {
440 AdvanceFrameTaskData() : runtime(
nullptr), terminationTimeDUSec(0) {}
443 uint64 terminationTimeDUSec;
446 VThreadState executeTask(
const ExecuteTaskData &taskData);
447 VThreadState terminateTask(
const TerminateTaskData &taskData);
448 VThreadState changePointsTask(
const ChangePointsTaskData &taskData);
449 VThreadState triggerMessageTask(
const TriggerMessageTaskData &taskData);
450 VThreadState sendMessageToParentTask(
const SendMessageToParentTaskData &taskData);
451 VThreadState changeCelTask(
const ChangeCelTaskData &taskData);
452 VThreadState changePositionTask(
const ChangePositionTaskData &taskData);
453 VThreadState advanceFrameTask(
const AdvanceFrameTaskData &taskData);
455 void scheduleNextAdvance(
Runtime *runtime, uint64 startingFromTimeDUSec);
456 void advance(
Runtime *runtime);
459 const char *getDefaultName()
const override;
462 Event _terminateWhen;
467 bool _startAtBeginning;
469 uint64 _frameDurationDUSec;
477 bool _isAlternatingDirection;
478 uint _currentPointIndex;
479 uint64 _lastPointTimeDUSec;
489 bool respondsToEvent(
const Event &evt)
const override;
491 void disable(
Runtime *runtime)
override;
493 #ifdef MTROPOLIS_DEBUG_ENABLE 494 const char *debugGetTypeName()
const override {
return "Simple Motion Modifier"; }
495 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusNone; }
500 kMotionTypeOutOfScene = 1,
501 kMotionTypeIntoScene = 2,
502 kMotionTypeRandomBounce = 3,
505 enum DirectionFlags {
506 kDirectionFlagDown = 1,
507 kDirectionFlagUp = 2,
508 kDirectionFlagRight = 4,
509 kDirectionFlagLeft = 8,
512 void startRandomBounce(
Runtime *runtime);
513 void runRandomBounce(
Runtime *runtime);
516 const char *getDefaultName()
const override;
519 Event _terminateWhen;
521 MotionType _motionType;
522 uint16 _directionFlags;
524 uint32 _delayMSecTimes4800;
526 uint64 _lastTickTime;
537 bool respondsToEvent(
const Event &evt)
const override;
539 void disable(
Runtime *runtime)
override;
541 #ifdef MTROPOLIS_DEBUG_ENABLE 542 const char *debugGetTypeName()
const override {
return "Drag Motion Modifier"; }
543 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
548 const char *getDefaultName()
const override;
562 bool respondsToEvent(
const Event &evt)
const override;
564 void disable(
Runtime *runtime)
override;
566 #ifdef MTROPOLIS_DEBUG_ENABLE 567 const char *debugGetTypeName()
const override {
return "Vector Modifier"; }
568 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
573 const char *getDefaultName()
const override;
577 void trigger(
Runtime *runtime);
589 uint64 _lastTickTime;
596 bool respondsToEvent(
const Event &evt)
const override;
598 void disable(
Runtime *runtime)
override;
600 #ifdef MTROPOLIS_DEBUG_ENABLE 601 const char *debugGetTypeName()
const override {
return "Scene Transition Modifier"; }
602 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
607 const char *getDefaultName()
const override;
614 SceneTransitionTypes::SceneTransitionType _transitionType;
615 SceneTransitionDirections::SceneTransitionDirection _transitionDirection;
625 bool respondsToEvent(
const Event &evt)
const override;
627 void disable(
Runtime *runtime)
override;
629 enum TransitionType {
630 kTransitionTypeRectangularIris,
631 kTransitionTypeOvalIris,
641 #ifdef MTROPOLIS_DEBUG_ENABLE 642 const char *debugGetTypeName()
const override {
return "Element Transition Modifier"; }
643 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusPartial; }
648 const char *getDefaultName()
const override;
650 void continueTransition(
Runtime *runtime);
651 void completeTransition(
Runtime *runtime);
653 void setTransitionProgress(uint32 steps, uint32 maxSteps);
660 TransitionType _transitionType;
661 RevealType _revealType;
663 uint64 _transitionStartTime;
676 bool respondsToEvent(
const Event &evt)
const override;
678 void disable(
Runtime *runtime)
override;
680 #ifdef MTROPOLIS_DEBUG_ENABLE 681 const char *debugGetTypeName()
const override {
return "Shared Scene Modifier"; }
682 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
687 const char *getDefaultName()
const override;
691 uint32 _targetSectionGUID;
692 uint32 _targetSubsectionGUID;
693 uint32 _targetSceneGUID;
700 bool respondsToEvent(
const Event &evt)
const override;
702 void disable(
Runtime *runtime)
override {}
704 #ifdef MTROPOLIS_DEBUG_ENABLE 705 const char *debugGetTypeName()
const override {
return "If Messenger Modifier"; }
706 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
710 struct RunEvaluateAndSendCoroutine {
711 CORO_DEFINE_RETURN_TYPE(
void);
716 const char *getDefaultName()
const override;
734 bool respondsToEvent(
const Event &evt)
const override;
736 void disable(
Runtime *runtime)
override;
741 #ifdef MTROPOLIS_DEBUG_ENABLE 742 const char *debugGetTypeName()
const override {
return "Timer Messenger Modifier"; }
743 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
748 const char *getDefaultName()
const override;
750 void trigger(
Runtime *runtime);
753 Event _terminateWhen;
755 uint32 _milliseconds;
770 bool respondsToEvent(
const Event &evt)
const override;
772 void disable(
Runtime *runtime)
override;
777 void getCollisionProperties(
Modifier *&modifier, uint &edgeFlags,
bool &mustBeCompletelyOutside,
bool &continuous)
const override;
778 void triggerCollision(
Runtime *runtime)
override;
780 #ifdef MTROPOLIS_DEBUG_ENABLE 781 const char *debugGetTypeName()
const override {
return "Boundary Detection Modifier"; }
786 const char *getDefaultName()
const override;
788 enum ExitTriggerMode {
790 kExitTriggerOnceExited,
800 ExitTriggerMode _exitTriggerMode;
801 DetectionMode _detectionMode;
803 bool _detectBottomEdge;
804 bool _detectLeftEdge;
805 bool _detectRightEdge;
821 bool respondsToEvent(
const Event &evt)
const override;
823 void disable(
Runtime *runtime)
override;
828 #ifdef MTROPOLIS_DEBUG_ENABLE 829 const char *debugGetTypeName()
const override {
return "Collision Detection Messenger Modifier"; }
830 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusPartial; }
835 const char *getDefaultName()
const override;
837 struct EnableTaskData {
840 struct DisableTaskData {
843 VThreadState enableTask(
const EnableTaskData &taskData);
844 VThreadState disableTask(
const DisableTaskData &taskData);
846 void getCollisionProperties(
Modifier *&modifier,
bool &collideInFront,
bool &collideBehind,
bool &excludeParents)
const override;
847 void triggerCollision(
Runtime *runtime,
Structural *collidingElement,
bool wasInContact,
bool isInContact,
bool &outShouldStop)
override;
850 kDetectionModeFirstContact,
851 kDetectionModeWhileInContact,
852 kDetectionModeExiting,
859 DetectionMode _detectionMode;
863 bool _sendToCollidingElement;
864 bool _sendToOnlyFirstCollidingElement;
878 bool isKeyboardMessenger()
const override;
882 bool respondsToEvent(
const Event &evt)
const override;
884 void disable(
Runtime *runtime)
override;
889 #ifdef MTROPOLIS_DEBUG_ENABLE 890 const char *debugGetTypeName()
const override {
return "Keyboard Messenger Modifier"; }
891 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
896 const char *getDefaultName()
const override;
918 kMacRomanChar = 0xff,
926 bool _keyModControl : 1;
927 bool _keyModCommand : 1;
928 bool _keyModOption : 1;
930 KeyCodeType _keyCodeType;
940 bool respondsToEvent(
const Event &evt)
const override;
942 void disable(
Runtime *runtime)
override;
944 #ifdef MTROPOLIS_DEBUG_ENABLE 945 const char *debugGetTypeName()
const override {
return "Text Style Modifier"; }
950 const char *getDefaultName()
const override;
956 TextAlignment _alignment;
967 bool respondsToEvent(
const Event &evt)
const override;
969 void disable(
Runtime *runtime)
override;
971 #ifdef MTROPOLIS_DEBUG_ENABLE 972 const char *debugGetTypeName()
const override {
return "Graphic Modifier"; }
973 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
978 const char *getDefaultName()
const override;
992 bool respondsToEvent(
const Event &evt)
const override;
994 void disable(
Runtime *runtime)
override;
996 #ifdef MTROPOLIS_DEBUG_ENABLE 997 const char *debugGetTypeName()
const override {
return "Image Effect Modifier"; }
998 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusNone; }
1006 kTypeSelectedBevels,
1007 kTypeDeselectedBevels,
1012 struct ApplyTaskData {
1013 ApplyTaskData() : runtime(
nullptr) {}
1018 struct RemoveTaskData {
1019 RemoveTaskData() : runtime(
nullptr) {}
1025 const char *getDefaultName()
const override;
1027 VThreadState applyTask(
const ApplyTaskData &taskData);
1028 VThreadState removeTask(
const RemoveTaskData &taskData);
1035 bool _includeBorders;
1044 bool respondsToEvent(
const Event &evt)
const override;
1046 void disable(
Runtime *runtime)
override;
1048 #ifdef MTROPOLIS_DEBUG_ENABLE 1049 const char *debugGetTypeName()
const override {
return "Return Modifier"; }
1050 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusNone; }
1055 const char *getDefaultName()
const override;
1066 bool respondsToEvent(
const Event &evt)
const override;
1068 void disable(
Runtime *runtime)
override;
1070 #ifdef MTROPOLIS_DEBUG_ENABLE 1071 const char *debugGetTypeName()
const override {
return "Cursor Modifier V1"; }
1072 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusNone; }
1081 kCursor_HandPointUp,
1082 kCursor_HandPointRight,
1083 kCursor_HandPointLeft,
1084 kCursor_HandPointDown,
1085 kCursor_HandGrabColor,
1086 kCursor_HandOpenColor,
1095 const char *getDefaultName()
const override;
1098 uint32 _cursorIndex;
1110 void disable(
Runtime *runtime)
override;
1116 bool isCompoundVariable()
const override {
return true; }
1118 #ifdef MTROPOLIS_DEBUG_ENABLE 1119 const char *debugGetTypeName()
const override {
return "Compound Variable Modifier"; }
1120 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1130 void commitLoad()
const override;
1133 struct ChildSaveLoad {
1146 const char *getDefaultName()
const override;
1150 void removeModifier(
const Modifier *modifier)
override;
1172 #ifdef MTROPOLIS_DEBUG_ENABLE 1173 const char *debugGetTypeName()
const override {
return "Boolean Variable Modifier"; }
1174 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1180 const char *getDefaultName()
const override;
1199 void commitLoad()
const override;
1219 #ifdef MTROPOLIS_DEBUG_ENABLE 1220 const char *debugGetTypeName()
const override {
return "Integer Variable Modifier"; }
1221 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1227 const char *getDefaultName()
const override;
1246 void commitLoad()
const override;
1269 #ifdef MTROPOLIS_DEBUG_ENABLE 1270 const char *debugGetTypeName()
const override {
return "Integer Range Variable Modifier"; }
1271 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1277 const char *getDefaultName()
const override;
1296 void commitLoad()
const override;
1319 #ifdef MTROPOLIS_DEBUG_ENABLE 1320 const char *debugGetTypeName()
const override {
return "Vector Variable Modifier"; }
1321 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1327 const char *getDefaultName()
const override;
1345 void commitLoad()
const override;
1368 #ifdef MTROPOLIS_DEBUG_ENABLE 1369 const char *debugGetTypeName()
const override {
return "Point Variable Modifier"; }
1370 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1376 const char *getDefaultName()
const override;
1395 void commitLoad()
const override;
1415 #ifdef MTROPOLIS_DEBUG_ENABLE 1416 const char *debugGetTypeName()
const override {
return "Floating Point Variable Modifier"; }
1417 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1423 const char *getDefaultName()
const override;
1442 void commitLoad()
const override;
1462 #ifdef MTROPOLIS_DEBUG_ENABLE 1463 const char *debugGetTypeName()
const override {
return "String Variable Modifier"; }
1464 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusDone; }
1470 const char *getDefaultName()
const override;
1489 void commitLoad()
const override;
1509 bool respondsToEvent(
const Event &evt)
const override;
1514 #ifdef MTROPOLIS_DEBUG_ENABLE 1515 const char *debugGetTypeName()
const override {
return "Object Reference Variable Modifier V1"; }
1516 SupportStatus debugGetSupportStatus()
const override {
return kSupportStatusNone; }
1521 const char *getDefaultName()
const override;
1523 Event _setToSourcesParentWhen;
1542 void commitLoad()
const override;
Definition: runtime.h:816
Definition: runtime.h:2034
Definition: runtime.h:469
Definition: modifiers.h:266
Definition: runtime.h:330
Definition: modifier_factory.h:30
Definition: modifiers.h:986
Definition: runtime.h:925
Definition: modifiers.h:1500
Definition: modifiers.h:132
Definition: modifiers.h:1038
Definition: modifiers.h:482
EventType
Definition: events.h:49
Definition: modifiers.h:963
Definition: runtime.h:2195
Definition: modifiers.h:1280
Definition: modifiers.h:1453
Definition: runtime.h:440
Definition: runtime.h:1594
Definition: modifiers.h:1230
Definition: modifiers.h:533
Definition: runtime.h:2743
Definition: runtime.h:3035
Definition: modifiers.h:592
Definition: miniscript.h:421
Definition: modifiers.h:1106
Definition: modifiers.h:1473
Definition: runtime.h:544
Definition: modifiers.h:1330
Definition: modifiers.h:618
Definition: runtime.h:369
Definition: modifiers.h:240
Definition: modifiers.h:1257
Definition: runtime.h:1307
Definition: modifiers.h:1526
Definition: runtime.h:2432
Definition: modifiers.h:873
Definition: modifiers.h:1406
Definition: runtime.h:2118
Definition: modifiers.h:1163
Definition: modifiers.h:184
Definition: modifiers.h:106
Definition: modifiers.h:763
Definition: modifiers.h:556
Definition: modifiers.h:215
Definition: runtime.h:1108
Definition: runtime.h:3124
Definition: modifiers.h:289
Definition: modifiers.h:323
Definition: modifiers.h:360
Definition: modifiers.h:1379
Definition: modifiers.h:1307
Definition: keyboard.h:294
Definition: modifiers.h:814
Definition: modifiers.h:727
Definition: modifiers.h:669
Definition: modifiers.h:1183
Definition: modifiers.h:41
Definition: modifiers.h:696
Definition: runtime.h:3011
Definition: modifiers.h:936
Definition: runtime.h:2427
Definition: modifiers.h:157
Definition: modifiers.h:1210
Definition: modifiers.h:1356
Definition: runtime.h:3116
Definition: modifiers.h:1060
Definition: modifiers.h:1426