Exemplo n.º 1
0
        public virtual void Deserialize(byte[] data, Pointer p)
        {
            int numScripts = BitPacker.GetInt(data, p);

            for (int i = 0; i < numScripts; i++)
            {
                uint scriptId = BitPacker.GetUInt(data, p);
                Scripts.AttachScript(scriptId);
            }

            int numEffects = BitPacker.GetInt(data, p);

            for (int i = 0; i < numEffects; i++)
            {
                uint   effectId = BitPacker.GetUInt(data, p);
                Effect e        = Effect.GetEffect(effectId);

                if (e != null)
                {
                    e.Deserialize(data, p);
                }

                Effects.AttachEffect(this, null, effectId);
            }

            PhysicalState.Position.X = BitPacker.GetDouble(data, p);
            PhysicalState.Position.Y = BitPacker.GetDouble(data, p);
            PhysicalState.Position.Z = BitPacker.GetDouble(data, p);

            PhysicalState.Rotation.X = BitPacker.GetDouble(data, p);
            PhysicalState.Rotation.Y = BitPacker.GetDouble(data, p);
            PhysicalState.Rotation.Z = BitPacker.GetDouble(data, p);
        }
Exemplo n.º 2
0
 public virtual void Deserialize(byte[] data, Pointer p, bool includeSubComponents)
 {
     if (!includeSubComponents)
     {
         return;
     }
     lock (m_Components)
     {
         int count = BitPacker.GetInt(data, p);
         for (int i = 0; i < count; i++)
         {
             uint       typeHash = BitPacker.GetUInt(data, p);
             IComponent wisp     = Factory.Instance.CreateObject(typeHash) as IComponent;
             if (wisp == null)
             {
                 throw new ArgumentException("Error deserializing wisp object.  Did you remember to register the Wisp Object's ISerializableWispObject.TypeHash with the Factory? Try: |> Factory.Instance.Register(typeof(YourCharacterComponentClassName), () => { return new YourCharacterComponentClassName(); });|");
             }
             if (wisp is IComponent)
             {
                 AddComponent(wisp as IComponent);
             }
             wisp.Deserialize(data, p, includeSubComponents);
         }
     }
 }