Exemplo n.º 1
0
 private static void Serialize(this SerializingContainer2 sc, LightMap_2D lmap)
 {
     sc.Serialize(ref lmap.LightGuids, SCExt.Serialize);
     sc.Serialize(ref lmap.Texture1);
     sc.Serialize(ref lmap.ScaleVector1);
     sc.Serialize(ref lmap.Texture2);
     sc.Serialize(ref lmap.ScaleVector2);
     sc.Serialize(ref lmap.Texture3);
     sc.Serialize(ref lmap.ScaleVector3);
     if (sc.Game < MEGame.ME3)
     {
         sc.Serialize(ref lmap.Texture4);
         sc.Serialize(ref lmap.ScaleVector4);
     }
     else if (sc.IsLoading)
     {
         lmap.Texture4 = new UIndex(0);
     }
     sc.Serialize(ref lmap.CoordinateScale);
     sc.Serialize(ref lmap.CoordinateBias);
 }
Exemplo n.º 2
0
        public static void Serialize(this SerializingContainer2 sc, ref LightMap lmap)
        {
            if (sc.IsLoading)
            {
                var type = (ELightMapType)sc.ms.ReadInt32();
                switch (type)
                {
                case ELightMapType.LMT_None:
                    lmap = new LightMap();
                    break;

                case ELightMapType.LMT_1D:
                    lmap = new LightMap_1D();
                    break;

                case ELightMapType.LMT_2D:
                    lmap = new LightMap_2D();
                    break;

                case ELightMapType.LMT_3:
                    lmap = new LightMap_3();
                    break;

                case ELightMapType.LMT_4:
                case ELightMapType.LMT_6:
                    lmap = new LightMap_4or6();
                    break;

                case ELightMapType.LMT_5:
                    lmap = new LightMap_5();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                lmap.LightMapType = type;
            }
            else
            {
                if (sc.Game != MEGame.ME3 && lmap.LightMapType > ELightMapType.LMT_2D)
                {
                    lmap = new LightMap();
                }
                sc.ms.Writer.WriteInt32((int)lmap.LightMapType);
            }

            switch (lmap.LightMapType)
            {
            case ELightMapType.LMT_None:
                break;

            case ELightMapType.LMT_1D:
                sc.Serialize((LightMap_1D)lmap);
                break;

            case ELightMapType.LMT_2D:
                sc.Serialize((LightMap_2D)lmap);
                break;

            case ELightMapType.LMT_3:
                sc.Serialize((LightMap_3)lmap);
                break;

            case ELightMapType.LMT_4:
            case ELightMapType.LMT_6:
                sc.Serialize((LightMap_4or6)lmap);
                break;

            case ELightMapType.LMT_5:
                sc.Serialize((LightMap_5)lmap);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }