1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Revise the entity creation/destruction system.

This commit is contained in:
Sandu Liviu Catalin 2015-10-31 21:28:23 +02:00
parent 1f985c5ebc
commit 0aafb46af2
7 changed files with 1068 additions and 383 deletions

View File

@ -734,279 +734,163 @@ void Core::CompilerErrorHandler(HSQUIRRELVM vm, const SQChar * desc, const SQCha
}
// ------------------------------------------------------------------------------------------------
Reference< CBlip > Core::CreateBlip(SQInt32 index, SQInt32 world, const Vector3 & pos, SQInt32 scale, \
const Color4 & color, SQInt32 sprite, SQInt32 header, SqObj & payload) noexcept
Reference< CBlip > Core::NewBlip(SQInt32 index, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale, SQUint32 color, SQInt32 sprid,
SQInt32 header, SqObj & payload) noexcept
{
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreateCoordBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprite);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CBlip >::Activate(id, true, world, scale, sprite, pos, color))
{
// Trigger the specific event
OnBlipCreated(id, header, payload);
}
else
{
LogErr("Unable to create a new <CBlip> instance");
}
// Return the obtained reference as is
return Reference< CBlip >(id);
// Attempt to create the entity and return a reference to it
return Reference< CBlip >(EntMan< CBlip >::Create(header, payload, true,
index, world, x, y, z, scale, color, sprid));
}
// ------------------------------------------------------------------------------------------------
Reference< CCheckpoint > Core::CreateCheckpoint(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \
const Color4 & color, SQFloat radius, SQInt32 header, SqObj & payload) noexcept
Reference< CCheckpoint > Core::NewCheckpoint(SQInt32 player, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQUint32 r, SQUint32 g, SQUint32 b, SQUint32 a, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
// See if the specified player reference is valid
if (!player)
if (!Reference< CPlayer >::Verify(player))
{
LogWrn("Attempting to create a <Checkpoint> instance on an invalid player: %d", _SCI32(player));
}
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreateCheckpoint(_SCI32(player), world, pos.x, pos.y, pos.z, color.r, color.g, color.b, color.a, radius);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CCheckpoint >::Activate(id, true))
{
// Trigger the specific event
OnCheckpointCreated(id, header, payload);
LogWrn("Attempting to <create a checkpoint instance> on an invalid player: %d", player);
}
// Attempt to create the entity and return a reference to it
else
{
LogErr("Unable to create a new <CCheckpoint> instance");
return Reference< CCheckpoint >(EntMan< CCheckpoint >::Create(header, payload, true,
player, world, x, y, z, r, g, b, a, radius));
}
// Return the obtained reference as is
return Reference< CCheckpoint >(id);
// Return an invalid reference
return Reference< CCheckpoint >();
}
// ------------------------------------------------------------------------------------------------
Reference< CKeybind > Core::CreateKeybind(SQInt32 slot, bool release, SQInt32 primary, SQInt32 secondary, \
SQInt32 alternative, SQInt32 header, SqObj & payload) noexcept
Reference< CKeybind > Core::NewKeybind(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload) noexcept
{
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->RegisterKeyBind(slot, release, primary, secondary, alternative);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CKeybind >::Activate(id, true, primary, secondary, alternative, release))
{
// Trigger the specific event
OnKeybindCreated(id, header, payload);
}
else
{
LogErr("Unable to create a new <CKeybind> instance");
}
// Return the obtained reference as is
return Reference< CKeybind >(id);
// Attempt to create the entity and return a reference to it
return Reference< CKeybind >(EntMan< CKeybind >::Create(header, payload, true,
slot, release, primary, secondary, alternative));
}
// ------------------------------------------------------------------------------------------------
Reference< CObject > Core::CreateObject(const CModel & model, SQInt32 world, const Vector3 & pos, SQInt32 alpha, \
SQInt32 header, SqObj & payload) noexcept
Reference< CObject > Core::NewObject(SQInt32 model, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha,
SQInt32 header, SqObj & payload) noexcept
{
// See if the specified model is valid
if (!model)
if (!CModel::Valid(model))
{
LogWrn("Attempting to create an <Object> instance with an invalid model: %d", _SCI32(model));
}
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreateObject(_SCI32(model), world, pos.x, pos.y, pos.z, alpha);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CObject >::Activate(id, true))
{
// Trigger the specific event
OnObjectCreated(id, header, payload);
LogWrn("Attempting to <create an object instance> using an invalid model: %d", model);
}
// Attempt to create the entity and return a reference to it
else
{
LogErr("Unable to create a new <CObject> instance");
return Reference< CObject >(EntMan< CObject >::Create(header, payload, true,
model, world, x, y, z, alpha));
}
// Return the obtained reference as is
return Reference< CObject >(id);
// Return an invalid reference
return Reference< CObject >();
}
// ------------------------------------------------------------------------------------------------
Reference< CPickup > Core::CreatePickup(const CModel & model, SQInt32 world, SQInt32 quantity, const Vector3 & pos, \
SQInt32 alpha, bool automatic, SQInt32 header, SqObj & payload) noexcept
Reference< CPickup > Core::NewPickup(SQInt32 model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z, SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload) noexcept
{
// See if the specified model is valid
if (!model)
if (!CModel::Valid(model))
{
LogWrn("Attempting to create a <Pickup> instance with an invalid model: %d", _SCI32(model));
}
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreatePickup(_SCI32(model), world, quantity, pos.x, pos.y, pos.z, alpha, automatic);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CPickup >::Activate(id, true))
{
// Trigger the specific event
OnPickupCreated(id, header, payload);
LogWrn("Attempting to <create a pickup instance> using an invalid model: %d", model);
}
// Attempt to create the entity and return a reference to it
else
{
LogErr("Unable to create a new <CPickup> instance");
return Reference< CPickup >(EntMan< CPickup >::Create(header, payload, true,
model, world, quantity, x, y, z, alpha, automatic));
}
// Return the obtained reference as is
return Reference< CPickup >(id);
// Return an invalid reference
return Reference< CPickup >();
}
// ------------------------------------------------------------------------------------------------
Reference< CSphere > Core::CreateSphere(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \
const Color3 & color, SQFloat radius, SQInt32 header, SqObj & payload) noexcept
Reference< CSphere > Core::NewSphere(SQInt32 player, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQUint32 r, SQUint32 g, SQUint32 b, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{
// See if the specified player reference is valid
if (!player)
if (!Reference< CPlayer >::Verify(player))
{
LogWrn("Attempting to create a <Sphere> instance on an invalid player: %d", _SCI32(player));
}
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreateSphere(_SCI32(player), world, pos.x, pos.y, pos.z, color.r, color.g, color.b, radius);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CSphere >::Activate(id, true))
{
// Trigger the specific event
OnSphereCreated(id, header, payload);
LogWrn("Attempting to <create a Sphere instance> on an invalid player: %d", player);
}
// Attempt to create the entity and return a reference to it
else
{
LogErr("Unable to create a new <CSphere> instance");
return Reference< CSphere >(EntMan< CSphere >::Create(header, payload, true,
player, world, x, y, z, r, g, b, radius));
}
// Return the obtained reference as is
return Reference< CSphere >(id);
// Return an invalid reference
return Reference< CSphere >();
}
// ------------------------------------------------------------------------------------------------
Reference< CSprite > Core::CreateSprite(SQInt32 index, const String & file, const Vector2i & pos, const Vector2i & rot, \
SQFloat angle, SQInt32 alpha, bool rel, SQInt32 header, SqObj & payload) noexcept
Reference< CSprite > Core::NewSprite(SQInt32 index, const SQChar * file, SQInt32 xp, SQInt32 yp,
SQInt32 xr, SQInt32 yr, SQFloat angle, SQInt32 alpha, bool rel,
SQInt32 header, SqObj & payload) noexcept
{
// See if the specified file path is valid
if (file.empty())
if (!file)
{
LogWrn("Attempting to create a <Sprite> instance with an empty path: %d", file.size());
}
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreateSprite(index, file.c_str(), pos.x, pos.y, rot.x, rot.y, angle, alpha, rel);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CSprite >::Activate(id, true, file))
{
// Trigger the specific event
OnSpriteCreated(id, header, payload);
LogWrn("Attempting to <create a sprite instance> with an empty path: null");
}
// Attempt to create the entity and return a reference to it
else
{
LogErr("Unable to create a new <CSprite> instance");
return Reference< CSprite >(EntMan< CSprite >::Create(header, payload, true,
index, file, xp, yp, xr, yr, angle, alpha, rel));
}
// Return the obtained reference as is
return Reference< CSprite >(id);
// Return an invalid reference
return Reference< CSprite >();
}
// ------------------------------------------------------------------------------------------------
Reference< CTextdraw > Core::CreateTextdraw(SQInt32 index, const String & text, const Vector2i & pos, \
const Color4 & color, bool rel, SQInt32 header, SqObj & payload) noexcept
Reference< CTextdraw > Core::NewTextdraw(SQInt32 index, const SQChar * text, SQInt32 xp, SQInt32 yp,
SQUint32 color, bool rel,
SQInt32 header, SqObj & payload) noexcept
{
// See if the specified text is valid
if (text.empty())
if (!text)
{
LogWrn("Attempting to create a <Textdraw> instance with an empty text: %d", text.size());
}
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreateTextdraw(index, text.c_str(), pos.x, pos.y, color.GetRGBA(), rel);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CTextdraw >::Activate(id, true, text))
{
// Trigger the specific event
OnTextdrawCreated(id, header, payload);
LogWrn("Attempting to <create a textdraw instance> using an empty text: null");
}
// Attempt to create the entity and return a reference to it
else
{
LogErr("Unable to create a new <CTextdraw> instance");
return Reference< CTextdraw >(EntMan< CTextdraw >::Create(header, payload, true,
index, text, xp, yp, color, rel));
}
// Return the obtained reference as is
return Reference< CTextdraw >(id);
// Return an invalid reference
return Reference< CTextdraw >();
}
// ------------------------------------------------------------------------------------------------
Reference< CVehicle > Core::CreateVehicle(const CAutomobile & model, SQInt32 world, const Vector3 & pos, \
SQFloat angle, SQInt32 primary, SQInt32 secondary, SQInt32 header, SqObj & payload) noexcept
Reference< CVehicle > Core::NewVehicle(SQInt32 model, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQFloat angle, SQInt32 primary, SQInt32 secondary,
SQInt32 header, SqObj & payload) noexcept
{
// See if the specified model is valid
if (!model)
if (!CAutomobile::Valid(model))
{
LogWrn("Attempting to create an <Vehicle> instance with an invalid model: %d", _SCI32(model));
}
// Attempt to create an instance on the server and obtain it's identifier
SQInt32 id = _Func->CreateVehicle(_SCI32(model), world, pos.x, pos.y, pos.z, angle, primary, secondary);
// Attempt to activate the instance in the plugin at the received identifier
if (EntMan< CVehicle >::Activate(id, true))
{
// Trigger the specific event
OnVehicleCreated(id, header, payload);
LogWrn("Attempting to <create a vehicle instance> using an invalid model: %d", model);
}
// Attempt to create the entity and return a reference to it
else
{
LogErr("Unable to create a new <CVehicle> instance");
return Reference< CVehicle >(EntMan< CVehicle >::Create(header, payload, true,
model, world, x, y, z, angle, primary, secondary));
}
// Return the obtained reference as is
return Reference< CVehicle >(id);
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyBlip(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyCheckpoint(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyKeybind(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyObject(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyPickup(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyPlayer(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroySphere(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroySprite(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyTextdraw(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
}
// ------------------------------------------------------------------------------------------------
bool Core::DestroyVehicle(SQInt32 id, SQInt32 header, SqObj & payload) noexcept
{
return true;
// Return an invalid reference
return Reference< CVehicle >();
}
// ------------------------------------------------------------------------------------------------
@ -1771,7 +1655,7 @@ void Core::OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept
case SQMOD_ENTITY_POOL_VEHICLE:
if (deleted)
{
DestroyVehicle(id, SQMOD_DESTROY_POOL, payload);
EntMan< CVehicle >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
}
else if (EntMan< CVehicle >::Activate(id, false))
{
@ -1781,7 +1665,7 @@ void Core::OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept
case SQMOD_ENTITY_POOL_OBJECT:
if (deleted)
{
DestroyObject(id, SQMOD_DESTROY_POOL, payload);
EntMan< CObject >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
}
else if (EntMan< CObject >::Activate(id, false))
{
@ -1791,7 +1675,7 @@ void Core::OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept
case SQMOD_ENTITY_POOL_PICKUP:
if (deleted)
{
DestroyPickup(id, SQMOD_DESTROY_POOL, payload);
EntMan< CPickup >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
}
else if (EntMan< CPickup >::Activate(id, false))
{
@ -1804,9 +1688,9 @@ void Core::OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept
case SQMOD_ENTITY_POOL_SPRITE:
if (deleted)
{
DestroySprite(id, SQMOD_DESTROY_POOL, payload);
EntMan< CSprite >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
}
else if (EntMan< CSprite >::Activate(id, false, ""))
else if (EntMan< CSprite >::Activate(id, false))
{
OnSpriteCreated(id, SQMOD_CREATE_POOL, payload);
}
@ -1814,9 +1698,9 @@ void Core::OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept
case SQMOD_ENTITY_POOL_TEXTDRAW:
if (deleted)
{
DestroyTextdraw(id, SQMOD_DESTROY_POOL, payload);
EntMan< CTextdraw >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
}
else if (EntMan< CTextdraw >::Activate(id, false, ""))
else if (EntMan< CTextdraw >::Activate(id, false))
{
OnTextdrawCreated(id, SQMOD_CREATE_POOL, payload);
}
@ -1824,20 +1708,17 @@ void Core::OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept
case SQMOD_ENTITY_POOL_BLIP:
if (deleted)
{
DestroyBlip(id, SQMOD_DESTROY_POOL, payload);
EntMan< CBlip >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
}
else
{
SQInt32 world, scale, sprite;
SQUint32 pcolor;
Vector3 pos;
Color4 color;
SQInt32 world, scale, sprid;
SQUint32 color;
SQFloat x, y, z;
// Get the blip information from the server
_Func->GetCoordBlipInfo(id, &world, &pos.x, &pos.y, &pos.z, &scale, &pcolor, &sprite);
// Unpack the retrieved color
color.SetRGBA(pcolor);
if (EntMan< CBlip >::Activate(id, false, world, scale, sprite, pos, color))
_Func->GetCoordBlipInfo(id, &world, &x, &y, &z, &scale, &color, &sprid);
// Attempt to activate this instance
if (EntMan< CBlip >::Activate(id, false, SQMOD_UNKNOWN, world, x, y, z, scale, color, sprid))
{
OnBlipCreated(id, SQMOD_CREATE_POOL, payload);
}

View File

@ -181,103 +181,65 @@ public:
/* --------------------------------------------------------------------------------------------
* Creates a new Blip on the server
*/
Reference< CBlip > CreateBlip(SQInt32 index, SQInt32 world, const Vector3 & pos, SQInt32 scale, \
const Color4 & color, SQInt32 sprite, SQInt32 header, SqObj & payload) noexcept;
Reference< CBlip > NewBlip(SQInt32 index, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQInt32 scale, SQUint32 color, SQInt32 sprid,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Checkpoint on the server
*/
Reference< CCheckpoint > CreateCheckpoint(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \
const Color4 & color, SQFloat radius, SQInt32 header, SqObj & payload) noexcept;
Reference< CCheckpoint > NewCheckpoint(SQInt32 player, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQUint32 r, SQUint32 g, SQUint32 b, SQUint32 a, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Keybind on the server
*/
Reference< CKeybind > CreateKeybind(SQInt32 slot, bool release, SQInt32 primary, SQInt32 secondary, \
SQInt32 alternative, SQInt32 header, SqObj & payload) noexcept;
Reference< CKeybind > NewKeybind(SQInt32 slot, bool release,
SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Object on the server
*/
Reference< CObject > CreateObject(const CModel & model, SQInt32 world, const Vector3 & pos, SQInt32 alpha, \
SQInt32 header, SqObj & payload) noexcept;
Reference< CObject > NewObject(SQInt32 model, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQInt32 alpha,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Pickup on the server
*/
Reference< CPickup > CreatePickup(const CModel & model, SQInt32 world, SQInt32 quantity, const Vector3 & pos, \
SQInt32 alpha, bool automatic, SQInt32 header, SqObj & payload) noexcept;
Reference< CPickup > NewPickup(SQInt32 model, SQInt32 world, SQInt32 quantity,
SQFloat x, SQFloat y, SQFloat z, SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Sphere on the server
*/
Reference< CSphere > CreateSphere(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \
const Color3 & color, SQFloat radius, SQInt32 header, SqObj & payload) noexcept;
Reference< CSphere > NewSphere(SQInt32 player, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQUint32 r, SQUint32 g, SQUint32 b, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Sprite on the server
*/
Reference< CSprite > CreateSprite(SQInt32 index, const String & file, const Vector2i & pos, const Vector2i & rot, \
SQFloat angle, SQInt32 alpha, bool rel, SQInt32 header, SqObj & payload) noexcept;
Reference< CSprite > NewSprite(SQInt32 index, const SQChar * file, SQInt32 xp, SQInt32 yp,
SQInt32 xr, SQInt32 yr, SQFloat angle, SQInt32 alpha, bool rel,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Textdraw on the server
*/
Reference< CTextdraw > CreateTextdraw(SQInt32 index, const String & text, const Vector2i & pos, \
const Color4 & color, bool rel, SQInt32 header, SqObj & payload) noexcept;
Reference< CTextdraw > NewTextdraw(SQInt32 index, const SQChar * text, SQInt32 xp, SQInt32 yp,
SQUint32 color, bool rel,
SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Creates a new Vehicle on the server
*/
Reference< CVehicle > CreateVehicle(const CAutomobile & model, SQInt32 world, const Vector3 & pos, SQFloat angle, \
SQInt32 primary, SQInt32 secondary, SQInt32 header, SqObj & payload) noexcept;
public:
/* --------------------------------------------------------------------------------------------
* Destroys a Blip created by the server
*/
bool DestroyBlip(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Checkpoint created by the server
*/
bool DestroyCheckpoint(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Keybind created by the server
*/
bool DestroyKeybind(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Object created by the server
*/
bool DestroyObject(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Pickup created by the server
*/
bool DestroyPickup(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Sphere created by the server
*/
bool DestroySphere(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Sprite created by the server
*/
bool DestroySprite(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Textdraw created by the server
*/
bool DestroyTextdraw(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
/* --------------------------------------------------------------------------------------------
* Destroys a Vehicle created by the server
*/
bool DestroyVehicle(SQInt32 id, SQInt32 header, SqObj & payload) noexcept;
Reference< CVehicle > NewVehicle(SQInt32 model, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQFloat angle, SQInt32 primary, SQInt32 secondary,
SQInt32 header, SqObj & payload) noexcept;
public:

View File

@ -5,6 +5,159 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
EBlipCreated & GBlipCreated() noexcept
{
return _Core->BlipCreated;
}
ECheckpointCreated & GCheckpointCreated() noexcept
{
return _Core->CheckpointCreated;
}
EKeybindCreated & GKeybindCreated() noexcept
{
return _Core->KeybindCreated;
}
EObjectCreated & GObjectCreated() noexcept
{
return _Core->ObjectCreated;
}
EPickupCreated & GPickupCreated() noexcept
{
return _Core->PickupCreated;
}
EPlayerCreated & GPlayerCreated() noexcept
{
return _Core->PlayerCreated;
}
ESphereCreated & GSphereCreated() noexcept
{
return _Core->SphereCreated;
}
ESpriteCreated & GSpriteCreated() noexcept
{
return _Core->SpriteCreated;
}
ETextdrawCreated & GTextdrawCreated() noexcept
{
return _Core->TextdrawCreated;
}
EVehicleCreated & GVehicleCreated() noexcept
{
return _Core->VehicleCreated;
}
// ------------------------------------------------------------------------------------------------
EBlipDestroyed & GBlipDestroyed() noexcept
{
return _Core->BlipDestroyed;
}
ECheckpointDestroyed & GCheckpointDestroyed() noexcept
{
return _Core->CheckpointDestroyed;
}
EKeybindDestroyed & GKeybindDestroyed() noexcept
{
return _Core->KeybindDestroyed;
}
EObjectDestroyed & GObjectDestroyed() noexcept
{
return _Core->ObjectDestroyed;
}
EPickupDestroyed & GPickupDestroyed() noexcept
{
return _Core->PickupDestroyed;
}
EPlayerDestroyed & GPlayerDestroyed() noexcept
{
return _Core->PlayerDestroyed;
}
ESphereDestroyed & GSphereDestroyed() noexcept
{
return _Core->SphereDestroyed;
}
ESpriteDestroyed & GSpriteDestroyed() noexcept
{
return _Core->SpriteDestroyed;
}
ETextdrawDestroyed & GTextdrawDestroyed() noexcept
{
return _Core->TextdrawDestroyed;
}
EVehicleDestroyed & GVehicleDestroyed() noexcept
{
return _Core->VehicleDestroyed;
}
// ------------------------------------------------------------------------------------------------
EBlipCustom & GBlipCustom() noexcept
{
return _Core->BlipCustom;
}
ECheckpointCustom & GCheckpointCustom() noexcept
{
return _Core->CheckpointCustom;
}
EKeybindCustom & GKeybindCustom() noexcept
{
return _Core->KeybindCustom;
}
EObjectCustom & GObjectCustom() noexcept
{
return _Core->ObjectCustom;
}
EPickupCustom & GPickupCustom() noexcept
{
return _Core->PickupCustom;
}
EPlayerCustom & GPlayerCustom() noexcept
{
return _Core->PlayerCustom;
}
ESphereCustom & GSphereCustom() noexcept
{
return _Core->SphereCustom;
}
ESpriteCustom & GSpriteCustom() noexcept
{
return _Core->SpriteCustom;
}
ETextdrawCustom & GTextdrawCustom() noexcept
{
return _Core->TextdrawCustom;
}
EVehicleCustom & GVehicleCustom() noexcept
{
return _Core->VehicleCustom;
}
// ------------------------------------------------------------------------------------------------
bool Register_Entity(HSQUIRRELVM vm)
{

File diff suppressed because it is too large Load Diff

View File

@ -223,27 +223,27 @@ void CAutomobile::SetName(const SQChar * name) noexcept
Reference< CVehicle > CAutomobile::Create(SQInt32 world, const Vector3 & pos, SQFloat angle,
SQInt32 header, SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, pos, angle, SQMOD_UNKNOWN, SQMOD_UNKNOWN, header, payload);
return _Core->NewVehicle(m_ID, world, pos.x, pos.z, pos.y, angle, SQMOD_UNKNOWN, SQMOD_UNKNOWN, header, payload);
}
Reference< CVehicle > CAutomobile::Create(SQInt32 world, const Vector3 & pos, SQFloat angle,
SQInt32 primary, SQInt32 secondary, SQInt32 header,
SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, pos, angle, primary, secondary, header, payload);
return _Core->NewVehicle(*this, world, pos.x, pos.z, pos.y, angle, primary, secondary, header, payload);
}
Reference< CVehicle > CAutomobile::Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle,
SQInt32 header, SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, Vector3(x, y, z), angle, SQMOD_UNKNOWN, SQMOD_UNKNOWN, header, payload);
return _Core->NewVehicle(*this, world, x, y, z, angle, SQMOD_UNKNOWN, SQMOD_UNKNOWN, header, payload);
}
Reference< CVehicle > CAutomobile::Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle,
SQInt32 primary, SQInt32 secondary, SQInt32 header,
SqObj & payload) const noexcept
{
return _Core->CreateVehicle(*this, world, Vector3(x, y, z), angle, primary, secondary, header, payload);
return _Core->NewVehicle(*this, world, x, y, z, angle, primary, secondary, header, payload);
}
// ================================================================================================

View File

@ -232,26 +232,26 @@ bool CModel::IsActuallyWeapon() const noexcept
Reference< CObject > CModel::Object(SQInt32 world, const Vector3 & pos, SQInt32 alpha, SQInt32 header, \
SqObj & payload) const noexcept
{
return _Core->CreateObject(*this, world, pos, alpha, header, payload);
return _Core->NewObject(m_ID, world, pos.x, pos.y, pos.z, alpha, header, payload);
}
Reference< CObject > CModel::Object(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQInt32 alpha, \
SQInt32 header, SqObj & payload) const noexcept
{
return _Core->CreateObject(*this, world, Vector3(x, y, z), alpha, header, payload);
return _Core->NewObject(m_ID, world, x, y, z, alpha, header, payload);
}
// ------------------------------------------------------------------------------------------------
Reference< CPickup > CModel::Pickup(SQInt32 world, SQInt32 quantity, const Vector3 & pos, SQInt32 alpha, \
bool automatic, SQInt32 header, SqObj & payload) const noexcept
{
return _Core->CreatePickup(*this, world, quantity, pos, alpha, automatic, header, payload);
return _Core->NewPickup(m_ID, world, quantity, pos.x, pos.y, pos.z, alpha, automatic, header, payload);
}
Reference< CPickup > CModel::Pickup(SQInt32 world, SQInt32 quantity, SQFloat x, SQFloat y, SQFloat z, \
SQInt32 alpha, bool automatic, SQInt32 header, SqObj & payload) const noexcept
{
return _Core->CreatePickup(*this, world, quantity, Vector3(x, y, z), alpha, automatic, header, payload);
return _Core->NewPickup(m_ID, world, quantity, x, y, z, alpha, automatic, header, payload);
}
// ================================================================================================

View File

@ -166,6 +166,16 @@ protected:
LogErr("Attempting to set global data for invalid automobile id: %d", id);
}
}
public:
/* --------------------------------------------------------------------------------------------
* See if the specified identifier is valid and in bounds.
*/
static bool Valid(SQInt32 id) noexcept
{
return VALID_ENTITYGETEX(id, Max);
}
};
// ------------------------------------------------------------------------------------------------