Obligatory "I ruined everything!" thread
#17
I don´t get the point, why I should use the DoWithX functions.
Whats better with them?
I think:
Code:
cEntity *ent = m_Player->GetWorld()->GetEntityById(Id);
if(ent && ent->IsA("cPawn"))
{
    reinterpret_cast<cPawn*>(ent)->TakeDamage(1, m_Player);
}
is much faster to write, needs less knowledge of the system (You don´t need to know all the different Callback classes) and in addition looks much cleaner than those big classes.
The current implementation of the above code:
Code:
    class cDamageEntity : public cEntityCallback
    {
        virtual bool Item(cEntity * a_Entity) override
        {
            if( a_Entity->IsA("cPawn") )
            {
                reinterpret_cast< cPawn* >( a_Entity )->TakeDamage(Damage, Instigator );
            }
            return true;
        }
    public:
        int Damage;
        cEntity * Instigator;
    } Callback;

    Callback.Damage = 1; // TODO: Find proper damage from current item equipped
    Callback.Instigator = m_Player;

    cWorld * World = m_Player->GetWorld();
    World->DoWithEntityByID(a_Packet->m_TargetID, Callback);
Reply
Thanks given by:


Messages In This Thread
RE: Obligatory "I ruined everything!" thread - by Lapayo - 07-12-2012, 01:19 AM



Users browsing this thread: 13 Guest(s)