2015-11-11 07:57:34 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Entity/Pickup.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Entity/Player.hpp"
|
|
|
|
#include "Base/Vector3.hpp"
|
2015-11-01 00:32:16 +01:00
|
|
|
#include "Core.hpp"
|
2021-01-30 07:51:39 +01:00
|
|
|
#include "Core/Tasks.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_DECL_TYPENAME(Typename, _SC("SqPickup"))
|
2015-10-29 21:11:00 +01:00
|
|
|
|
2015-11-01 00:32:16 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t CPickup::Max = SQMOD_PICKUP_POOL;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-08-07 00:54:33 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPickup::SqGetNull(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-04-17 16:42:09 +02:00
|
|
|
sq_pushobject(vm, Core::Get().GetNullPickup().GetObj());
|
2016-08-07 00:54:33 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPickup::GetNull()
|
2016-08-07 00:54:33 +02:00
|
|
|
{
|
|
|
|
return Core::Get().GetNullPickup();
|
|
|
|
}
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
CPickup::CPickup(int32_t id)
|
2016-02-20 23:25:00 +01:00
|
|
|
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PICKUP_POOL))
|
2021-01-30 07:51:39 +01:00
|
|
|
, m_Tag(fmt::format("{}", id)), m_Data(), m_CircularLocks(0)
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const String & CPickup::ToString() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & CPickup::GetTag() const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:11:00 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CPickup::SetTag(StackStrF & tag)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-11-16 13:48:57 +01:00
|
|
|
if (tag.mLen > 0)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
|
2016-11-16 13:48:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Tag.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
CPickup & CPickup::ApplyTag(StackStrF & tag)
|
2016-11-16 13:48:57 +01:00
|
|
|
{
|
|
|
|
SetTag(tag);
|
|
|
|
return *this;
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPickup::GetData()
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return m_Data;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:11:00 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CPickup::SetData(LightObj & data)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Apply the specified value
|
|
|
|
m_Data = data;
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
bool CPickup::Destroy(int32_t header, LightObj & payload) const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().DelPickup(m_ID, header, payload);
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPickup::GetEvents() const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-02-21 20:24:59 +01:00
|
|
|
// Return the associated event table
|
|
|
|
return Core::Get().GetPickup(m_ID).mEvents;
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-07-26 23:13:50 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::CustomEvent(int32_t header, LightObj & payload) const
|
2016-07-26 23:13:50 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2021-01-30 07:51:39 +01:00
|
|
|
// Perform the requested action
|
2016-07-26 23:13:50 +02:00
|
|
|
Core::Get().EmitPickupCustom(m_ID, header, payload);
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:11:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
bool CPickup::IsStreamedFor(CPlayer & player) const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsPickupStreamedForPlayer(m_ID, player.GetID());
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2018-06-28 21:06:23 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
bool CPickup::GetOption(int32_t option_id) const
|
2018-06-28 21:06:23 +02:00
|
|
|
{
|
|
|
|
// Attempt to obtain the current value of the specified option
|
|
|
|
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
|
|
|
|
// Check for errors
|
|
|
|
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid option identifier: {}", option_id);
|
2018-06-28 21:06:23 +02:00
|
|
|
}
|
|
|
|
// Return the requested value
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetOption(int32_t option_id, bool toggle)
|
2018-06-28 21:06:23 +02:00
|
|
|
{
|
|
|
|
// Attempt to obtain the current value of the specified option
|
|
|
|
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
|
2021-09-12 15:03:23 +02:00
|
|
|
// Avoid infinite recursive event loops
|
|
|
|
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
|
2018-06-28 21:06:23 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPickupOption(m_ID, option_id, value, 0, NullLightObj());
|
|
|
|
}
|
2021-09-12 15:03:23 +02:00
|
|
|
// Attempt to modify the current value of the specified option
|
|
|
|
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
|
|
|
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid option identifier: {}", option_id);
|
|
|
|
}
|
2018-06-28 21:06:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetOptionEx(int32_t option_id, bool toggle, int32_t header, LightObj & payload)
|
2018-06-28 21:06:23 +02:00
|
|
|
{
|
|
|
|
// Attempt to obtain the current value of the specified option
|
|
|
|
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
|
2021-09-12 15:03:23 +02:00
|
|
|
// Avoid infinite recursive event loops
|
|
|
|
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
|
2018-06-28 21:06:23 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPickupOption(m_ID, option_id, value, header, payload);
|
|
|
|
}
|
2021-09-12 15:03:23 +02:00
|
|
|
// Attempt to modify the current value of the specified option
|
|
|
|
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
|
|
|
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid option identifier: {}", option_id);
|
|
|
|
}
|
2018-06-28 21:06:23 +02:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPickup::GetWorld() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPickupWorld(m_ID);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetWorld(int32_t world)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-19 16:58:08 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPickupWorld(m_ID);
|
2016-08-19 16:58:08 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == world)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:23 +02:00
|
|
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_WORLD))
|
2016-08-19 16:58:08 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_WORLD);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPickupWorld(m_ID, current, world);
|
|
|
|
}
|
2021-09-12 15:03:23 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPickupWorld(m_ID, world);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPickup::GetAlpha() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPickupAlpha(m_ID);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetAlpha(int32_t alpha)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-19 17:05:29 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPickupAlpha(m_ID);
|
2016-08-19 17:05:29 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == alpha)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:23 +02:00
|
|
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_ALPHA))
|
2016-08-19 17:05:29 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_ALPHA);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPickupAlpha(m_ID, current, alpha);
|
|
|
|
}
|
2021-09-12 15:03:23 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPickupAlpha(m_ID, alpha);
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool CPickup::GetAutomatic() const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->IsPickupAutomatic(m_ID);
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-19 17:21:41 +02:00
|
|
|
void CPickup::SetAutomatic(bool toggle)
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-19 17:21:41 +02:00
|
|
|
// Grab the current value for this property
|
|
|
|
const bool current = _Func->IsPickupAutomatic(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == toggle)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:23 +02:00
|
|
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOMATIC))
|
2016-08-19 17:21:41 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOMATIC);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPickupAutomatic(m_ID, current, toggle);
|
|
|
|
}
|
2021-09-12 15:03:23 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPickupIsAutomatic(m_ID, static_cast< uint8_t >(toggle));
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPickup::GetAutoTimer() const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPickupAutoTimer(m_ID);
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetAutoTimer(int32_t timer)
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-19 17:26:52 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPickupAutoTimer(m_ID);
|
2016-08-19 17:26:52 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == timer)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:23 +02:00
|
|
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOTIMER))
|
2016-08-19 17:26:52 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOTIMER);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPickupAutoTimer(m_ID, current, timer);
|
|
|
|
}
|
2021-09-12 15:03:23 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPickupAutoTimer(m_ID, static_cast< uint32_t >(timer));
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPickup::Refresh() const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->RefreshPickup(m_ID);
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
Vector3 CPickup::GetPosition() const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Create a default vector instance
|
|
|
|
Vector3 vec;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the position values
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->GetPickupPosition(m_ID, &vec.x, &vec.y, &vec.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return vec;
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPickup::SetPosition(const Vector3 & pos) const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPickupPosition(m_ID, pos.x, pos.y, pos.z);
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetPositionEx(float x, float y, float z) const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPickupPosition(m_ID, x, y, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPickup::GetModel() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPickupModel(m_ID);
|
2015-10-29 21:11:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPickup::GetQuantity() const
|
2015-10-29 21:11:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPickupQuantity(m_ID);
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPickup::GetPositionX() const
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous position information, if any
|
2021-01-30 07:51:39 +01:00
|
|
|
float x = 0.0f, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPickupPosition(m_ID, &x, &dummy, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return x;
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPickup::GetPositionY() const
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous position information, if any
|
2021-01-30 07:51:39 +01:00
|
|
|
float y = 0.0f, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPickupPosition(m_ID, &dummy, &y, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return y;
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPickup::GetPositionZ() const
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear previous position information, if any
|
2021-01-30 07:51:39 +01:00
|
|
|
float z = 0.0f, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPickupPosition(m_ID, &dummy, &dummy, &z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return z;
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetPositionX(float x) const
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2021-01-30 07:51:39 +01:00
|
|
|
float y, z, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPickupPosition(m_ID, &dummy, &y, &z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetPickupPosition(m_ID, x, y, z);
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetPositionY(float y) const
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2021-01-30 07:51:39 +01:00
|
|
|
float x, z, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPickupPosition(m_ID, &x, &dummy, &z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetPickupPosition(m_ID, x, y, z);
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPickup::SetPositionZ(float z) const
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2021-01-30 07:51:39 +01:00
|
|
|
float x, y, dummy;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPickupPosition(m_ID, &x, &y, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetPickupPosition(m_ID, z, y, z);
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
2022-07-23 21:09:30 +02:00
|
|
|
#ifdef VCMP_ENABLE_OFFICIAL
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
LightObj & CPickup::GetLegacyObject() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return Core::Get().GetPickup(m_ID).mLgObj;
|
|
|
|
}
|
|
|
|
#endif
|
2015-11-01 00:32:16 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
static LightObj & Pickup_CreateEx1a(int32_t model, int32_t world, int32_t quantity,
|
|
|
|
float x, float y, float z, int32_t alpha, bool automatic)
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewPickup(model, world, quantity, x, y, z, alpha, automatic,
|
2021-03-20 10:51:40 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj()).mObj;
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
2021-01-30 07:51:39 +01:00
|
|
|
static LightObj & Pickup_CreateEx1b(int32_t model, int32_t world, int32_t quantity,
|
|
|
|
float x, float y, float z, int32_t alpha, bool automatic,
|
|
|
|
int32_t header, LightObj & payload)
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2021-03-20 10:51:40 +01:00
|
|
|
return Core::Get().NewPickup(model, world, quantity, x, y, z, alpha, automatic, header, payload).mObj;
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
static LightObj & Pickup_Create1a(int32_t model, int32_t world, int32_t quantity, const Vector3 & pos,
|
|
|
|
int32_t alpha, bool automatic)
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
|
2021-03-20 10:51:40 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj()).mObj;
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
2021-01-30 07:51:39 +01:00
|
|
|
static LightObj & Pickup_Create1b(int32_t model, int32_t world, int32_t quantity, const Vector3 & pos,
|
|
|
|
int32_t alpha, bool automatic, int32_t header, LightObj & payload)
|
2015-11-01 00:32:16 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().NewPickup(model, world, quantity, pos.x, pos.y, pos.z, alpha, automatic,
|
2021-03-20 10:51:40 +01:00
|
|
|
header, payload).mObj;
|
2015-11-01 00:32:16 +01:00
|
|
|
}
|
|
|
|
|
2015-10-29 21:11:00 +01:00
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_CPickup(HSQUIRRELVM vm)
|
|
|
|
{
|
2016-11-15 20:16:24 +01:00
|
|
|
RootTable(vm).Bind(Typename::Str,
|
|
|
|
Class< CPickup, NoConstructor< CPickup > >(vm, Typename::Str)
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-11-15 20:16:24 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_tostring"), &CPickup::ToString)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Static Values
|
2016-03-10 04:57:13 +01:00
|
|
|
.SetStaticValue(_SC("MaxID"), CPickup::Max)
|
|
|
|
// Core Properties
|
2017-02-21 20:24:59 +01:00
|
|
|
.Prop(_SC("On"), &CPickup::GetEvents)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("ID"), &CPickup::GetID)
|
|
|
|
.Prop(_SC("Tag"), &CPickup::GetTag, &CPickup::SetTag)
|
|
|
|
.Prop(_SC("Data"), &CPickup::GetData, &CPickup::SetData)
|
|
|
|
.Prop(_SC("Active"), &CPickup::IsActive)
|
2022-07-23 21:09:30 +02:00
|
|
|
#ifdef VCMP_ENABLE_OFFICIAL
|
|
|
|
.Prop(_SC("Legacy"), &CPickup::GetLegacyObject)
|
|
|
|
#endif
|
2016-03-10 05:18:39 +01:00
|
|
|
// Core Methods
|
2016-11-16 13:48:57 +01:00
|
|
|
.FmtFunc(_SC("SetTag"), &CPickup::ApplyTag)
|
2016-07-26 23:13:50 +02:00
|
|
|
.Func(_SC("CustomEvent"), &CPickup::CustomEvent)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Core Overloads
|
2021-02-15 08:42:18 +01:00
|
|
|
.Overload(_SC("Destroy"), &CPickup::Destroy0)
|
|
|
|
.Overload(_SC("Destroy"), &CPickup::Destroy1)
|
2021-01-30 07:51:39 +01:00
|
|
|
.Overload(_SC("Destroy"), &CPickup::Destroy)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Properties
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Model"), &CPickup::GetModel)
|
|
|
|
.Prop(_SC("World"), &CPickup::GetWorld, &CPickup::SetWorld)
|
|
|
|
.Prop(_SC("Alpha"), &CPickup::GetAlpha, &CPickup::SetAlpha)
|
|
|
|
.Prop(_SC("Auto"), &CPickup::GetAutomatic, &CPickup::SetAutomatic)
|
|
|
|
.Prop(_SC("Automatic"), &CPickup::GetAutomatic, &CPickup::SetAutomatic)
|
|
|
|
.Prop(_SC("Timer"), &CPickup::GetAutoTimer, &CPickup::SetAutoTimer)
|
2021-01-30 07:51:39 +01:00
|
|
|
.Prop(_SC("AutoTimer"), &CPickup::GetAutoTimer, &CPickup::SetAutoTimer)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Pos"), &CPickup::GetPosition, &CPickup::SetPosition)
|
|
|
|
.Prop(_SC("Position"), &CPickup::GetPosition, &CPickup::SetPosition)
|
|
|
|
.Prop(_SC("Quantity"), &CPickup::GetQuantity)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("PosX"), &CPickup::GetPositionX, &CPickup::SetPositionX)
|
|
|
|
.Prop(_SC("PosY"), &CPickup::GetPositionY, &CPickup::SetPositionY)
|
|
|
|
.Prop(_SC("PosZ"), &CPickup::GetPositionZ, &CPickup::SetPositionZ)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Member Methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("StreamedFor"), &CPickup::IsStreamedFor)
|
2018-06-28 21:06:23 +02:00
|
|
|
.Func(_SC("GetOption"), &CPickup::GetOption)
|
|
|
|
.Func(_SC("SetOption"), &CPickup::SetOption)
|
|
|
|
.Func(_SC("SetOptionEx"), &CPickup::SetOptionEx)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Refresh"), &CPickup::Refresh)
|
|
|
|
.Func(_SC("SetPos"), &CPickup::SetPositionEx)
|
|
|
|
.Func(_SC("SetPosition"), &CPickup::SetPositionEx)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Static Overloads
|
2021-01-30 07:51:39 +01:00
|
|
|
.StaticOverload(_SC("CreateEx"), &Pickup_CreateEx1a)
|
|
|
|
.StaticOverload(_SC("CreateEx"), &Pickup_CreateEx1b)
|
|
|
|
.StaticOverload(_SC("Create"), &Pickup_Create1a)
|
|
|
|
.StaticOverload(_SC("Create"), &Pickup_Create1b)
|
2016-08-07 00:54:33 +02:00
|
|
|
// Raw Squirrel Methods
|
|
|
|
.SquirrelFunc(_SC("NullInst"), &CPickup::SqGetNull)
|
2016-11-16 23:23:59 +01:00
|
|
|
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CPickup, ENT_PICKUP >)
|
|
|
|
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CPickup, ENT_PICKUP >)
|
|
|
|
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CPickup, ENT_PICKUP >)
|
2016-11-17 16:04:21 +01:00
|
|
|
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CPickup, ENT_PICKUP >)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-04-14 02:08:06 +02:00
|
|
|
} // Namespace:: SqMod
|