1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-31 09:57:14 +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, \ Reference< CBlip > Core::NewBlip(SQInt32 index, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
const Color4 & color, SQInt32 sprite, SQInt32 header, SqObj & payload) noexcept SQInt32 scale, SQUint32 color, SQInt32 sprid,
SQInt32 header, SqObj & payload) noexcept
{ {
// Attempt to create an instance on the server and obtain it's identifier // Attempt to create the entity and return a reference to it
SQInt32 id = _Func->CreateCoordBlip(index, world, pos.x, pos.y, pos.z, scale, color.GetRGBA(), sprite); return Reference< CBlip >(EntMan< CBlip >::Create(header, payload, true,
// Attempt to activate the instance in the plugin at the received identifier index, world, x, y, z, scale, color, sprid));
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);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CCheckpoint > Core::CreateCheckpoint(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \ Reference< CCheckpoint > Core::NewCheckpoint(SQInt32 player, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
const Color4 & color, SQFloat radius, SQInt32 header, SqObj & payload) noexcept SQUint32 r, SQUint32 g, SQUint32 b, SQUint32 a, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{ {
// See if the specified player reference is valid // 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)); LogWrn("Attempting to <create a checkpoint instance> on an invalid player: %d", 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);
} }
// Attempt to create the entity and return a reference to it
else 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 an invalid reference
return Reference< CCheckpoint >(id); return Reference< CCheckpoint >();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CKeybind > Core::CreateKeybind(SQInt32 slot, bool release, SQInt32 primary, SQInt32 secondary, \ Reference< CKeybind > Core::NewKeybind(SQInt32 slot, bool release,
SQInt32 alternative, SQInt32 header, SqObj & payload) noexcept SQInt32 primary, SQInt32 secondary, SQInt32 alternative,
SQInt32 header, SqObj & payload) noexcept
{ {
// Attempt to create an instance on the server and obtain it's identifier // Attempt to create the entity and return a reference to it
SQInt32 id = _Func->RegisterKeyBind(slot, release, primary, secondary, alternative); return Reference< CKeybind >(EntMan< CKeybind >::Create(header, payload, true,
// Attempt to activate the instance in the plugin at the received identifier slot, release, primary, secondary, alternative));
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);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CObject > Core::CreateObject(const CModel & model, SQInt32 world, const Vector3 & pos, SQInt32 alpha, \ Reference< CObject > Core::NewObject(SQInt32 model, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
SQInt32 header, SqObj & payload) noexcept SQInt32 alpha,
SQInt32 header, SqObj & payload) noexcept
{ {
// See if the specified model is valid // 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)); LogWrn("Attempting to <create an object instance> using an invalid model: %d", 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);
} }
// Attempt to create the entity and return a reference to it
else 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 an invalid reference
return Reference< CObject >(id); return Reference< CObject >();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CPickup > Core::CreatePickup(const CModel & model, SQInt32 world, SQInt32 quantity, const Vector3 & pos, \ Reference< CPickup > Core::NewPickup(SQInt32 model, SQInt32 world, SQInt32 quantity,
SQInt32 alpha, bool automatic, SQInt32 header, SqObj & payload) noexcept SQFloat x, SQFloat y, SQFloat z, SQInt32 alpha, bool automatic,
SQInt32 header, SqObj & payload) noexcept
{ {
// See if the specified model is valid // 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)); LogWrn("Attempting to <create a pickup instance> using an invalid model: %d", 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);
} }
// Attempt to create the entity and return a reference to it
else 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 an invalid reference
return Reference< CPickup >(id); return Reference< CPickup >();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CSphere > Core::CreateSphere(const Reference< CPlayer > & player, SQInt32 world, const Vector3 & pos, \ Reference< CSphere > Core::NewSphere(SQInt32 player, SQInt32 world, SQFloat x, SQFloat y, SQFloat z,
const Color3 & color, SQFloat radius, SQInt32 header, SqObj & payload) noexcept SQUint32 r, SQUint32 g, SQUint32 b, SQFloat radius,
SQInt32 header, SqObj & payload) noexcept
{ {
// See if the specified player reference is valid // 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)); LogWrn("Attempting to <create a Sphere instance> on an invalid player: %d", 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);
} }
// Attempt to create the entity and return a reference to it
else 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 an invalid reference
return Reference< CSphere >(id); return Reference< CSphere >();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CSprite > Core::CreateSprite(SQInt32 index, const String & file, const Vector2i & pos, const Vector2i & rot, \ Reference< CSprite > Core::NewSprite(SQInt32 index, const SQChar * file, SQInt32 xp, SQInt32 yp,
SQFloat angle, SQInt32 alpha, bool rel, SQInt32 header, SqObj & payload) noexcept SQInt32 xr, SQInt32 yr, SQFloat angle, SQInt32 alpha, bool rel,
SQInt32 header, SqObj & payload) noexcept
{ {
// See if the specified file path is valid // 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()); LogWrn("Attempting to <create a sprite instance> with an empty path: null");
}
// 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);
} }
// Attempt to create the entity and return a reference to it
else 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 an invalid reference
return Reference< CSprite >(id); return Reference< CSprite >();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CTextdraw > Core::CreateTextdraw(SQInt32 index, const String & text, const Vector2i & pos, \ Reference< CTextdraw > Core::NewTextdraw(SQInt32 index, const SQChar * text, SQInt32 xp, SQInt32 yp,
const Color4 & color, bool rel, SQInt32 header, SqObj & payload) noexcept SQUint32 color, bool rel,
SQInt32 header, SqObj & payload) noexcept
{ {
// See if the specified text is valid // 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()); LogWrn("Attempting to <create a textdraw instance> using an empty text: null");
}
// 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);
} }
// Attempt to create the entity and return a reference to it
else 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 an invalid reference
return Reference< CTextdraw >(id); return Reference< CTextdraw >();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Reference< CVehicle > Core::CreateVehicle(const CAutomobile & model, SQInt32 world, const Vector3 & pos, \ 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 SQFloat angle, SQInt32 primary, SQInt32 secondary,
SQInt32 header, SqObj & payload) noexcept
{ {
// See if the specified model is valid // 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)); LogWrn("Attempting to <create a vehicle instance> using an invalid model: %d", 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);
} }
// Attempt to create the entity and return a reference to it
else 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 an invalid reference
return Reference< CVehicle >(id); return Reference< CVehicle >();
}
// ------------------------------------------------------------------------------------------------
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;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -1771,7 +1655,7 @@ void Core::OnEntityPool(SQInt32 type, SQInt32 id, bool deleted) noexcept
case SQMOD_ENTITY_POOL_VEHICLE: case SQMOD_ENTITY_POOL_VEHICLE:
if (deleted) if (deleted)
{ {
DestroyVehicle(id, SQMOD_DESTROY_POOL, payload); EntMan< CVehicle >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
} }
else if (EntMan< CVehicle >::Activate(id, false)) 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: case SQMOD_ENTITY_POOL_OBJECT:
if (deleted) if (deleted)
{ {
DestroyObject(id, SQMOD_DESTROY_POOL, payload); EntMan< CObject >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
} }
else if (EntMan< CObject >::Activate(id, false)) 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: case SQMOD_ENTITY_POOL_PICKUP:
if (deleted) if (deleted)
{ {
DestroyPickup(id, SQMOD_DESTROY_POOL, payload); EntMan< CPickup >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
} }
else if (EntMan< CPickup >::Activate(id, false)) 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: case SQMOD_ENTITY_POOL_SPRITE:
if (deleted) 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); 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: case SQMOD_ENTITY_POOL_TEXTDRAW:
if (deleted) 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); 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: case SQMOD_ENTITY_POOL_BLIP:
if (deleted) if (deleted)
{ {
DestroyBlip(id, SQMOD_DESTROY_POOL, payload); EntMan< CBlip >::Deactivate(id, SQMOD_DESTROY_POOL, payload, true);
} }
else else
{ {
SQInt32 world, scale, sprite; SQInt32 world, scale, sprid;
SQUint32 pcolor; SQUint32 color;
Vector3 pos; SQFloat x, y, z;
Color4 color;
// Get the blip information from the server // Get the blip information from the server
_Func->GetCoordBlipInfo(id, &world, &pos.x, &pos.y, &pos.z, &scale, &pcolor, &sprite); _Func->GetCoordBlipInfo(id, &world, &x, &y, &z, &scale, &color, &sprid);
// Unpack the retrieved color // Attempt to activate this instance
color.SetRGBA(pcolor); if (EntMan< CBlip >::Activate(id, false, SQMOD_UNKNOWN, world, x, y, z, scale, color, sprid))
if (EntMan< CBlip >::Activate(id, false, world, scale, sprite, pos, color))
{ {
OnBlipCreated(id, SQMOD_CREATE_POOL, payload); OnBlipCreated(id, SQMOD_CREATE_POOL, payload);
} }

View File

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

View File

@ -5,6 +5,159 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { 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) 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, Reference< CVehicle > CAutomobile::Create(SQInt32 world, const Vector3 & pos, SQFloat angle,
SQInt32 header, SqObj & payload) const noexcept 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, Reference< CVehicle > CAutomobile::Create(SQInt32 world, const Vector3 & pos, SQFloat angle,
SQInt32 primary, SQInt32 secondary, SQInt32 header, SQInt32 primary, SQInt32 secondary, SQInt32 header,
SqObj & payload) const noexcept 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, Reference< CVehicle > CAutomobile::Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle,
SQInt32 header, SqObj & payload) const noexcept 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, Reference< CVehicle > CAutomobile::Create(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQFloat angle,
SQInt32 primary, SQInt32 secondary, SQInt32 header, SQInt32 primary, SQInt32 secondary, SQInt32 header,
SqObj & payload) const noexcept 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, \ Reference< CObject > CModel::Object(SQInt32 world, const Vector3 & pos, SQInt32 alpha, SQInt32 header, \
SqObj & payload) const noexcept 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, \ Reference< CObject > CModel::Object(SQInt32 world, SQFloat x, SQFloat y, SQFloat z, SQInt32 alpha, \
SQInt32 header, SqObj & payload) const noexcept 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, \ Reference< CPickup > CModel::Pickup(SQInt32 world, SQInt32 quantity, const Vector3 & pos, SQInt32 alpha, \
bool automatic, SQInt32 header, SqObj & payload) const noexcept 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, \ Reference< CPickup > CModel::Pickup(SQInt32 world, SQInt32 quantity, SQFloat x, SQFloat y, SQFloat z, \
SQInt32 alpha, bool automatic, SQInt32 header, SqObj & payload) const noexcept 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); 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);
}
}; };
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------