Example #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);
        }
Example #2
0
        public bool AttachEffect(IGameObject target, IGameObject instigator, uint kind, bool fireScriptAttachEvent = false)
        {
            Effect e = Effect.GetEffect(kind) as Effect;

            if (e == null)
            {
                // "That effect does not exist."
                return(false);
            }

            e.Target     = target;
            e.Instigator = instigator;
            if (AttachEffect(e))
            {
                return(true);
            }
            return(false);
        }