Defines a "animated" data set constructed in such a way that it is very useful for doing generic animations with lots of additional animation data. It is made up of two concepts, "states" and "parts". States: There are N "state types" defined, which each defines a set of mutually exclusive states that each "state type" can be in. For example, one state type might be "movement", and the "movemen
| 40 | // like damage or collision polys can be stored along with the animation |
| 41 | // frames, the part state, the base part, whichever is most applicable. |
| 42 | class AnimatedPartSet { |
| 43 | public: |
| 44 | struct ActiveStateInformation { |
| 45 | String stateTypeName; |
| 46 | String stateName; |
| 47 | float timer; |
| 48 | unsigned frame; |
| 49 | JsonObject properties; |
| 50 | }; |
| 51 | |
| 52 | struct ActivePartInformation { |
| 53 | String partName; |
| 54 | // If a state match is found, this will be set. |
| 55 | Maybe<ActiveStateInformation> activeState; |
| 56 | JsonObject properties; |
| 57 | }; |
| 58 | |
| 59 | enum AnimationMode { |
| 60 | End, |
| 61 | Loop, |
| 62 | Transition |
| 63 | }; |
| 64 | |
| 65 | struct State { |
| 66 | unsigned frames; |
| 67 | float cycle; |
| 68 | AnimationMode animationMode; |
| 69 | String transitionState; |
| 70 | JsonObject stateProperties; |
| 71 | JsonObject stateFrameProperties; |
| 72 | }; |
| 73 | |
| 74 | struct StateType { |
| 75 | float priority; |
| 76 | bool enabled; |
| 77 | String defaultState; |
| 78 | JsonObject stateTypeProperties; |
| 79 | OrderedHashMap<String, shared_ptr<State const>> states; |
| 80 | |
| 81 | ActiveStateInformation activeState; |
| 82 | State const* activeStatePointer; |
| 83 | bool activeStateDirty; |
| 84 | }; |
| 85 | |
| 86 | struct PartState { |
| 87 | JsonObject partStateProperties; |
| 88 | JsonObject partStateFrameProperties; |
| 89 | }; |
| 90 | |
| 91 | struct Part { |
| 92 | JsonObject partProperties; |
| 93 | StringMap<StringMap<PartState>> partStates; |
| 94 | |
| 95 | ActivePartInformation activePart; |
| 96 | bool activePartDirty; |
| 97 | }; |
| 98 | |
| 99 | AnimatedPartSet(); |