Showing the changes to interface/src/InterfaceActionFactory.cpp (1 of 12 files). Show all
Unified · Split
| @@ -18,32 +18,53 @@ · 17 unmodified lines | |||
| 18 | #include "InterfaceActionFactory.h" | 18 | #include "InterfaceActionFactory.h" |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | EntityActionPointer InterfaceActionFactory::factory(EntitySimulation* simulation, | 21 | EntityActionPointer interfaceActionFactory(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) { |
| 22 | EntityActionType type, | ||
| 23 | QUuid id, | ||
| 24 | EntityItemPointer ownerEntity, | ||
| 25 | QVariantMap arguments) { | ||
| 26 | EntityActionPointer action = nullptr; | ||
| 27 | switch (type) { | 22 | switch (type) { |
| 28 | case ACTION_TYPE_NONE: | 23 | case ACTION_TYPE_NONE: |
| 29 | return nullptr; | 24 | return nullptr; |
| 30 | case ACTION_TYPE_OFFSET: | 25 | case ACTION_TYPE_OFFSET: |
| 31 | action = (EntityActionPointer) new ObjectActionOffset(id, ownerEntity); | 26 | return (EntityActionPointer) new ObjectActionOffset(id, ownerEntity); |
| 32 | break; | ||
| 33 | case ACTION_TYPE_SPRING: | 27 | case ACTION_TYPE_SPRING: |
| 34 | action = (EntityActionPointer) new ObjectActionSpring(id, ownerEntity); | 28 | return (EntityActionPointer) new ObjectActionSpring(id, ownerEntity); |
| 35 | break; | ||
| 36 | case ACTION_TYPE_HOLD: | 29 | case ACTION_TYPE_HOLD: |
| 37 | action = (EntityActionPointer) new AvatarActionHold(id, ownerEntity); | 30 | return (EntityActionPointer) new AvatarActionHold(id, ownerEntity); |
| 38 | break; | ||
| 39 | } | 31 | } |
| 40 | 32 | ||
| 41 | bool ok = action->updateArguments(arguments); | 33 | assert(false); |
| 42 | if (ok) { | 34 | return nullptr; |
| 43 | ownerEntity->addAction(simulation, action); | 35 | } |
| 44 | return action; | 36 | |
| 37 | |||
| 38 | EntityActionPointer InterfaceActionFactory::factory(EntitySimulation* simulation, | ||
| 39 | EntityActionType type, | ||
| 40 | QUuid id, | ||
| 41 | EntityItemPointer ownerEntity, | ||
| 42 | QVariantMap arguments) { | ||
| 43 | EntityActionPointer action = interfaceActionFactory(type, id, ownerEntity); | ||
| 44 | if (action) { | ||
| 45 | bool ok = action->updateArguments(arguments); | ||
| 46 | if (ok) { | ||
| 47 | ownerEntity->addAction(simulation, action); | ||
| 48 | return action; | ||
| 49 | } | ||
| 45 | } | 50 | } |
| 51 | return action; | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | EntityActionPointer InterfaceActionFactory::factoryBA(EntitySimulation* simulation, | ||
| 56 | EntityItemPointer ownerEntity, | ||
| 57 | QByteArray data) { | ||
| 58 | QDataStream ds(data); | ||
| 59 | EntityActionType type; | ||
| 60 | QUuid id; | ||
| 61 | |||
| 62 | ds >> type; | ||
| 63 | ds >> id; | ||
| 64 | |||
| 65 | EntityActionPointer action = interfaceActionFactory(type, id, ownerEntity); | ||
| 46 | 66 | ||
| 47 | action = nullptr; | 67 | action->deserializeFromDataStream(ds); |
| 68 | ownerEntity->addAction(simulation, action); | ||
| 48 | return action; | 69 | return action; |
| 49 | } | 70 | } |