MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / freshenActivePart

Method freshenActivePart

source/base/StarAnimatedPartSet.cpp:264–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264void AnimatedPartSet::freshenActivePart(Part& part) {
265 if (part.activePartDirty) {
266 // First reset all the active part information assuming that no state type
267 // x state match exists.
268 auto& activePart = part.activePart;
269 activePart.activeState = {};
270 activePart.properties = part.partProperties;
271
272 // Then go through each of the state types and states and look for a part
273 // state match in order of priority.
274 for (auto& stateTypePair : m_stateTypes) {
275 auto const& stateTypeName = stateTypePair.first;
276 auto& stateType = stateTypePair.second;
277
278 // Skip disabled state types
279 if (!stateType.enabled)
280 continue;
281
282 auto partStateType = part.partStates.ptr(stateTypeName);
283 if (!partStateType)
284 continue;
285
286 auto const& stateName = stateType.activeState.stateName;
287 auto partState = partStateType->ptr(stateName);
288 if (!partState)
289 continue;
290
291 // If we have a partState match, then set the active state information.
292 freshenActiveState(stateType);
293 activePart.activeState = stateType.activeState;
294 unsigned frame = stateType.activeState.frame;
295
296 // Then set the part state data, as well as any part state frame data if
297 // the current frame is within the list size.
298 activePart.properties.merge(partState->partStateProperties, true);
299
300 for (auto const& pair : partState->partStateFrameProperties) {
301 if (frame < pair.second.size())
302 activePart.properties[pair.first] = pair.second.get(frame);
303 }
304
305 // Each part can only have one state type x state match, so we are done.
306 break;
307 }
308
309 part.activePartDirty = false;
310 }
311}
312
313}

Callers 2

forEachActivePartMethod · 0.80

Calls 4

ptrMethod · 0.45
mergeMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected