Ejemplo n.º 1
0
// -----------------------------------------------------------------------------
// TSnapshotItem::TSnapshotItem
// Constructor, takes item id as a parameter
// -----------------------------------------------------------------------------
TSnapshotItem::TSnapshotItem( const TSmlDbItemUid& aItemId,
    const TSmlDbItemUid& aParent, TBool aUnread )
: TNSmlSnapshotItem( aItemId )
    {
    SetParentId( aParent );
    iUnread = aUnread;
    }
void CStickyProjectile::NetSerialize(CProjectile* pProjectile, TSerialize ser, EEntityAspects aspect)
{
	if(aspect == ASPECT_STICK)
	{
		ser.Value("pos", m_stuckPos, 'lwld');
		ser.Value("rot", m_stuckRot, 'ori1');
		ser.Value("joint", m_stuckJoint, 'i16');
		bool isStuckToEntity = m_parentId > 0;
		EntityId parentId = m_parentId;
		ser.Value("isStuckToEntity", isStuckToEntity, 'bool');
		ser.Value("stuckEntity", parentId, 'eid');
		SetParentId(parentId);

		if(isStuckToEntity && !m_parentId && ser.IsReading()) //Still waiting to resolve entity Id
		{
			ser.FlagPartialRead();
			return;
		}

		s_stuckSer = SStuckSer(this, pProjectile);
		ser.Value(
			"stuck",
			&s_stuckSer,
			&SStuckSer::IsStuck,
			&SStuckSer::SetStuck,
			'bool');
	}
}
void CStickyProjectile::Reset()
{
	m_stuckPos.zero();
	m_stuckRot.SetIdentity();
	m_flags &= ~eSF_Reset;
	SetParentId(0);
	m_childId = 0;
}
Ejemplo n.º 4
0
void CVehicleMountedWeapon::ResetState()
{
	if(m_pOwnerSeat != NULL)
	{
		if(m_pOwnerSeat == m_pSeatUser)
		{
			m_pOwnerSeat->SetLocked(eVSLS_Locked);
		}

		m_pOwnerSeat->Exit(true);
	}

	m_vehicleId = 0;
	m_pSeatUser = NULL;
	m_pOwnerSeat = NULL;
	SetParentId(0); //remove parent ID to allow first person mode
}
Ejemplo n.º 5
0
// -----------------------------------------------------------------------------
// TSnapshotItem::TSnapshotItem
// Constructor, takes item id as a parameter
// -----------------------------------------------------------------------------
TSnapshotItem::TSnapshotItem( const TSmlDbItemUid& aItemId,
    const TSmlDbItemUid& aParent )
: TNSmlSnapshotItem( aItemId )
    {
    SetParentId( aParent );
    }
