public void Write(BitStream stream)
        {
            stream.Write(this.ID);
            stream.Write(Name);


            BitStreamExtension.Write(stream, (ulong)getParams());

            if (ScemeName.Length > 0)
            {
                stream.Write(ScemeName);
            }

            for (int i = 0; i < Protection.Length; i++)
            {
                if (Protection[i] != 0)
                {
                    stream.Write(Protection[i]);
                }
            }

            if (DamageType != Enumeration.DamageTypes.DAM_INVALID)
            {
                stream.Write((byte)DamageType);
            }
            if (TotalDamage != 0)
            {
                stream.Write(TotalDamage);
            }

            for (int i = 0; i < Damages.Length; i++)
            {
                if (Damages[i] != 0)
                {
                    stream.Write(Damages[i]);
                }
            }

            if (Range != 0)
            {
                stream.Write(Range);
            }

            for (int i = 0; i < this.ConditionAttributes.Length; i++)
            {
                if (ConditionAttributes[i] != 0)
                {
                    stream.Write(ConditionAttributes[i]);
                }
            }
            for (int i = 0; i < this.ConditionValues.Length; i++)
            {
                if (ConditionValues[i] != 0)
                {
                    stream.Write(ConditionValues[i]);
                }
            }

            if (Value != 0)
            {
                stream.Write(Value);
            }

            if (MainFlags != 0)
            {
                stream.Write((int)MainFlags);
            }

            if (Flags != 0)
            {
                stream.Write((int)Flags);
            }

            if (Wear != 0)
            {
                stream.Write((byte)Wear);
            }
            if (Materials != 0)
            {
                stream.Write((byte)Materials);
            }

            if (Description.Length > 0)
            {
                stream.Write(Description);
            }

            for (int i = 0; i < this.Text.Length; i++)
            {
                if (Text[i].Length > 0)
                {
                    stream.Write(Text[i]);
                }
            }
            for (int i = 0; i < this.Count.Length; i++)
            {
                if (Count[i] != 0)
                {
                    stream.Write(Count[i]);
                }
            }

            if (Visual.Length > 0)
            {
                stream.Write(Visual);
            }
            if (Visual_Change.Length > 0)
            {
                stream.Write(Visual_Change);
            }
            if (Effect.Length > 0)
            {
                stream.Write(Effect);
            }

            if (Visual_skin != 0)
            {
                stream.Write(Visual_skin);
            }
            if (munition != null)
            {
                stream.Write(munition.ID);
            }
            if (isKeyInstance)
            {
                stream.Write(isKeyInstance);
            }
            if (Spell != null)
            {
                stream.Write(Spell.ID);
            }
            if (isTorch)
            {
                stream.Write(isTorch);
            }
            if (isTorchBurning)
            {
                stream.Write(isTorchBurning);
            }
            if (isTorchBurned)
            {
                stream.Write(isTorchBurned);
            }
            if (isGold)
            {
                stream.Write(isGold);
            }
        }
        public void Write(BitStream stream)
        {
            stream.Write(this.id);
            stream.Write(this.Name);
            stream.Write(this.FXName);
            stream.Write(this.AniName);

            stream.Write(processMana.Length);
            for (int i = 0; i < processMana.Length; i++)
            {
                stream.Write(processMana[i]);
            }

            SpellParameters paramI = getParams();

            BitStreamExtension.Write(stream, (ushort)paramI);

            if (paramI.HasFlag(SpellParameters.TimePerMana))
            {
                stream.Write(this.TimePerMana);
            }
            if (paramI.HasFlag(SpellParameters.DamagePerLevel))
            {
                stream.Write(this.DamagePerLevel);
            }
            if (paramI.HasFlag(SpellParameters.DamageType))
            {
                stream.Write((byte)DamageType);
            }
            if (paramI.HasFlag(SpellParameters.SpellType))
            {
                stream.Write((byte)SpellType);
            }
            if (paramI.HasFlag(SpellParameters.CanTurnDuringInvest))
            {
                stream.Write(this.CanTurnDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.CanChangeTargetDuringInvest))
            {
                stream.Write(this.CanChangeTargetDuringInvest);
            }
            if (paramI.HasFlag(SpellParameters.isMultiEffect))
            {
                stream.Write(this.isMultiEffect);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectionAlgo))
            {
                stream.Write((byte)TargetCollectionAlgo);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectType))
            {
                stream.Write((byte)TargetCollectType);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectRange))
            {
                stream.Write(this.TargetCollectRange);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectAzi))
            {
                stream.Write(this.TargetCollectAzi);
            }
            if (paramI.HasFlag(SpellParameters.TargetCollectElev))
            {
                stream.Write(this.TargetCollectElev);
            }
        }