//------------------------------------------------------------------------
void CVehicleSeatActionRotateTurret::Serialize(TSerialize ser, EEntityAspects aspects)
{
	// MR: for network, only turret parts are serialized
	// for savegame, all parts are serialized (by CVehicle)
	if (ser.GetSerializationTarget() == eST_Network)
	{
		for (int i = 0; i < eVTRT_NumRotationTypes; ++i)
		{
			if (m_rotations[i].m_pPart)
			{
				m_rotations[i].m_pPart->Serialize(ser, aspects);
			}
		}
	}
	else
	{
		// save rotation details
		CryFixedStringT<16> tag;
		for (int i = 0; i < eVTRT_NumRotationTypes; ++i)
		{
			if (m_rotations[i].m_pPart)
			{
				Quat     q;
				Matrix34 currentTM = m_rotations[i].m_pPart->GetLocalBaseTM();
				if (ser.IsWriting())
					q = Quat(currentTM);

				tag = (i == eVTRT_Pitch) ? "rotation_pitch" : "rotation_yaw";
				ser.Value(tag.c_str(), q, 'ori1');

				if (ser.IsReading())
				{
					Matrix34 newTM(q);
					newTM.SetTranslation(currentTM.GetTranslation());
					m_rotations[i].m_pPart->SetLocalBaseTM(newTM);
					m_rotations[i].m_orientation.Set(q);
				}
			}
		}
	}
}
Example #2
0
bool CHeavyMountedWeapon::NetSerialize(TSerialize ser, EEntityAspects aspect, uint8 profile, int flags)
{
	if (!BaseClass::NetSerialize(ser, aspect, profile, flags))
		return false;

	if(aspect == ASPECT_RIPOFF)
	{
		ser.Value("ripOff", static_cast<CHeavyMountedWeapon*>(this), &CHeavyMountedWeapon::IsRippingOrRippedOff, &CHeavyMountedWeapon::SetRippingOff, 'bool');
	}

	return true;
}
Example #3
0
void CMultipleGrabHandler::Serialize(TSerialize ser)
{
	int numHandlers;
	if (ser.IsWriting())
		numHandlers = m_handlers.size();

	ser.Value("numHandlers", numHandlers);

	if (ser.IsReading())
	{
		for (int i=0; i < numHandlers; ++i)
		{
			m_handlers.push_back (new CAnimatedGrabHandler (m_pActor));
		}
	}

	std::vector <CAnimatedGrabHandler*>::iterator it = m_handlers.begin();
	std::vector <CAnimatedGrabHandler*>::iterator end = m_handlers.end();
	for ( ; it != end; ++it)
		(*it)->Serialize (ser);
}
void CDoorPanel::FullSerialize( TSerialize serializer )
{
	if (serializer.IsReading())
	{
		m_fLastVisibleDistanceCheckTime = 0.0f;
		int iCurrentState = (int)eDoorPanelBehaviorState_Idle;
		serializer.Value( "CurrentState", iCurrentState );
		const EDoorPanelBehaviorState stateId = (EDoorPanelBehaviorState)iCurrentState;
		if (stateId != eDoorPanelBehaviorState_Invalid)
		{
			m_currentState = stateId;
		}
	}
	else
	{
		int iCurrentState = (int)m_currentState;
		serializer.Value( "CurrentState", iCurrentState );
	}
	
	StateMachineSerializeBehavior( SStateEventSerialize(serializer) );
}
void CSmartMine::FullSerialize( TSerialize ser )
{
	uint32 targetCount = m_trackedEntities.size();

	ser.Value( "MineEnabled", m_enabled );
	ser.Value( "MineFaction", m_factionId );
	ser.Value( "MineTargetCount", targetCount );

	CryFixedStringT<16> targetName;
	if (ser.IsReading())
	{
		m_trackedEntities.clear();
		for(uint32 i = 0; i < targetCount; ++i)
		{
			m_trackedEntities.push_back();
			targetName.Format( "MineTarget_%d", i );
			ser.Value( targetName.c_str(), m_trackedEntities[i] );
		}
	}
	else
	{
		for(uint32 i = 0; i < targetCount; ++i)
		{
			targetName.Format( "MineTarget_%d", i );
			ser.Value( targetName.c_str(), m_trackedEntities[i] );
		}
	}

	StateMachineSerializeBehavior( SStateEventSerialize( ser ) );
}
Example #6
0
//------------------------------------------------------------------
void CLam::FullSerialize(TSerialize ser)
{
    CAccessory::FullSerialize(ser);

    if(ser.IsReading())
    {
        ActivateLight(false);
        ActivateLaser(false);
        m_lastLaserHitPt.Set(0,0,0);
        m_lastLaserHitSolid = false;
        m_smoothLaserLength = -1.0f;
        DestroyLaserEntity();
        m_laserHelperFP.clear();
        m_allowUpdate = false;
        m_updateTime = 0.0f;
    }

    m_laserActiveSerialize = m_laserActivated;
    ser.Value("laserActivated", m_laserActiveSerialize);
    m_lightActiveSerialize = m_lightActivated;
    ser.Value("lightActivated", m_lightActiveSerialize);
}
Example #7
0
	virtual void Serialize(SActivationInfo *pActInfo, TSerialize ser)
	{
		ser.Value("m_bPlaying", m_bPlaying);
		ser.Value("m_direction", m_direction);
		ser.Value("m_postSerializeTrigger", m_postSerializeTrigger);

		if (ser.IsReading())
		{
			// in case we were playing before the fader is stopped on load,
			// but still we need to activate outputs. this MUST NOT be done in serialize
			// but in ProcessEvent
			if (m_bPlaying)
			{
				pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, true);
				m_postSerializeTrigger = m_direction;
			}
			m_bPlaying = false;
			m_bNeedFaderStop = false;
			m_ticket = 0;
			m_direction = 0;
		}
	}
