Example #1
0
    public void SaveFieldMap()
    {
        BGSCENE_DEF scene = this.fieldMap.scene;

        Byte[] ebgBin          = scene.ebgBin;
        String mapName         = this.fieldMap.mapName;
        String fieldMapModName = FieldMapEditor.GetFieldMapModName(mapName);
        String mapResourcePath = FieldMap.GetMapResourcePath(mapName);

        using (BinaryWriter binaryWriter = new BinaryWriter(new MemoryStream(ebgBin)))
        {
            for (Int32 i = 0; i < (Int32)scene.overlayCount; i++)
            {
                BGOVERLAY_DEF bgoverlay_DEF = scene.overlayList[i];
                UInt32        oriData       = bgoverlay_DEF.oriData;
                UInt16        num           = (UInt16)bgoverlay_DEF.transform.localPosition.z;
                UInt16        num2          = (UInt16)(oriData >> 8 & 4095u);
                UInt32        num3          = oriData;
                UInt32        num4          = 1048320u;
                num3 &= ~num4;
                num3 |= (UInt32)((Int64)((Int64)num << 8) & (Int64)((UInt64)num4));
                global::Debug.Log(String.Concat(new Object[]
                {
                    i,
                    " : data  :",
                    oriData,
                    ", curZ : ",
                    num,
                    ", oriZ : ",
                    num2,
                    ", res : ",
                    num3
                }));
                binaryWriter.BaseStream.Seek(bgoverlay_DEF.startOffset, SeekOrigin.Begin);
                binaryWriter.Write(num3);
            }
        }
        String path = "Assets/Resources/" + mapResourcePath + fieldMapModName + ".bgs.bytes";

        File.WriteAllBytes(path, ebgBin);
    }
Example #2
0
    public void LoadEBG(FieldMap fieldMap, String path, String newName)
    {
        this.name = newName;
        if (!this.useUpscaleFM)
        {
            this.InitPSXTextureAtlas();
        }
        else
        {
            Texture2D x = AssetManager.Load <Texture2D>(Path.Combine(path, "atlas"), false);
            if (x != null)
            {
                this.atlas = x;
                if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor)
                {
                    this.atlasAlpha = AssetManager.Load <Texture2D>(Path.Combine(path, "atlas_a"), false);
                }
                else
                {
                    this.atlasAlpha = null;
                }
                this.SPRITE_W = 32u;
                this.SPRITE_H = 32u;
            }
            else
            {
                this.useUpscaleFM = false;
                this.InitPSXTextureAtlas();
            }
        }
        if (!this.useUpscaleFM)
        {
            this.vram.LoadTIMs(path);
        }
        TextAsset textAsset;

        if (!FieldMapEditor.useOriginalVersion)
        {
            textAsset = AssetManager.Load <TextAsset>(path + FieldMapEditor.GetFieldMapModName(newName) + ".bgs", false);
            if (textAsset == null)
            {
                Debug.Log("Cannot find MOD version.");
                textAsset = AssetManager.Load <TextAsset>(path + newName + ".bgs", false);
            }
        }
        else
        {
            textAsset = AssetManager.Load <TextAsset>(path + newName + ".bgs", false);
        }

        if (textAsset == null)
        {
            return;
        }

        this.ebgBin = textAsset.bytes;
        using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(this.ebgBin)))
        {
            this.ReadData(binaryReader);
        }
        String symbol = Localization.GetSymbol();

        if (symbol != "US")
        {
            FieldMapLocalizeAreaTitleInfo info = FieldMapInfo.localizeAreaTitle.GetInfo(newName);
            if (info != null)
            {
                if (symbol != "UK" || info.hasUK)
                {
                    BGSCENE_DEF bGSCENE_DEF = new BGSCENE_DEF(this.useUpscaleFM);
                    bGSCENE_DEF._LoadDummyEBG(this, path, newName, info, symbol);
                }
            }
        }
        FieldMapInfo.fieldmapExtraOffset.SetOffset(newName, this.overlayList);
        if (!this.useUpscaleFM)
        {
            this.GenerateAtlasFromBinary();
        }

        this.CreateMaterials();
        if (fieldMap != null)
        {
            this.CreateScene(fieldMap, this.useUpscaleFM);
        }
    }