I haven't had too much experience with AngelScript, so forgive me if I'm off about something.
But anyways, to explain my question/situation I basically have a class that fundementally is something like this (of course, this is just an example):
class Behaviors
{
public:
void Behavior1(int v)
{
val *= v;
}
int Behavior2()
{
return val;
}
private:
int val;
};
Now, the class is getting really messy (and there's behavior that it contains that I'd prefer scripted anyways) so I'm trying to get the class to work off of components instead.
So I'm effectively trying to achieve something like this:
struct IBehavior1
{
virtual void Behavior1(int v)=0;
};
struct IBehavior2
{
virtual int Behavior2()=0;
};
struct Behavior1Impl : IBehavior1
{
Behavior& behavior;
Behavior1Impl(Behavior& b) : behavior(b) { }
void Behavior1(int v) { behavior.val *= v; }
};
struct Behavior2Impl : IBehavior1
{
Behavior& behavior;
Behavior2Impl(Behavior& b) : behavior(b) { }
int Behavior2() { return behavior.val; }
};
class Behavior
{
friend struct Behavior1;
friend struct Behavior2;
public:
Behavior() { behavior1 = static_cast<Behavior1*>(new Behavior1Impl(*this)); behavior2 = static_cast<Behavior2*>(new Behavior2Imp(*this)); }
~Behavior() { delete behavior1; delete behavior2; }
void Behavior1(int v) { behavior1->Behavior1(v); }
int Behavior2() { return behavior2->Behavior2(); }
private:
int val;
IBehavior1 *behavior1;
IBehavior2 *behavior2;
};
What I want to do is replace, what is equivalent to this example's "Behavior1Impl" and "Behavior2Impl", with a scripted class, that implements the behavior of the components but is invisible to the container that it's scripted. Sorry if the example I gave is confusing.
I looked at the AngelScript documents and it has not made it clear to me what's required in order achieve something like this. Or even what I want to do is possible.
Any information regarding this would be appreciated.