Example #8
0
		void SerializeWith( TSerialize ser )
		{
			ser.Value("hostId", hostId, 'eid');
			ser.Value("ownerId", ownerId, 'eid');
			ser.Value("weaponId", weaponId, 'eid');
			ser.Value("fmId", fmId, 'fmod');
			ser.Value("pos", pos, 'wrld');
			ser.Value("dir", dir, 'dir0');
			ser.Value("vel", vel, 'vel0');
			ser.Value("tracked", tracked, 'bool');
		}
Example #9
0
void CMasterFader::Serialize( TSerialize ser )
{
	if (ser.IsReading())
	{
		for (int i=0; i<NUM_FADERS; ++i)
		{
			if (m_pHUDFader[i])
			{
				m_pHUDFader[i]->Reset();
			}
		}
	}
}
Example #10
0
void CPlayerRotation::FullSerialize( TSerialize ser )
{
	ser.BeginGroup( "PlayerRotation" );
	ser.Value( "viewAngles" , m_viewAngles );
	ser.Value( "leanAmount", m_leanAmount );
	ser.Value( "viewRoll", m_viewRoll );

	//[AlexMcC|19.03.10]: TODO: delete these once we stop reviving players on quick load!
	// When we don't revive, these are overwritten by a calculation that reads from m_viewAngles,
	// which we serialize above.
	ser.Value( "viewQuat", m_viewQuat );
	ser.Value( "viewQuatFinal", m_viewQuatFinal );
	ser.Value( "baseQuat", m_baseQuat );
	ser.EndGroup();
}
void CHUDMissionObjective::Serialize(TSerialize ser)
{
	//ser.Value("m_shortMessage", m_shortMessage);
	//ser.Value("m_screenMessage", m_screenMessage);
	//ser.Value("m_id", m_id);

	ser.Value("m_trackedEntity", m_trackedEntity);
	ser.EnumValue("m_eStatus", m_eStatus, FIRST, LAST);
	ser.Value("m_silent", m_silent);
	ser.Value("m_secondary", m_secondary);

	if(ser.IsReading())
	{
		if(m_eStatus != DEACTIVATED)
		{
			m_lastTimeChanged = gEnv->pTimer->GetFrameStartTime().GetSeconds();
		}

		m_pMOS = g_pGame->GetMOSystem();

		SetTrackedEntity(m_trackedEntity.c_str());
	}
}
Example #12
0
//------------------------------------------------------------------------
void CVehicleMovementWarrior::Serialize(TSerialize ser, EEntityAspects aspects)
{
  CVehicleMovementHovercraft::Serialize(ser, aspects);

  if (ser.GetSerializationTarget() != eST_Network)
  {
    ser.Value("m_thrustersDamaged", m_thrustersDamaged);
    ser.Value("m_collapseTimer", m_collapseTimer);
    ser.Value("m_collapsed", m_collapsed);
    ser.Value("m_platformDown", m_platformDown);

    char buf[16];    
    for (int i=0; i<m_numThrusters; ++i)
    {
      _snprintf(buf, 16, "thruster_%d", i);
      ser.BeginGroup(buf);
      ser.Value("enabled", m_vecThrusters[i]->enabled);
      ser.Value("heightAdaption", m_vecThrusters[i]->heightAdaption);
      ser.Value("hoverVariance", m_vecThrusters[i]->hoverVariance);            
      ser.EndGroup();
    }    
  }
}
Example #13
0
void CSoundMoods::Serialize(TSerialize ser)
{
    if(!m_pSoundMoodManager)
        return;

    uint uiSoundMood = 0;
    for(TVectorSoundMoods::iterator iter=m_vecSoundMoods.begin(); iter!=m_vecSoundMoods.end(); ++iter,++uiSoundMood)
    {
        SSoundMood *pSoundMood = &(*iter);

        char szTemp[256];
        sprintf(szTemp,"strSoundMood_%d",	uiSoundMood);
        ser.Value(szTemp,pSoundMood->strSoundMood);
        sprintf(szTemp,"uiFadeOutTime_%d",uiSoundMood);
        ser.Value(szTemp,pSoundMood->uiFadeOutTime);
        sprintf(szTemp,"uiFadeOut_%d",		uiSoundMood);
        ser.Value(szTemp,pSoundMood->uiFadeOut);
        sprintf(szTemp,"bValid_%d",				uiSoundMood);
        ser.Value(szTemp,pSoundMood->bValid);
        sprintf(szTemp,"bUnlimited_%d",		uiSoundMood);
        ser.Value(szTemp,pSoundMood->bUnlimited);
    }
}
void CTacticalManager::STacticalInterestPoint::Serialize(TSerialize ser)
{
	ser.Value("m_entityId", m_entityId);
	ser.Value("m_scanned", m_scanned);
	ser.Value("m_overrideIconType", m_overrideIconType);
	ser.Value("m_tagged", m_tagged);
	ser.Value("m_visible", m_visible);
	ser.Value("m_pinged", m_pinged);
}
//------------------------------------------------------------------------
void CVehicleSeatActionSound::Serialize(TSerialize ser, EEntityAspects aspects)
{
	if (aspects&CVehicle::ASPECT_SEAT_ACTION)
	{
		NET_PROFILE_SCOPE("SeatAction_Sound", ser.IsReading());

		bool enabled=m_enabled;
		
		ser.Value("enabled", enabled, 'bool');

		if(ser.IsReading())
		{
			if(m_enabled != enabled)
			{
				if (enabled)
					ExecuteTrigger(m_nAudioControlIDStart);
				else
					StopTrigger();

				m_enabled=enabled;
			}
		}
	}
}
void SDeclareExplosiveObjectState::SerializeWith( TSerialize ser )
{
	LOGBREAK("SDeclareExplosiveObjectState: %s", ser.IsReading() ? "Reading:" : "Writing");

	ser.Value("breakId", breakId, 'brId');
	ser.Value("isEnt", isEnt);
	if (isEnt)
	{
		if (ser.IsWriting())
			CRY_ASSERT(CCryAction::GetCryAction()->GetGameContext()->GetNetContext()->IsBound(entId));
		ser.Value("entid", entId, 'eid');
		ser.Value("entpos", entPos);
		ser.Value("entrot", entRot);
		ser.Value("entscale", entScale);
	}
	else
	{
		ser.Value("eventPos", eventPos);
		ser.Value("hash", hash);
	}
}
Example #17
0
//------------------------------------------------------------------------
void CProjectile::SerializeSpawnInfo( TSerialize ser )
{
	ser.Value("hostId", m_hostId, 'eid');
	ser.Value("ownerId", m_ownerId, 'eid');
	ser.Value("weaponId", m_weaponId, 'eid');
	ser.Value("fmId", m_fmId, 'fmod');
	ser.Value("pos", m_initial_pos, 'wrld');
	ser.Value("dir", m_initial_dir, 'dir0');
	ser.Value("vel", m_initial_vel, 'vel0');
	ser.Value("tracked", m_tracked, 'bool');

	if (ser.IsReading())
		SetParams(m_ownerId, m_hostId, m_weaponId, m_fmId, m_damage, m_hitTypeId);
}
void CAICounter_Alertness::Serialize( TSerialize ser )
{
	ser.BeginGroup("AICounter_Alertness");

	ser.Value( "m_timeNextUpdate", m_timeNextUpdate );
	ser.Value( "m_alertnessGlobal", m_alertnessGlobal );
	ser.Value( "m_alertnessEnemies", m_alertnessEnemies );
	ser.Value( "m_alertnessFriends", m_alertnessFriends );
	ser.Value( "m_alertnessFaction", m_alertnessFaction );
	ser.Value( "m_bNewListeners", m_bNewListeners );
	if (ser.IsReading())
	{
		m_bJustUpdated = false;
		m_bFactionVectorsAreValid = false;
	}

	ser.EndGroup();
}
 void Serialize(SActivationInfo *, TSerialize ser)
 {
     ser.BeginGroup("Local");
     ser.Value("m_currentRotation", m_currentRotation);
     ser.Value("m_destinationRotation", m_destinationRotation);
     ser.Value("m_currentRotationStep", m_currentRotationStep);
     ser.Value("m_lastTime", m_lastTime);
     ser.Value("m_timeRemaining", m_timeRemaining);
     // the regular update is taken care of by the FlowGraph itself
     ser.EndGroup();
 }
