Showing the changes to interface/src/InterfaceActionFactory.cpp (1 of 12 files). Show all
Unified · Split
| @@ -18,32 +18,53 @@ · 17 unmodified lines | ||
| 18 | 18 | #include "InterfaceActionFactory.h" |
| 19 | 19 | |
| 20 | 20 | |
| 21 | −EntityActionPointer InterfaceActionFactory::factory(EntitySimulation* simulation, | |
| 22 | − EntityActionType type, | |
| 23 | − QUuid id, | |
| 24 | − EntityItemPointer ownerEntity, | |
| 25 | − QVariantMap arguments) { | |
| 26 | − EntityActionPointer action = nullptr; | |
| 21 | +EntityActionPointer interfaceActionFactory(EntityActionType type, QUuid id, EntityItemPointer ownerEntity) { | |
| 27 | 22 | switch (type) { |
| 28 | 23 | case ACTION_TYPE_NONE: |
| 29 | 24 | return nullptr; |
| 30 | 25 | case ACTION_TYPE_OFFSET: |
| 31 | − action = (EntityActionPointer) new ObjectActionOffset(id, ownerEntity); | |
| 32 | − break; | |
| 26 | + return (EntityActionPointer) new ObjectActionOffset(id, ownerEntity); | |
| 33 | 27 | case ACTION_TYPE_SPRING: |
| 34 | − action = (EntityActionPointer) new ObjectActionSpring(id, ownerEntity); | |
| 35 | − break; | |
| 28 | + return (EntityActionPointer) new ObjectActionSpring(id, ownerEntity); | |
| 36 | 29 | case ACTION_TYPE_HOLD: |
| 37 | − action = (EntityActionPointer) new AvatarActionHold(id, ownerEntity); | |
| 38 | − break; | |
| 30 | + return (EntityActionPointer) new AvatarActionHold(id, ownerEntity); | |
| 39 | 31 | } |
| 40 | 32 | |
| 41 | − bool ok = action->updateArguments(arguments); | |
| 42 | − if (ok) { | |
| 43 | − ownerEntity->addAction(simulation, action); | |
| 44 | − return action; | |
| 33 | + assert(false); | |
| 34 | + return nullptr; | |
| 35 | +} | |
| 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 | 69 | return action; |
| 49 | 70 | } |