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

Method queryHit

source/game/StarDamageManager.cpp:177–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177SmallList<pair<EntityId, HitType>, 4> DamageManager::queryHit(DamageSource const& source, EntityId causingId) const {
178 SmallList<pair<EntityId, HitType>, 4> resultList;
179 auto doQueryHit = [&source, &resultList, causingId, this](EntityPtr const& targetEntity) {
180 if (targetEntity->entityId() == causingId)
181 return;
182
183 if (!source.team.canDamage(targetEntity->getTeam(), targetEntity->entityId() == source.sourceEntityId))
184 return;
185
186 if (source.rayCheck) {
187 if (auto poly = source.damageArea.ptr<PolyF>()) {
188 if (auto sourceEntity = m_world->entity(source.sourceEntityId)) {
189 auto overlap = m_world->geometry().rectOverlap(targetEntity->metaBoundBox().translated(targetEntity->position()), poly->boundBox());
190 if (!overlap.isEmpty() && m_world->lineTileCollision(overlap.center(), sourceEntity->position()))
191 return;
192 }
193 } else if (auto line = source.damageArea.ptr<Line2F>()) {
194 if (auto hitPoly = targetEntity->hitPoly()) {
195 if (auto intersection = m_world->geometry().lineIntersectsPolyAt(*line, *hitPoly)) {
196 if (m_world->lineTileCollision(line->min(), *intersection))
197 return;
198 }
199 }
200 }
201 }
202
203 if (auto hitResult = targetEntity->queryHit(source))
204 resultList.append({targetEntity->entityId(), *hitResult});
205
206 return;
207 };
208
209 if (auto poly = source.damageArea.ptr<PolyF>())
210 m_world->forEachEntity(poly->boundBox(), doQueryHit);
211 else if (auto line = source.damageArea.ptr<Line2F>())
212 m_world->forEachEntityLine(line->min(), line->max(), doQueryHit);
213
214 return resultList;
215}
216
217bool DamageManager::isAuthoritative(EntityPtr const& causingEntity, EntityPtr const& targetEntity) {
218 // Damage manager is authoritative if either one of the entities is

Callers

nothing calls this directly

Calls 15

entityIdMethod · 0.80
canDamageMethod · 0.80
rectOverlapMethod · 0.80
lineIntersectsPolyAtMethod · 0.80
getTeamMethod · 0.45
entityMethod · 0.45
geometryMethod · 0.45
translatedMethod · 0.45
metaBoundBoxMethod · 0.45
positionMethod · 0.45
boundBoxMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected