예제 #1
0
        /// <summary>
        /// Creates a new copy of the ParamSpec.
        /// </summary>
        /// <returns>A new instance of the ParamSpec is returned.</returns>
        public object Clone()
        {
            ParamSpec p = new ParamSpec();

            p.m_strName     = m_strName;
            p.m_shareMode   = m_shareMode;
            p.m_dfDecayMult = m_dfDecayMult;
            p.m_dfLrMult    = m_dfLrMult;

            return(p);
        }
예제 #2
0
        /// <summary>
        /// Loads a ParamSpec from a binary reader.
        /// </summary>
        /// <param name="br">Specifies the binary reader to use.</param>
        /// <param name="bNewInstance">When <i>true</i>, a new ParamSpec instance is created and loaded, otherwise this instance is loaded.</param>
        /// <returns>The ParamSpec instance loaded is returned.</returns>
        public object Load(BinaryReader br, bool bNewInstance)
        {
            ParamSpec p = this;

            if (bNewInstance)
            {
                p = new ParamSpec();
            }

            p.m_strName     = br.ReadString();
            p.m_shareMode   = (DimCheckMode)br.ReadInt32();
            p.m_dfLrMult    = br.ReadDouble();
            p.m_dfDecayMult = br.ReadDouble();

            return(p);
        }
예제 #3
0
        /// <summary>
        /// Parses a new ParamSpec from a RawProto.
        /// </summary>
        /// <param name="rp">Specifies the RawProto representing the ParamSpec.</param>
        /// <returns>The new ParamSpec instance is returned.</returns>
        public static ParamSpec FromProto(RawProto rp)
        {
            string    strVal;
            ParamSpec p = new ParamSpec();

            if ((strVal = rp.FindValue("name")) != null)
            {
                p.name = strVal;
            }

            if ((strVal = rp.FindValue("share_mode")) != null)
            {
                switch (strVal)
                {
                case "STRICT":
                    p.share_mode = DimCheckMode.STRICT;
                    break;

                case "PERMISSIVE":
                    p.share_mode = DimCheckMode.PERMISSIVE;
                    break;

                default:
                    throw new Exception("Unknown 'share_mode' value: " + strVal);
                }
            }

            if ((strVal = rp.FindValue("lr_mult")) != null)
            {
                p.lr_mult = double.Parse(strVal);
            }

            if ((strVal = rp.FindValue("decay_mult")) != null)
            {
                p.decay_mult = double.Parse(strVal);
            }

            return(p);
        }