Esempio n. 1
0
        /// <summary>
        /// Called when deserializing
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected EntityShape(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _entityClass = info.GetString( "_entityClass" );
              _modelFile   = info.GetString( "_modelFile" );

              // load entity properties
              object entityProps = (object) info.GetValue( "_entityProperties", typeof(object) );
              _entityProperties = entityProps as DynamicPropertyCollection;

              // Store the old property collection data in a member variable (when loading old scene files).
              // We'll migrate the property values in the OnDeserialization when all nested properties are fully loaded.
              if (_entityProperties == null)
              {
            _oldEntityProperties = entityProps as CloneableBase;
            UpdateEntityProperties(true);
            //_entityProperties = EditorManager.EngineManager.EntityClassManager.CreateCollection(this,_entityClass);
              }

              if (SerializationHelper.HasElement(info,"_bCastStaticShadows"))
            _bCastStaticShadows = info.GetBoolean("_bCastStaticShadows");
              if (SerializationHelper.HasElement(info,"_bCastDynamicShadows"))
            _bCastDynamicShadows = info.GetBoolean("_bCastDynamicShadows");
              if (SerializationHelper.HasElement(info,"_vLightGridOfs"))
            _vLightGridOfs = (Vector3F)info.GetValue("_vLightGridOfs", typeof(Vector3F));
              if (SerializationHelper.HasElement(info,"_iVisibleBitmask"))
            _iVisibleBitmask = (FlagsInt32_e)info.GetValue("_iVisibleBitmask", typeof(FlagsInt32_e));
              if (SerializationHelper.HasElement(info,"_iLightInfluenceBitmask"))
            _iLightInfluenceBitmask = (FlagsInt32_e)info.GetValue("_iLightInfluenceBitmask", typeof(FlagsInt32_e));
            //      if (SerializationHelper.HasElement(info,"_fLightmapTiling"))
            //        _fLightmapTiling = info.GetSingle("_fLightmapTiling");
              if (SerializationHelper.HasElement(info,"_ambientColor"))
            _ambientColor = (Color)info.GetValue("_ambientColor", typeof(Color));
              if (SerializationHelper.HasElement(info, "_farClipDistance"))
            _farClipDistance = info.GetSingle("_farClipDistance");
              if (SerializationHelper.HasElement(info, "_nearClipDistance"))
            _nearClipDistance = info.GetSingle("_nearClipDistance");
              if (SerializationHelper.HasElement(info, "_renderOrderPriority"))
            _renderOrderPriority = info.GetSByte("_renderOrderPriority");
              if (SerializationHelper.HasElement(info, "_classDefTemplate"))
            _classDefTemplate = info.GetString("_classDefTemplate");
              if (SerializationHelper.HasElement(info, "_copySource"))
            _copySource = (EntityShape)info.GetValue("_copySource", typeof(EntityShape));
              if (SerializationHelper.HasElement(info, "_customMaterialSetName"))
            _customMaterialSetName = info.GetString("_customMaterialSetName");
        }
Esempio n. 2
0
		private UnitType(SerializationInfo info, StreamingContext c)
		{
			// Retrieve data from serialization:
			int maxindex = 0;
			int count = info.GetInt32("count");
			int[] tstoreind = new int[count];
			sbyte[] tstoreexp = new sbyte[count];
			for (int i = 0; i < count; i++)
			{
				int index = UnitType.GetBaseUnitIndex(info.GetString("name" + i.ToString()));
				tstoreind[i] = index;
				tstoreexp[i] = info.GetSByte("exp"+i.ToString());
				if (index > maxindex) maxindex = index;
			}

			// Construct instance:
			this.baseUnitIndices = new sbyte[maxindex+1];
			for (int i = 0; i < count; i++)
			{
				this.baseUnitIndices[tstoreind[i]] = tstoreexp[i];
			}
		}