Example #20
0
//------------------------------------------------------------------------
void CProjectile::SerializeSpawnInfo(TSerialize ser)
{
	ser.Value("hostId", m_hostId, 'eid');
	ser.Value("ownerId", m_ownerId, 'eid');
	ser.Value("weaponId", m_weaponId, 'eid');
	ser.Value("pos", m_initial_pos, 'wrld');
	ser.Value("dir", m_initial_dir, 'dir0');
	ser.Value("vel", m_initial_vel, 'vel0');

	if(ser.IsReading())
		SetParams(m_ownerId, m_hostId, m_weaponId, m_damage, m_hitTypeId, m_damageDropPerMeter, m_damageDropMinDisSqr);
}
//------------------------------------------------------------------------
void CVehicleActionAutomaticDoor::Serialize(TSerialize ser, EEntityAspects aspects)
{
    ser.Value("timeInTheAir", m_timeInTheAir);
    ser.Value("timeOnTheGround", m_timeOnTheGround);
    ser.Value("isTouchingGround", m_isTouchingGround);
    ser.Value("isTouchingGroundBase", m_isTouchingGroundBase);
    ser.Value("eventSamplingTime",m_eventSamplingTime);

    ser.Value("animTime", m_animTime);

    if (ser.IsReading())
        {
            m_pDoorAnim->StartAnimation();
            m_pDoorAnim->ToggleManualUpdate(true);
            m_pDoorAnim->SetTime(m_animTime);
        }
}
Example #22
0
void CGameAISystem::Serialize(TSerialize ser)
{
	m_AIAwarenessToPlayerHelper.Serialize( ser );
	m_AICounters.Serialize( ser );
	if (ser.IsReading())
		Reset(false);

	m_state = UpdatingModules;

	Modules::iterator it = m_modules.begin();
	Modules::iterator end = m_modules.end();

	for ( ; it != end; ++it)
	{
		IGameAIModule& module = *(*it);
		module.Serialize(ser);
	}

	m_state = Idle;
}
Example #23
0
void SearchSpot::Serialize(TSerialize ser)
{
	// VisionID is not serialized. It will be created in InitSearchSpots.

	ser.Value("pos", m_pos);
	ser.Value("assigneeID", m_assigneeID);
	ser.Value("searchTimeoutLeft", m_searchTimeoutLeft);
	ser.Value("isTargetSearchSpot", m_isTargetSearchSpot);

	uint8 intStatus = (uint8)m_status;
	ser.Value("status", intStatus);

	if (ser.IsReading())
		m_status = (SearchSpotStatus)intStatus;
}
Example #24
0
void CScriptProxy::SerializeProperties( TSerialize ser )
{
	if (ser.GetSerializationTarget() == eST_Network)
		return;

	// Saving.
	if (!(m_pEntity->GetFlags() & ENTITY_FLAG_UNREMOVABLE))
	{

		// Properties never serialized
		/*
		   if (!m_pEntity->GetArchetype())
		   {
		   // If not archetype also serialize properties table of the entity.
		   SerializeTable( ser, "Properties" );
		   }*/

		// Instance table always initialized for dynamic entities.
		SerializeTable( ser, "PropertiesInstance" );
	}
}
//------------------------------------------------------------------------
void CVehicleMovementVTOL::Serialize(TSerialize ser, EEntityAspects aspects)
{
	CVehicleMovementHelicopter::Serialize(ser, aspects);

	if ((ser.GetSerializationTarget() == eST_Network) &&(aspects & eEA_GameClientDynamic))
	{
		ser.Value("wings", m_wingsAnimTime, 'unit');
	}
	else
	{
		ser.Value("horizontal", m_horizontal);
		ser.Value("wingsTime", m_wingsAnimTime);
		ser.Value("forwardAction", m_forwardAction);
		ser.Value("isVTOLMovement", m_isVTOLMovement); // for ai

		if (ser.IsReading())
			SetHorizontalMode(m_horizontal);
	}
}
Example #26
0
void CPlayerStateJump::OnFullSerialize( TSerialize ser, CPlayer& player )
{
	ser.BeginGroup( "StateJump" );
	ser.Value( "JumpLock", m_jumpLock );
	if( ser.IsReading() )
	{
		EJumpState state = JState_None;
		ser.EnumValue( "jumpState", state, JState_None, JState_Total );
		SetJumpState( player, state );
	}
	else
	{
		ser.EnumValue( "jumpState", m_jumpState, JState_None, JState_Total );
	}
	ser.EndGroup();
}
Example #27
0
void CMonoEntityExtension::FullSerialize(TSerialize ser)
{
	IEntity *pEntity = GetEntity();

	ser.BeginGroup("Properties");
	auto pPropertyHandler = static_cast<CEntityPropertyHandler *>(pEntity->GetClass()->GetPropertyHandler());
	for(int i = 0; i < pPropertyHandler->GetPropertyCount(); i++)
	{
		if(ser.IsWriting())
		{
			IEntityPropertyHandler::SPropertyInfo propertyInfo;
			pPropertyHandler->GetPropertyInfo(i, propertyInfo);

			ser.Value(propertyInfo.name, pPropertyHandler->GetProperty(pEntity, i));
		}
		else
		{
			IEntityPropertyHandler::SPropertyInfo propertyInfo;
			pPropertyHandler->GetPropertyInfo(i, propertyInfo);

			char *propertyValue = nullptr;
			ser.ValueChar(propertyInfo.name, propertyValue, 0);

			pPropertyHandler->SetProperty(pEntity, i, propertyValue);
		}
	}

	ser.EndGroup();

	ser.BeginGroup("ManagedEntity");

	IMonoArray *pArgs = CreateMonoArray(1);
	pArgs->InsertNativePointer(&ser);

	m_pScript->GetClass()->InvokeArray(m_pScript->GetManagedObject(), "InternalFullSerialize", pArgs);
	pArgs->Release();

	ser.EndGroup();
}
Example #28
0
//------------------------------------------------------------------------
void CVehiclePartEntity::Serialize(TSerialize serializer, EEntityAspects aspects)
{
	CVehiclePartBase::Serialize(serializer, aspects);

	bool saveGame = serializer.GetSerializationTarget() != eST_Network ;

	if( saveGame )
	{
		uint32	flags = 0;

		if(serializer.IsWriting())
		{
			if(m_hidden)
			{
				flags |= Flags::Hidden;
			}

			if(m_entityAttached)
			{
				flags |= Flags::EntityAttached;
			}

			if (m_destroyed)
			{
				flags |= Flags::Destroyed;
			}
		}

		serializer.Value("entityId", m_entityId);
		serializer.Value("flags", flags);

		if(serializer.IsReading())
		{
			m_hidden         = !!(flags & Flags::Hidden);
			m_entityAttached = !!(flags & Flags::EntityAttached);
			m_destroyed      = !!(flags & Flags::Destroyed);
		}
	}
	else
	{
		serializer.Value("netId",m_entityNetId,'ui16');
	}

}
//------------------------------------------------------------------------
void CNetworkMovementHelicopterCrysis2::Serialize(TSerialize ser, EEntityAspects aspects)
{
	CRY_ASSERT(ser.GetSerializationTarget() == eST_Network);

	NET_PROFILE_SCOPE("Movement", ser.IsReading());
	NET_PROFILE_SCOPE("NetMovementHelicopterCrysis2", ser.IsReading());

	if (m_netSyncFlags & k_syncLookMoveSpeed)
	{
		ser.Value("look", m_lookTarget, 'wrl3');
		ser.Value("move", m_moveTarget, 'wrl3');
		ser.Value("speed", m_desiredSpeed, 'iii');
	}
	if (m_netSyncFlags & k_syncPos)
	{
		ser.Value("pos", m_currentPos, 'wrld');
		ser.Value("rot", m_currentRot, 'ori1');
	}
}
Example #30
0
	virtual void Serialize(SActivationInfo *pActInfo, TSerialize ser)
	{
		ser.BeginGroup("Local");

		ser.Value("m_entityId", m_entityId);
		ser.Value("m_delayResult", m_delayResult);
		bool bEnabled = m_enabled;
		ser.Value("m_enabled", bEnabled);

		if (ser.IsReading()) 
		{
			if (bEnabled)
			{
				m_actInfo = *pActInfo;
			}
			SetEnabled(bEnabled); // can't hurt to do this on load as the listener uses stl::push_back_unique
		}

		ser.EndGroup();
	}