BVB Source Codes

CRYENGINE Show TimeSource.cpp Source code

Return Download CRYENGINE: download TimeSource.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "TimeSource.h"
  5.  
  6. CRY_PFX2_DBG
  7.  
  8. namespace pfx2
  9. {
  10.  
  11.  
  12. bool Serialize(Serialization::IArchive& ar, ETimeSourceField& value, cstr name, cstr label)
  13. {
  14.         // Populate enum on first serialization call.
  15.         if (!ETimeSourceField::count())
  16.         {
  17.                 for (auto type : EParticleDataType::values())
  18.                         if (type.info().isType<float>(1) && type != EPDT_NormalAge && type != EPDT_SpawnFraction && type != EPDT_InvLifeTime)
  19.                                 ETimeSourceField::container().add(type, type.name(), type.label());
  20.         }
  21.  
  22.         return value.container().Serialize(ar, reinterpret_cast<ETimeSourceField::Value&>(value), name, label);
  23. }
  24.  
  25. void CTimeSource::SerializeInplace(Serialization::IArchive& ar)
  26. {
  27.         const auto& context = GetContext(ar);
  28.  
  29.         bool patchedTimeSource = false;
  30.         if (ar.isInput() && GetVersion(ar) < 7)
  31.         {
  32.                 string field;
  33.                 const bool hasField = ar(field, "Field");
  34.                 if (hasField && field == "Age")
  35.                 {
  36.                         m_timeSource = ETimeSource::Age;
  37.                         string source;
  38.                         ar(source, "Source");
  39.                         if (source == "Field")
  40.                                 m_sourceOwner = ETimeSourceOwner::Self;
  41.                         else if (source == "ParentField")
  42.                                 m_sourceOwner = ETimeSourceOwner::Parent;
  43.                         patchedTimeSource = true;
  44.                 }
  45.         }
  46.         if (!patchedTimeSource)
  47.                 ar(m_timeSource, "TimeSource", "^>120>");
  48.  
  49.         // Read or set related parameters
  50.         switch (m_timeSource)
  51.         {
  52.         case ETimeSource::Field:
  53.                 ar(m_fieldSource, "Field", "Field");
  54.         // continue
  55.         case ETimeSource::Age:
  56.         case ETimeSource::SpawnFraction:
  57.         case ETimeSource::Speed:
  58.                 if (m_sourceOwner == ETimeSourceOwner::_None)
  59.                         m_sourceOwner = ETimeSourceOwner::Self;
  60.                 ar(m_sourceOwner, "Owner", "Owner");
  61.                 break;
  62.         case ETimeSource::Attribute:
  63.                 ar(m_attributeName, "AttributeName", "Attribute Name");
  64.                 m_sourceOwner = ETimeSourceOwner::_None;
  65.                 break;
  66.         case ETimeSource::LevelTime:
  67.                 m_sourceOwner = ETimeSourceOwner::_None;
  68.                 break;
  69.  
  70.         case ETimeSource::_ParentTime:
  71.                 m_timeSource = ETimeSource::Age;
  72.                 m_sourceOwner = ETimeSourceOwner::Parent;
  73.                 break;
  74.         case ETimeSource::_ParentOrder:
  75.                 m_timeSource = ETimeSource::SpawnFraction;
  76.                 m_sourceOwner = ETimeSourceOwner::Parent;
  77.                 break;
  78.         case ETimeSource::_ParentSpeed:
  79.                 m_timeSource = ETimeSource::Speed;
  80.                 m_sourceOwner = ETimeSourceOwner::Parent;
  81.                 break;
  82.         case ETimeSource::_ParentField:
  83.                 m_timeSource = ETimeSource::Field;
  84.                 m_sourceOwner = ETimeSourceOwner::Parent;
  85.                 ar(m_fieldSource, "Field", "Field");
  86.                 break;
  87.         }
  88.  
  89.         if (ar.isInput() && GetVersion(ar) < 7)
  90.         {
  91.                 ar(m_timeScale, "Scale", "Scale");
  92.                 ar(m_timeBias, "Bias", "Bias");
  93.         }
  94.         else
  95.         {
  96.                 ar(m_timeScale, "TimeScale", "Time Scale");
  97.                 ar(m_timeBias, "TimeBias", "Time Bias");
  98.         }
  99.  
  100.         if (!context.HasUpdate() || m_timeSource == ETimeSource::Random)
  101.                 m_spawnOnly = true;
  102.         else if (context.GetDomain() == EMD_PerParticle && m_timeSource == ETimeSource::Age && m_sourceOwner == ETimeSourceOwner::Self || m_timeSource == ETimeSource::ViewAngle)
  103.                 m_spawnOnly = false;
  104.         else
  105.                 ar(m_spawnOnly, "SpawnOnly", "Spawn Only");
  106. }
  107.  
  108. string CTimeSource::GetSourceDescription() const
  109. {
  110.         string desc;
  111.         if (m_sourceOwner == ETimeSourceOwner::Parent)
  112.                 desc = "Parent ";
  113.  
  114.         if (m_timeSource == ETimeSource::Attribute)
  115.                 desc += "Attribute: ", desc += m_attributeName;
  116.         else if (m_timeSource == ETimeSource::Field)
  117.                 desc += Serialization::getEnumLabel(m_fieldSource);
  118.         else
  119.                 desc += Serialization::getEnumLabel(m_timeSource);
  120.  
  121.         return desc;
  122. }
  123.  
  124.  
  125. }
  126.  
downloadTimeSource.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top