Ejemplo n.º 6
0
void TagEntry::Create(const wxString &fileName,
                      const wxString &name,
                      int lineNumber,
                      const wxString &pattern,
                      const wxString &kind,
                      std::map<wxString, wxString>& extFields)
{
    SetPosition( wxNOT_FOUND );
    SetName( name );
    SetLine( lineNumber );
    SetKind( kind.IsEmpty() ? wxT("<unknown>") : kind );
    SetPattern( pattern );
    SetFile( fileName );
    SetId(-1);
    SetParentId(-1);

    m_extFields = extFields;
    wxString path;

    // Check if we can get full name (including path)
    path = GetExtField(wxT("class"));
    if(!path.IsEmpty()) {
        UpdatePath( path ) ;
    } else {
        path = GetExtField(wxT("struct"));
        if(!path.IsEmpty()) {
            UpdatePath( path ) ;
        } else {
            path = GetExtField(wxT("namespace"));
            if(!path.IsEmpty()) {
                UpdatePath( path ) ;
            } else {
                path = GetExtField(wxT("interface"));
                if(!path.IsEmpty()) {
                    UpdatePath( path ) ;
                } else {
                    path = GetExtField(wxT("enum"));
                    if(!path.IsEmpty()) {
                        UpdatePath( path ) ;
                    } else {
                        path = GetExtField(wxT("union"));
                        if(!path.IsEmpty()) {
                            UpdatePath( path ) ;
                        }
                    }
                }
            }
        }
    }

    if(!path.IsEmpty()) {
        SetScope(path);
    } else {
        SetScope(wxT("<global>"));
    }

    // If there is no path, path is set to name
    if( GetPath().IsEmpty() )
        SetPath( GetName() );

    // Get the parent name
    StringTokenizer tok(GetPath(), wxT("::"));
    wxString parent;

    (tok.Count() < 2) ? parent = wxT("<global>") : parent = tok[tok.Count()-2];
    SetParent(parent);
}
bool CStickyProjectile::StickToEntity( const SStickParams& stickParams, IEntity* pTargetEntity )
{
	IEntity* pProjectileEntity = stickParams.m_pProjectile->GetEntity();
	ICharacterInstance* pCharInstance = pTargetEntity->GetCharacter(0);
	if( pCharInstance)	
	{
		IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pTargetEntity->GetId());
		if (!pActor || (stickParams.m_bStickToFriendlies || !pActor->IsFriendlyEntity(stickParams.m_ownerId)) && (gEnv->bMultiplayer || !pActor->IsDead()))
		{
			m_stuckJoint = GetJointIdFromPartId(*pTargetEntity, stickParams.m_targetPartId);
			m_stuckNormal = stickParams.m_stickNormal;
			m_stuckPartId = stickParams.m_targetPartId;

			ICharacterModelSkeleton* pICharacterModelSkeleton = pCharInstance->GetICharacterModel()->GetICharacterModelSkeleton();
			ISkeletonPose* pSkeleton = pCharInstance->GetISkeletonPose();
			const char* boneName = pICharacterModelSkeleton->GetJointNameByID(m_stuckJoint);
			const QuatT jointWorld = QuatT(pTargetEntity->GetWorldTM()) * pSkeleton->GetAbsJointByID(m_stuckJoint);
			QuatT loc;
			CalculateLocationForStick( *pProjectileEntity, stickParams.m_stickPosition, stickParams.m_stickNormal, loc );
			pProjectileEntity->SetWorldTM(Matrix34(loc));

			// Get the local pos and rot.
			loc = jointWorld.GetInverted() * loc;
			m_stuckPos = loc.t;
			m_stuckRot = loc.q;

			// Attach.
			if(AttachToCharacter( stickParams.m_pProjectile, *pTargetEntity, *pCharInstance, boneName))
			{
				m_flags |= eSF_IsStuck;
				m_flags |= pActor ? pActor->IsPlayer() ? eSF_StuckToPlayer : eSF_StuckToAI : 0;
				SetParentId(pTargetEntity->GetId());
				m_childId = pProjectileEntity->GetId();
				return true;
			}
		}
	}
	else
	{
		m_stuckNormal = stickParams.m_stickNormal;
		m_stuckPartId = stickParams.m_targetPartId;

		QuatT loc;
		CalculateLocationForStick( *pProjectileEntity, stickParams.m_stickPosition, stickParams.m_stickNormal, loc );

		AttachTo(stickParams.m_pProjectile, pTargetEntity);

		pProjectileEntity->SetWorldTM(Matrix34(loc));

		// Set as Stuck.
		SetParentId(pTargetEntity->GetId());
		m_childId = pProjectileEntity->GetId();
		m_flags |= eSF_IsStuck;

		//Store position and rotation relative to parent entity
		m_stuckPos = pProjectileEntity->GetPos();
		m_stuckRot = pProjectileEntity->GetRotation();
		return true;
	}

	return false;
}
void CStickyProjectile::SwapToCorpse( const EntityId corpseId )
{
	SetParentId(corpseId);
}
CStickyProjectile::~CStickyProjectile()
{
	m_childId = 0;
	UnStick();
	SetParentId(0);
}