예제 #1
0
        public void SetNodeBool(bool kg)
        {
            PropsCacheItem parent = this.ParentPropsCacheItem;

            lock (this)
            {
                if (this.nowkg != kg)
                {
                    if (this.nowkg)
                    {
                        for (int i = 0; i < 177; i++)
                        {
                            if (this.ExtProps[i] != 0.0)
                            {
                                parent.SetExtProp(i, parent.ExtProps[i] - this.ExtProps[i]);
                            }
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            if (this.BaseProps[i] != 0.0)
                            {
                                parent.SetBaseProp(i, parent.BaseProps[i] - this.BaseProps[i]);
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < 177; i++)
                        {
                            if (this.ExtProps[i] != 0.0)
                            {
                                parent.SetExtProp(i, parent.ExtProps[i] + this.ExtProps[i]);
                            }
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            if (this.BaseProps[i] != 0.0)
                            {
                                parent.SetBaseProp(i, parent.BaseProps[i] + this.BaseProps[i]);
                            }
                        }
                    }
                }
                this.nowkg = kg;
            }
        }
예제 #2
0
        /// <summary>
        /// 设置扩展属性的值(数组)
        /// </summary>
        /// <param name="args">系统类型(int),子系统类型(int),...,属性值数组(double[])</param>
        public void SetExtProps(params object[] args)
        {
            PropsCacheItem parent = PropsCacheRoot;

            PropsCacheItem child = null;

            double[] props       = null;
            object   propsObject = null;

            try
            {
                if (args.Length > 1)
                {
                    propsObject = args[args.Length - 1];
                    EquipPropItem equipPropItem = propsObject as EquipPropItem;
                    if (null != equipPropItem)
                    {
                        props = equipPropItem.ExtProps;
                    }
                    else
                    {
                        props = args[args.Length - 1] as double[];
                    }
                }

                lock (PropsCacheRoot)
                {
                    foreach (var obj in args)
                    {
                        if (obj == propsObject)
                        {
                            if (child != null)
                            {
                                Contract.Assert(child.SubPropsItemDict.Count == 0, "only leaf node can set props!");
                                if (null != props)
                                {
                                    for (int i = 0; i < (int)ExtPropIndexes.Max && i < props.Length; i++)
                                    {
                                        child.SetExtProp(i, props[i]);
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < (int)ExtPropIndexes.Max; i++)
                                    {
                                        child.SetExtProp(i, 0);
                                    }
                                }
                            }

                            break;
                        }
                        else
                        {
                            if (!parent.SubPropsItemDict.TryGetValue((int)obj, out child))
                            {
                                child = new PropsCacheItem(parent, Convert.ToInt32(obj));
                                parent.SubPropsItemDict.Add((int)obj, child);
                            }

                            parent = child;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogManager.WriteException(ex.ToString());
            }
        }