/// <summary> /// Serializes the component to binary /// </summary> /// <param name="buffer"></param> /// <param name="p"></param> /// <param name="includeSubComponents"></param> public virtual void Serialize(ref byte[] buffer, Pointer p, bool includeSubComponents) { //Log.LogMsg("Serializing component " + GetType().ToString() + " as ID " + TypeHash.ToString()); if (!includeSubComponents) { return; } lock (m_Components) { //List<Component> wisps = m_Components.FindAll(w => w is ISerializableWispObject); BitPacker.AddInt(ref buffer, p, m_Components.Count); for (int i = 0; i < m_Components.Count; i++) { IComponent wisp = m_Components[i] as IComponent; BitPacker.AddUInt(ref buffer, p, wisp.TypeHash); wisp.Serialize(ref buffer, p, includeSubComponents); } } }
public virtual void Serialize(ref byte[] buffer, Pointer p) { BitPacker.AddInt(ref buffer, p, Scripts.AttachedScripts.Count); foreach (GameObjectScript s in Scripts.AttachedScripts.Values) { BitPacker.AddUInt(ref buffer, p, s.TypeHash); } BitPacker.AddInt(ref buffer, p, Effects.AttachedEffects.Count); foreach (Effect e in Effects.AttachedEffects.Values) { BitPacker.AddUInt(ref buffer, p, e.Information.EffectKind); e.Serialize(ref buffer, p); } BitPacker.AddDouble(ref buffer, p, PhysicalState.Position.X); BitPacker.AddDouble(ref buffer, p, PhysicalState.Position.Y); BitPacker.AddDouble(ref buffer, p, PhysicalState.Position.Z); BitPacker.AddDouble(ref buffer, p, PhysicalState.Rotation.X); BitPacker.AddDouble(ref buffer, p, PhysicalState.Rotation.Y); BitPacker.AddDouble(ref buffer, p, PhysicalState.Rotation.Z); }