-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lets us do cool stuff, not really that bad of a thing to have tbh ... if theres weird exploits with this ill figure it out sooner or later
- Loading branch information
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "Etterna/Globals/global.h" | ||
#include "ActorProxy.h" | ||
#include "Etterna/Actor/Base/ActorUtil.h" | ||
|
||
REGISTER_ACTOR_CLASS(ActorProxy); | ||
|
||
ActorProxy::ActorProxy() | ||
{ | ||
m_pActorTarget = nullptr; | ||
} | ||
|
||
bool | ||
ActorProxy::EarlyAbortDraw() const | ||
{ | ||
return m_pActorTarget == nullptr || Actor::EarlyAbortDraw(); | ||
} | ||
|
||
void | ||
ActorProxy::DrawPrimitives() | ||
{ | ||
if (m_pActorTarget != nullptr) { | ||
bool bVisible = m_pActorTarget->GetVisible(); | ||
m_pActorTarget->SetVisible(true); | ||
m_pActorTarget->Draw(); | ||
m_pActorTarget->SetVisible(bVisible); | ||
} | ||
} | ||
|
||
void | ||
ActorProxy::LoadFromNode(const XNode* pNode) | ||
{ | ||
Actor::LoadFromNode(pNode); | ||
} | ||
|
||
// lua start | ||
#include "Etterna/Models/Lua/LuaBinding.h" | ||
|
||
/** @brief Allow Lua to have access to the ActorProxy. */ | ||
class LunaActorProxy : public Luna<ActorProxy> | ||
{ | ||
public: | ||
static int SetTarget(T* p, lua_State* L) | ||
{ | ||
Actor* pTarget = Luna<Actor>::check(L, 1); | ||
p->SetTarget(pTarget); | ||
COMMON_RETURN_SELF; | ||
} | ||
|
||
static int GetTarget(T* p, lua_State* L) | ||
{ | ||
Actor* pTarget = p->GetTarget(); | ||
if (pTarget != nullptr) | ||
pTarget->PushSelf(L); | ||
else | ||
lua_pushnil(L); | ||
return 1; | ||
} | ||
|
||
LunaActorProxy() | ||
{ | ||
ADD_METHOD(SetTarget); | ||
ADD_METHOD(GetTarget); | ||
} | ||
}; | ||
|
||
LUA_REGISTER_DERIVED_CLASS(ActorProxy, Actor) | ||
// lua end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef ACTOR_PROXY_H | ||
#define ACTOR_PROXY_H | ||
|
||
#include "Actor.h" | ||
|
||
struct lua_State; | ||
/** @brief Renders another actor. */ | ||
class ActorProxy : public Actor | ||
{ | ||
public: | ||
ActorProxy(); | ||
|
||
virtual bool EarlyAbortDraw() const; | ||
virtual void DrawPrimitives(); | ||
|
||
void LoadFromNode(const XNode* pNode); | ||
virtual ActorProxy* Copy() const; | ||
|
||
Actor* GetTarget() { return m_pActorTarget; } | ||
void SetTarget(Actor* pTarget) { m_pActorTarget = pTarget; } | ||
|
||
// Lua | ||
virtual void PushSelf(lua_State* L); | ||
|
||
private: | ||
Actor* m_pActorTarget; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters