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

Method interact

source/game/objects/StarLoungeableObject.cpp:28–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28InteractAction LoungeableObject::interact(InteractRequest const& request) {
29 auto res = Object::interact(request);
30 if (res.type == InteractActionType::None && !m_sitPositions.empty()) {
31 Maybe<size_t> index;
32 Vec2F interactOffset =
33 direction() == Direction::Right ? position() - request.interactPosition : request.interactPosition - position();
34 for (size_t i = 0; i < m_sitPositions.size(); ++i) {
35 if (!index || vmag(m_sitPositions[i] + interactOffset) < vmag(m_sitPositions[*index] + interactOffset))
36 index = i;
37 }
38 return InteractAction(InteractActionType::SitDown, entityId(), *index);
39 } else {
40 return res;
41 }
42}
43
44size_t LoungeableObject::anchorCount() const {
45 return m_sitPositions.size();

Callers

nothing calls this directly

Calls 4

vmagFunction · 0.85
InteractActionClass · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected