reverse engineered from unitst::have_unbailable_sp_activities (partial implementation)
| 2045 | |
| 2046 | // reverse engineered from unitst::have_unbailable_sp_activities (partial implementation) |
| 2047 | bool Units::hasUnbailableSocialActivity(df::unit *unit) |
| 2048 | { |
| 2049 | // these can become constexpr with C++23 |
| 2050 | static const need_type_set pray_needs = need_type_set() |
| 2051 | .set(df::need_type::PrayOrMeditate); |
| 2052 | |
| 2053 | static const need_type_set socialize_needs = need_type_set() |
| 2054 | .set(df::need_type::Socialize) |
| 2055 | .set(df::need_type::BeCreative) |
| 2056 | .set(df::need_type::Excitement) |
| 2057 | .set(df::need_type::AdmireArt); |
| 2058 | |
| 2059 | static const need_type_set read_needs = need_type_set() |
| 2060 | .set(df::need_type::ThinkAbstractly) |
| 2061 | .set(df::need_type::LearnSomething); |
| 2062 | |
| 2063 | CHECK_NULL_POINTER(unit); |
| 2064 | |
| 2065 | if (unit->social_activities.empty()) { |
| 2066 | return false; |
| 2067 | } else if (unit->social_activities.size() > 1) { |
| 2068 | return true; // is this even possible? |
| 2069 | } |
| 2070 | |
| 2071 | auto activity = df::activity_entry::find(unit->social_activities[0]); |
| 2072 | if (activity) { |
| 2073 | using df::activity_entry_type; |
| 2074 | switch (activity->type) { |
| 2075 | case activity_entry_type::Socialize: |
| 2076 | return getFocusPenalty(unit, socialize_needs) <= -10000; |
| 2077 | case activity_entry_type::Prayer: |
| 2078 | return getFocusPenalty(unit, pray_needs) <= -10000; |
| 2079 | case activity_entry_type::Read: |
| 2080 | return getFocusPenalty(unit, read_needs) <= -10000; |
| 2081 | default: |
| 2082 | // consider unhandled activities as uninterruptible |
| 2083 | return true; |
| 2084 | } |
| 2085 | } |
| 2086 | // this should never happen |
| 2087 | return false; |
| 2088 | } |
| 2089 | |
| 2090 | bool Units::isJobAvailable(df::unit *unit, bool preserve_social = false){ |
| 2091 | if (unit->job.current_job) |