END_VAR_TABLE

void RPG_AttackableComponent::SetOwner( VisTypedEngineObject_cl *owner )
{
  VisTypedEngineObject_cl* prevOwner = GetOwner();

  RPG_HighlightableComponent::SetOwner(owner);

  if(owner)
  {
    if(owner->IsFrom(RPG_DamageableEntity))
    {
      RPG_DamageableEntity* ownerEntity = static_cast<RPG_DamageableEntity*>(owner);
      RPG_GameManager::s_instance.AddAttackableEntity(ownerEntity);
    }
  }
  else if(prevOwner)
  {
    if(prevOwner->IsFrom(RPG_DamageableEntity))
    {
      RPG_DamageableEntity* ownerEntity = static_cast<RPG_DamageableEntity*>(prevOwner);
      RPG_GameManager::s_instance.RemoveAttackableEntity(ownerEntity);
    }
  }
  else
  {
    hkvLog::Warning("AttackableComponent::SetOwner(): owner is null and previous owner was also null.");
  }
}
VCustomVolumeObject *vHavokTriggerVolume::GetOwnerCustomVolume()
{
  VisTypedEngineObject_cl *pOwner = GetOwner();
  if (!pOwner || !pOwner->IsOfType(V_RUNTIME_CLASS(VCustomVolumeObject)))
    return NULL;

  return static_cast<VCustomVolumeObject*>(pOwner); 
}
VisObject3D_cl *vHavokTriggerVolume::GetOwner3D()
{
  VisTypedEngineObject_cl *pOwner = GetOwner();
  if (pOwner == NULL)
    return NULL;

  VASSERT(pOwner->IsOfType(V_RUNTIME_CLASS(VisObject3D_cl)));
  return (VisObject3D_cl*)pOwner; 
}
Exemplo n.º 4
0
void VScriptComponent::Serialize( VArchive &ar )
{
  char iLocalVersion = VERSION_CURRENT;
  IVObjectComponent::Serialize(ar);

  if (ar.IsLoading())
  {
    ar >> iLocalVersion;
    if (iLocalVersion<VERSION_INITIAL||iLocalVersion>VERSION_CURRENT)
      hkvLog::FatalError("Invalid script serialization version - please re-export scene.");

    // This is a workaround for [#21287] : This component must be immediately added to the owner's component list,
    // otherwise script function calls on it create a new script component which results in one object having two script components
    // [8.1: need to serialize it here]
    VisTypedEngineObject_cl *pOwner = ar.ReadObject<VisTypedEngineObject_cl>();
    if (pOwner != NULL && !pOwner->Components().Contains(this))
      ((VObjectComponentCollection &)pOwner->Components()).Add(this);
    // additionally we have to temporarily pretend the owner is set:
    m_pOwner = pOwner;

    m_iScriptRefID = LUA_REFNIL;
    VScriptInstance *pInstance = NULL;
    ar >> pInstance;
    // we shouldn't call SetScriptInstance since it calls the Lua OnCreate function, which may try to access the object
    //SetScriptInstance(pInstance);
    m_spInstance = pInstance;

    if(iLocalVersion >= VERSION_CUSTOM_EXPOSED_MEMBERS)
    {
      int iNumOfSerializedMembers;
      ar >> iNumOfSerializedMembers;

      m_CustomExposeVars.Clear();

      // read all members storead as Name+Type
      for(int i = 0;i < iNumOfSerializedMembers; i++)
      {
        char szBuffer1[64];
        char szBuffer2[64];
        bool bAllocated1 = false;
        bool bAllocated2 = false;
        const char *szName = ar.ReadEncryptedString(szBuffer1, 64, bAllocated1);
        const char *szValue = ar.ReadEncryptedString(szBuffer2, 64, bAllocated2);

        m_CustomExposeVars.Add(VScriptMember(szName, szValue));

        if(bAllocated1) V_SAFE_DELETE(szName);
        if(bAllocated2) V_SAFE_DELETE(szValue);
      }
    }
// ----------------------------------------------------------------------------
bool vHavokConstraintChainRendererBase::DoInit()
{
  // Get the constraint chain that owns this component
  VisTypedEngineObject_cl *pOwner = GetOwner();
  m_pConstraintChain = (pOwner && pOwner->IsOfType(V_RUNTIME_CLASS(vHavokConstraintChain)))
    ? static_cast<vHavokConstraintChain*>(pOwner)
    : NULL;
  if (!m_pConstraintChain)
    return false;

  // Register as a rendering hook
  Vision::Callbacks.OnRenderHook += this;
  Vision::Callbacks.OnUpdateSceneBegin += this;

  return true;
}
Exemplo n.º 6
0
void RPG_Trigger::OnOverlappingCollidableRemoved(hkpCollidable *handle)
{
  // check for phantoms (character proxy objects are phantoms)
  if(handle->getType() == hkpWorldObject::BROAD_PHASE_PHANTOM)
  {
    hkpEntity* hkEntity = static_cast<hkpEntity*>(handle->getOwner());

    vHavokUserDataType_e eType = V_USERDATA_UNDEFINED;
    void *pObject = vHavokUserDataPointerPair_t::ExtractTypeAndPointer((void*)hkEntity->getUserData(), eType);

    if (pObject && eType==V_USERDATA_OBJECT)
    {
      // pObject should be a VisTypedEngineObject_cl.
      VisTypedEngineObject_cl* object = (VisTypedEngineObject_cl*)pObject;

      if(object->IsOfType(V_RUNTIME_CLASS(vHavokCharacterController)))
      {
        m_exitedEntities.Add((VisBaseEntity_cl*)(static_cast<vHavokCharacterController*>(object)->GetOwner()));
      }
    }
  }
}