| 25 | namespace Star { |
| 26 | |
| 27 | Object::Object(ObjectConfigConstPtr config, Json const& parameters) { |
| 28 | m_config = config; |
| 29 | if (!parameters.isNull()) |
| 30 | m_parameters.reset(parameters.toObject()); |
| 31 | |
| 32 | auto jOrientations = m_parameters.ptr("customOrientations"); |
| 33 | if (jOrientations && jOrientations->isType(Json::Type::Array)) { |
| 34 | JsonArray base = m_config->config.get("orientations").toArray(); |
| 35 | auto orientations = jOrientations->toArray(); |
| 36 | for (size_t i = 0; i != orientations.size(); ++i) |
| 37 | base.set(i, jsonMergeNulling(base.get(i), orientations.get(i))); |
| 38 | m_orientations = ObjectDatabase::parseOrientations(m_config->path, base); |
| 39 | } |
| 40 | |
| 41 | m_animationTimer = 0.0f; |
| 42 | m_currentFrame = 0; |
| 43 | |
| 44 | m_lightFlickering = m_config->lightFlickering; |
| 45 | |
| 46 | m_tileDamageStatus = make_shared<EntityTileDamageStatus>(); |
| 47 | |
| 48 | m_orientationIndex = NPos; |
| 49 | |
| 50 | m_interactive.set(!configValue("interactAction", Json()).isNull()); |
| 51 | |
| 52 | m_broken = false; |
| 53 | m_unbreakable = m_config->unbreakable || configValue("unbreakable", false).toBool(); |
| 54 | m_direction.set(Direction::Left); |
| 55 | |
| 56 | m_health.set(m_config->health); |
| 57 | |
| 58 | m_currentFrame = -1; |
| 59 | |
| 60 | if (m_config->animationConfig) |
| 61 | m_networkedAnimator = make_shared<NetworkedAnimator>(m_config->animationConfig, m_config->path); |
| 62 | else |
| 63 | m_networkedAnimator = make_shared<NetworkedAnimator>(); |
| 64 | |
| 65 | if (m_config->damageTeam.type != TeamType::Null) { |
| 66 | setTeam(m_config->damageTeam); |
| 67 | } else { |
| 68 | setTeam(EntityDamageTeam(TeamType::Environment)); |
| 69 | } |
| 70 | |
| 71 | for (auto const& node : configValue("inputNodes", JsonArray()).iterateArray()) |
| 72 | m_inputNodes.append({jsonToVec2I(node), {}, {}}); |
| 73 | |
| 74 | for (auto const& node : configValue("outputNodes", JsonArray()).iterateArray()) |
| 75 | m_outputNodes.append({jsonToVec2I(node), {}, {}}); |
| 76 | |
| 77 | m_offeredQuests.set(configValue("offeredQuests", JsonArray()).toArray().transformed(&QuestArcDescriptor::fromJson)); |
| 78 | m_turnInQuests.set(jsonToStringSet(configValue("turnInQuests", JsonArray()))); |
| 79 | if (!m_offeredQuests.get().empty() || !m_turnInQuests.get().empty()) |
| 80 | m_interactive.set(true); |
| 81 | |
| 82 | setUniqueId(configValue("uniqueId").optString()); |
| 83 | |
| 84 | m_netGroup.addNetElement(&m_parameters); |
nothing calls this directly
no test coverage detected