| 15 | namespace Star { |
| 16 | |
| 17 | StatusController::StatusController(Json const& config) : m_statCollection(config) { |
| 18 | m_parentEntity = nullptr; |
| 19 | m_movementController = nullptr; |
| 20 | |
| 21 | m_statusProperties.reset(config.getObject("statusProperties", {})); |
| 22 | m_statusProperties.setOverrides( |
| 23 | [&](DataStream& ds, NetCompatibilityRules rules) { |
| 24 | if (rules.version() <= 1) ds << m_statusProperties.baseMap(); |
| 25 | else m_statusProperties.NetElementHashMap<String, Json>::netStore(ds, rules); |
| 26 | }, |
| 27 | [&](DataStream& ds, NetCompatibilityRules rules) { |
| 28 | if (rules.version() <= 1) m_statusProperties.reset(ds.read<JsonObject>()); |
| 29 | else m_statusProperties.NetElementHashMap<String, Json>::netLoad(ds, rules); |
| 30 | }, |
| 31 | [&](DataStream& ds, uint64_t fromVersion, NetCompatibilityRules rules) { |
| 32 | if (rules.version() <= 1) { |
| 33 | if (m_statusProperties.shouldWriteNetDelta(fromVersion, rules)) { |
| 34 | ds << m_statusProperties.baseMap(); |
| 35 | return true; |
| 36 | } |
| 37 | return false; |
| 38 | } |
| 39 | return m_statusProperties.NetElementHashMap<String, Json>::writeNetDelta(ds, fromVersion, rules); |
| 40 | }, |
| 41 | [&](DataStream& ds, float interp, NetCompatibilityRules rules) { |
| 42 | if (rules.version() <= 1) m_statusProperties.reset(ds.read<JsonObject>()); |
| 43 | else m_statusProperties.NetElementHashMap<String, Json>::readNetDelta(ds, interp, rules); |
| 44 | } |
| 45 | ); |
| 46 | |
| 47 | m_minimumLiquidStatusEffectPercentage = config.getFloat("minimumLiquidStatusEffectPercentage"); |
| 48 | m_appliesEnvironmentStatusEffects = config.getBool("appliesEnvironmentStatusEffects"); |
| 49 | m_appliesWeatherStatusEffects = config.getBool("appliesWeatherStatusEffects"); |
| 50 | m_environmentStatusEffectUpdateTimer = GameTimer(config.getFloat("environmentStatusEffectUpdateTimer", 0.15f)); |
| 51 | |
| 52 | m_primaryAnimationConfig = config.optString("primaryAnimationConfig"); |
| 53 | m_primaryScript.setScripts(jsonToStringList(config.get("primaryScriptSources", JsonArray()))); |
| 54 | m_primaryScript.setUpdateDelta(config.getUInt("primaryScriptDelta", 1)); |
| 55 | |
| 56 | uint64_t keepDamageSteps = config.getUInt("keepDamageNotificationSteps", 120); |
| 57 | m_recentHitsGiven.setHistoryLimit(keepDamageSteps); |
| 58 | m_recentDamageGiven.setHistoryLimit(keepDamageSteps); |
| 59 | m_recentDamageTaken.setHistoryLimit(keepDamageSteps); |
| 60 | |
| 61 | m_netGroup.addNetElement(&m_statCollection); |
| 62 | m_netGroup.addNetElement(&m_statusProperties); |
| 63 | m_netGroup.addNetElement(&m_parentDirectives); |
| 64 | m_netGroup.addNetElement(&m_uniqueEffectMetadata); |
| 65 | m_netGroup.addNetElement(&m_effectAnimators); |
| 66 | |
| 67 | if (m_primaryAnimationConfig) |
| 68 | m_primaryAnimatorId = m_effectAnimators.addNetElement(make_shared<EffectAnimator>(*m_primaryAnimationConfig)); |
| 69 | else |
| 70 | m_primaryAnimatorId = EffectAnimatorGroup::NullElementId; |
| 71 | } |
| 72 | |
| 73 | Json StatusController::diskStore() const { |
| 74 | JsonObject resourceValues; |
nothing calls this directly
no test coverage detected