Exemple #1
0
        public static Rectangle operator -(Rectangle rectangle, Vector2 vector)
        {
            Rectangle clone = CloneUtil.CloneDeep(rectangle);

            clone.AddWorldOffset(-vector);
            return(clone);
        }
Exemple #2
0
        public static Circle3D operator -(Circle3D circle, Vector3 vector)
        {
            Circle3D clone = CloneUtil.CloneDeep(circle);

            clone.AddWorldOffset(-vector);
            return(clone);
        }
Exemple #3
0
        public static Rectangle3D operator +(Rectangle3D rectangle, Vector3 vector)
        {
            Rectangle3D clone = CloneUtil.CloneDeep(rectangle);

            clone.AddWorldOffset(vector);
            return(clone);
        }
Exemple #4
0
        public static Polygon3D operator -(Polygon3D polygon, Vector3 vector)
        {
            Polygon3D clone = CloneUtil.CloneDeep(polygon);

            clone.AddWorldOffset(-vector);
            return(clone);
        }
Exemple #5
0
        public static Sphere3D operator -(Sphere3D sphere, Vector3 vector)
        {
            Sphere3D clone = CloneUtil.CloneDeep(sphere);

            clone.AddWorldOffset(-vector);
            return(clone);
        }
Exemple #6
0
        public static Triangle3D operator +(Triangle3D triangle, Vector3 vector)
        {
            Triangle3D clone = CloneUtil.CloneDeep(triangle);

            clone.AddWorldOffset(vector);
            return(clone);
        }
Exemple #7
0
        public static Cube3D operator +(Cube3D cube, Vector3 vector)
        {
            Cube3D clone = CloneUtil.CloneDeep(cube);

            clone.AddWorldOffset(vector);
            return(clone);
        }
Exemple #8
0
        public static Triangle operator -(Triangle triangle, Vector2 vector)
        {
            Triangle clone = CloneUtil.CloneDeep(triangle);

            clone.AddWorldOffset(-vector);
            return(clone);
        }
Exemple #9
0
        public static Polygon operator +(Polygon polygon, Vector2 vector)
        {
            Polygon clone = CloneUtil.CloneDeep(polygon);

            clone.AddWorldOffset(vector);
            return(clone);
        }
Exemple #10
0
        public static Line operator -(Line line, Vector2 vector)
        {
            Line clone = CloneUtil.CloneDeep(line);

            clone.AddWorldOffset(-vector);
            return(clone);
        }
Exemple #11
0
        public static Line3D operator +(Line3D line, Vector3 vector)
        {
            Line3D clone = CloneUtil.CloneDeep(line);

            clone.AddWorldOffset(vector);
            return(clone);
        }
Exemple #12
0
        public static Circle operator +(Circle circle, Vector2 vector)
        {
            Circle clone = CloneUtil.CloneDeep(circle);

            clone.AddWorldOffset(vector);
            return(clone);
        }
Exemple #13
0
        //////////////////////////////////////////////////////////////////////
        // Diff相关
        //////////////////////////////////////////////////////////////////////
        // 必须和ApplyDiff使用
        // 以new为基准,获取new相对于old不一样的部分
        // local diff = table.GetDiff(old, new)
        //  table.ApplyDiff(old, diff)
        // 这样old的就变成和new一模一样的数据
        public static LinkedHashtable GetDiff(IDictionary oldDict, IDictionary newDict)
        {
            var diff = new LinkedHashtable();

            foreach (DictionaryEntry dictionaryEntry in newDict)
            {
                var newK = dictionaryEntry.Key;
                var newV = dictionaryEntry.Value;
                if (newV is IDictionary newVDict)
                {
                    switch (newVDict.Count)
                    {
                    case 0 when(!oldDict.Contains(newK) || oldDict[newK].GetType() != newVDict.GetType() ||
                                (oldDict[newK] is IDictionary &&
                                 ((IDictionary)oldDict[newK]).Count != 0)):
                        diff[newK] = StringConst.String_New_In_Table + newVDict.GetType();
                        break;

                    default:
                    {
                        if (oldDict.Contains(newK) && oldDict[newK] is IDictionary)
                        {
                            diff[newK] = GetDiff((IDictionary)oldDict[newK], newVDict);
                        }
                        else if (!oldDict.Contains(newK) || !newVDict.Equals(oldDict[newK]))
                        {
                            diff[newK] = CloneUtil.CloneDeep(newV);
                        }
                        break;
                    }
                    }
                }
                else if (newV is IList list && oldDict.Contains(newK) && oldDict[newK] is IList)
                {
                    diff[newK] = ListUtil.GetDiff((IList)oldDict[newK], list);
                }
Exemple #14
0
        //////////////////////////////////////////////////////////////////////
        // Diff相关
        //////////////////////////////////////////////////////////////////////
        // 必须和ApplyDiff使用
        // 以new为基准,获取new相对于old不一样的部分
        // local diff = table.GetDiff(old, new)
        //  table.ApplyDiff(old, diff)
        // 这样old的就变成和new一模一样的数据
        public static LinkedHashtable GetDiff(IList oldList, IList newList)
        {
            var diff = new LinkedHashtable();

            for (int i = newList.Count - 1; i >= 0; i--)
            {
                var newK = i;
                var newV = newList[i];
                switch (newV)
                {
                case IList _:
                {
                    var newVList = newV as IList;
                    if (newVList.Count == 0 && (!oldList.ContainsIndex(newK) ||
                                                oldList[newK].GetType() != newV.GetType() ||
                                                (oldList[newK] is IList && (oldList[newK] as IList).Count != 0)))
                    {
                        diff[newK] = StringConst.String_New_In_Table + newV.GetType();
                    }
                    else if (oldList.ContainsIndex(newK) && oldList[newK] is IList)
                    {
                        diff[newK] = GetDiff(oldList[newK] as IList, newVList);
                    }
                    else if (!oldList.ContainsIndex(newK) || !newV.Equals(oldList[newK]))
                    {
                        diff[newK] = CloneUtil.CloneDeep(newV);
                    }
                    break;
                }

                case IDictionary _ when oldList.ContainsIndex(newK) && oldList[newK] is IDictionary:
                    diff[newK] = IDictionaryUtil.GetDiff(oldList[newK] as IDictionary, newV as IDictionary);

                    break;

                default:
                {
                    if (!oldList.ContainsIndex(newK) || !newV.Equals(oldList[newK]))
                    {
                        diff[newK] = newV;
                    }
                    break;
                }
                }
            }

            for (int i = 0; i < oldList.Count; i++)
            {
                if (!newList.ContainsIndex(i))
                {
                    diff[i] = StringConst.String_Nil_In_Table;
                }
            }

            diff.Sort((a, b) => a.To <int>() >= b.To <int>());
            if (diff.Count == 0)
            {
                diff = null;
            }
            return(diff);
        }
Exemple #15
0
 public static T Clone <T>(this T self)
 {
     return(CloneUtil.Clone(self));
 }