Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
Add isActorSelectable
Browse files Browse the repository at this point in the history
References #38
  • Loading branch information
scemino committed Oct 23, 2019
1 parent 197dc69 commit aaad9e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class Engine : public NonCopyable
void actorSlotSelectable(Actor *pActor, bool selectable);
void actorSlotSelectable(int index, bool selectable);
void setActorSlotSelectable(ActorSlotSelectableMode mode);
bool isActorSelectable(Actor* pActor) const;
void setUseFlag(UseFlag flag, Entity *object);
void flashSelectableActor(bool on);

Expand Down
10 changes: 10 additions & 0 deletions src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,16 @@ void Engine::actorSlotSelectable(int index, bool selectable)
_pImpl->_actorsIconSlots.at(index - 1).selectable = selectable;
}

bool Engine::isActorSelectable(Actor* pActor) const
{
for (auto &&slot : _pImpl->_actorsIconSlots)
{
if(slot.pActor == pActor)
return slot.selectable;
}
return false;
}

void Engine::setActorSlotSelectable(ActorSlotSelectableMode mode) { _pImpl->_actorIcons.setMode(mode); }

void Engine::setUseFlag(UseFlag flag, Entity *object)
Expand Down
9 changes: 9 additions & 0 deletions src/Scripting/_ActorPack.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class _ActorPack : public Pack
engine.registerGlobalFunction(isActor, "isActor");
engine.registerGlobalFunction(isActorOnScreen, "isActorOnScreen");
engine.registerGlobalFunction(isActor, "is_actor");
engine.registerGlobalFunction(isActorSelectable, "isActorSelectable");
engine.registerGlobalFunction(masterActorArray, "masterActorArray");
engine.registerGlobalFunction(mumbleLine, "mumbleLine");
engine.registerGlobalFunction(sayLine, "sayLine");
Expand Down Expand Up @@ -1017,6 +1018,14 @@ class _ActorPack : public Pack
return 1;
}

static SQInteger isActorSelectable(HSQUIRRELVM v)
{
auto actor = ScriptEngine::getActor(v, 2);
bool isSelectable = g_pEngine->isActorSelectable(actor);
sq_pushbool(v, isSelectable ? SQTrue : SQFalse);
return 1;
}

static SQInteger isActorOnScreen(HSQUIRRELVM v)
{
auto entity = ScriptEngine::getEntity(v, 2);
Expand Down

0 comments on commit aaad9e1

Please sign in to comment.