Пример #1
0
    public void StartEvents(Byte[] ebFileData)
    {
        EventEngine.resyncBGMSignal = 0;
        //Debug.Log("Reset resyncBGMSignal = " + (object)EventEngine.resyncBGMSignal);
        this._ff9 = FF9StateSystem.Common.FF9;
        this._ff9.charArray.Clear();
        this._ff9Sys = PersistenSingleton <FF9StateSystem> .Instance;
        BinaryReader br = new BinaryReader(new MemoryStream(ebFileData));

        this.SetupCodeParam(br);
        this._ff9.mapNameStr = FF9TextTool.LocationName(this._ff9.fldMapNo);
        this._defaultMapName = this._ff9.mapNameStr;
        switch (this._ff9Sys.mode)
        {
        case 1:
            this.gMode = 1;
            break;

        case 2:
            this.gMode = 2;
            break;

        case 3:
            this.gMode = 3;
            UIManager.World.EnableMapButton = true;
            break;

        case 8:
            this.gMode = 4;
            break;
        }
        EventInput.IsProcessingInput = this.gMode != 2 && this.gMode != 4;
        EMinigame.GetTheAirShipAchievement();
        EMinigame.GetHelpAllVictimsInCleyraTown();
        TimerUI.SetEnable(this._ff9.timerDisplay);
        TimerUI.SetDisplay(this._ff9.timerDisplay);
        TimerUI.SetPlay(this._ff9.timerControl);
        this.allObjsEBData = new Byte[this.sSourceObjN][];
        this.toBeAddedObjUIDList.Clear();
        for (Int32 index = 0; index < this.sSourceObjN; ++index)
        {
            br.BaseStream.Seek(128L, SeekOrigin.Begin);
            Int32 num   = (Int32)this.sObjTable[index].ofs;
            Int32 count = (Int32)this.sObjTable[index].size;
            br.BaseStream.Seek((Int64)num, SeekOrigin.Current);
            this.allObjsEBData[index] = br.ReadBytes(count);
            //if (count < 4)
            //;
        }
        if ((this.sEventContext0.inited == 1 || this.sEventContext0.inited == 3) && this.gMode == 2)
        {
            this.sEventContext1.copy(this.sEventContext0);
        }
        this._context = this.sEventContext0;
        this.InitMP();
        this.InitObj();
        EventInput.IsProcessingInput = true;
        EIcon.InitFIcon();
        EIcon.SetAIcon(0);
        for (Int32 index = 0; index < 80; ++index)
        {
            this._context.mapvar[index] = 0;
        }
        this._context.usercontrol = 0;
        this._context.controlUID  = 0;
        this._context.idletimer   = 0;
        EIcon.SetHereIcon(0);
        this.gStopObj         = null;
        this._context.dashinh = 0;
        this._context.twist_a = 0;
        this._context.twist_d = 0;
        this.eTb.gMesCount    = this.gAnimCount = 10;
        this._noEvents        = false;
        this.InitEncount();
        NewThread(0, 0);
        this._context.activeObj.obj.state = EventEngine.stateInit;
        this.SetupPartyUID();
        for (Int32 index = 0; index < 8; ++index)
        {
            this._objPtrList[index] = null;
        }
        this._opLStart = 0;
        if (this.gMode == 2)
        {
            for (Int32 index = 0; index < 4; ++index)
            {
                Int32 partyMember = this.eTb.GetPartyMember(index);
                if (partyMember >= 0)
                {
                    Actor actor = new Actor(this.sSourceObjN - 9 + partyMember, 0, EventEngine.sizeOfActor);
                }
            }
            this._context.partyObjTail = this._context.activeObjTail;
        }
        else
        {
            this._ff9.btl_rain = 0;
        }
        this._opLStart = 4;
        if (this.gMode == 1 && this.sEventContext1.inited == 1 && this.sEventContext1.lastmap == this._ff9.fldMapNo || this.gMode == 3 && this.sEventContext1.inited == 3 && this.sEventContext1.lastmap == this._ff9.wldMapNo || this._ff9Sys.prevMode == 9 && this.sEventContext1.inited != 0)
        {
            this.sEventContext0.copy(this.sEventContext1);
            this.Request(this.FindObjByUID(0), 0, 10, false);
            this.EnterBattleEnd();
        }
        else
        {
            if (this.gMode != 2 && this.gMode != 4)
            {
                Boolean flag1 = this._ff9.fldMapNo == 70;
                Boolean flag2 = this._ff9.fldMapNo == 2200 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 9450 && this.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 9999;
                Boolean flag3 = this._ff9.fldMapNo == 150 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 1155 && this.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 325;
                Boolean flag4 = this._ff9.fldMapNo == 1251 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 5400;
                Boolean flag5 = this._ff9.fldMapNo == 1602 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 6645 && this.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 16;
                Boolean flag6 = this._ff9.fldMapNo == 1757 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 6740;
                Boolean flag7 = this._ff9.fldMapNo == 2752 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 11100 && this.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 9999;
                Boolean flag8 = this._ff9.fldMapNo == 3001 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 12000 && this.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 0;
                Boolean flag9 = this._ff9.fldMapNo == 2161 && this.eBin.getVarManually(EBin.SC_COUNTER_SVR) == 10000 && this.eBin.getVarManually(EBin.MAP_INDEX_SVR) == 32;
                if (!flag1 && !flag4 && (!flag5 && !flag6) && (!flag3 && !flag2 && (!flag7 && !flag8)) && !flag9)
                {
                    FF9StateSystem.Settings.UpdateTickTime();
                    ISharedDataSerializer serializer = FF9StateSystem.Serializer;
                    serializer.Autosave(null, (e, s) => { });
                }
            }
            this.ProcessEvents();
        }
        this._context.inited  = (Byte)this.gMode;
        this._context.lastmap = this.gMode != 1 ? (this.gMode != 3 ? (UInt16)0 : (UInt16)this._ff9.wldMapNo) : (UInt16)this._ff9.fldMapNo;
        br.Close();

        SpawnCustomChatacters();

        PersistenSingleton <CheatingManager> .Instance.ApplyDataWhenEventStart();
    }