diff --git a/runtime/include/CSharpResource.h b/runtime/include/CSharpResource.h index b80cbf2abc..adc2f35956 100644 --- a/runtime/include/CSharpResource.h +++ b/runtime/include/CSharpResource.h @@ -97,7 +97,7 @@ typedef void (* OnCreateColShapeDelegate_t)(alt::IColShape* colShape); typedef void (* OnRemoveColShapeDelegate_t)(alt::IColShape* colShape); typedef void (* OnConsoleCommandDelegate_t)(const char* name, alt::Array* args); typedef void (* MetaChangeDelegate_t)(void* entity, alt::IBaseObject::Type type, alt::StringView key, alt::MValue* value); -typedef void (* ColShapeDelegate_t)(alt::IColShape* colShape, alt::IEntity* entity, alt::IBaseObject::Type baseObjectType, bool state); +typedef void (* ColShapeDelegate_t)(alt::IColShape* colShape, void* entity, alt::IBaseObject::Type baseObjectType, bool state); class CSharpResource : public alt::IResource { bool OnEvent(const alt::CEvent* ev) override; diff --git a/runtime/src/CSharpResource.cpp b/runtime/src/CSharpResource.cpp index 814304d659..443a7c6fb3 100644 --- a/runtime/src/CSharpResource.cpp +++ b/runtime/src/CSharpResource.cpp @@ -358,19 +358,12 @@ bool CSharpResource::OnEvent(const alt::CEvent* ev) { case alt::CEvent::Type::COLSHAPE_EVENT: { auto entity = ((alt::CColShapeEvent*) (ev))->GetEntity(); if (entity != nullptr) { - switch (entity->GetType()) { - case alt::IBaseObject::Type::PLAYER: - ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(), - dynamic_cast(entity), - entity->GetType(), - ((alt::CColShapeEvent*) (ev))->GetState()); - break; - case alt::IBaseObject::Type::VEHICLE: - ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(), - dynamic_cast(entity), - entity->GetType(), - ((alt::CColShapeEvent*) (ev))->GetState()); - break; + auto entityPointer = GetEntityPointer(entity); + if (entityPointer != nullptr) { + ColShapeDelegate(((alt::CColShapeEvent*) (ev))->GetTarget(), + entityPointer, + entity->GetType(), + ((alt::CColShapeEvent*) (ev))->GetState()); } } break;