Beispiel #1
0
    public static void RemoveReceiver(GameDataType type, object instance)
    {
        List<Receiver> acts;

        if (mReceivers.TryGetValue(type, out acts))
        {
            acts.RemoveAll((item) => item.instance == instance);
        }
    }
Beispiel #2
0
 /// <summary>
 /// Create a new GameData packet.
 /// </summary>
 /// <param name="gameDataType">The type associated with this packet.</param>
 /// <param name="playerId">The id of the player that performed the action.</param>
 /// <param name="eventDetail">The extra detail associated with this event.</param>
 public GameData(GameDataType gameDataType, int playerId = 0, int eventDetail = 0, TransformData transformData = null, EntityData entityData = null)
 {
     Type = gameDataType;
     PlayerID = playerId;
     EventDetail = eventDetail;
     TransformData = transformData;
     EntityData = entityData;
     return;
 }
Beispiel #3
0
    public static void Emitter(GameDataType dataType, object currentData)
    {
        curType = dataType;
        curData = currentData;

        List<Receiver> acts;

        if (mReceivers.TryGetValue(dataType, out acts))
        {
            foreach (var act in acts)
            {
                act.method.Invoke(act.instance, null);
            }
        }
    }
Beispiel #4
0
 public DataEntry(GameDataType dataType)
 {
     this.dataType = dataType;
 }
Beispiel #5
0
 public DataReceiver(GameDataType dataType)
 {
     this.dataType = dataType;
 }
Beispiel #6
0
        static void HandleGameData(HazelBinaryReader reader, GameDataType datatype, bool send)
        {
            var dir = send ? "SEND" : "RECV";

            switch (datatype)
            {
            case GameDataType.RpcCall:
                var RPC     = RpcCall.Deserialize(reader);
                var reciver = EntityTracker.Get(RPC.targetNetId);
                if (LogRPC)
                {
                    Console.WriteLine($"[RPC][{RPC.callId}]sent to {reciver?.GetType()?.Name ?? "unknown"} size: {reader.GetBytesLeft()}");
                }
                if (reciver != null)
                {
                    reciver.HandleRpcCall(RPC.callId, reader);
                }
                //DumpToConsole(RPC, LogRPC);
                //Console.WriteLine($"RPC for type: {RPC} size: {data.body.Length}");
                switch (RPC.callId)
                {
                case RpcCalls.CheckColor:
                    var CheckColor = CmdCheckColor.Deserialize(reader);
                    DumpToConsole(CheckColor, LogRPC);
                    break;

                case RpcCalls.CheckName:
                    var CheckName = CmdCheckName.Deserialize(reader);
                    DumpToConsole(CheckName, LogRPC);
                    break;

                case RpcCalls.CloseDoorsOfType:
                    var CloseDoorsOfType = RpcCloseDoorsOfType.Deserialize(reader);
                    DumpToConsole(CloseDoorsOfType, LogRPC);
                    break;

                case RpcCalls.EnterVent:
                    var EnterVent = RpcEnterVent.Deserialize(reader);
                    DumpToConsole(EnterVent, LogRPC);
                    break;

                case RpcCalls.ExitVent:
                    var ExitVent = RpcExitVent.Deserialize(reader);
                    DumpToConsole(ExitVent, LogRPC);
                    break;

                case RpcCalls.Exiled:
                    var exileid = reader.ReadPackedInt32();
                    Console.WriteLine("Exile id: " + exileid);
                    break;

                case RpcCalls.SendChat:
                    var chat = RpcSendChat.Deserialize(reader);
                    LogChatToConsole(RPC.targetNetId.ToString(), chat.text);
                    break;

                case RpcCalls.SendChatNote:
                    var chatnote = RpcSendChatNote.Deserialize(reader);
                    LogChatToConsole("server", "SendChatNote");
                    break;

                case RpcCalls.SetColor:
                    var SetColor = RpcSetColor.Deserialize(reader);
                    DumpToConsole(SetColor, LogRPC);
                    break;

                case RpcCalls.SetSkin:
                    var skin = RpcSetSkin.Deserialize(reader);
                    DumpToConsole(skin, LogRPC);
                    break;

                case RpcCalls.SetHat:
                    var hat = RpcSetHat.Deserialize(reader);
                    Console.WriteLine($"Set hat: [{(int)hat.hatId}]{hat.hatId}");
                    break;

                case RpcCalls.SetPet:
                    var setpet = RpcSetPet.Deserialize(reader);
                    DumpToConsole(setpet, LogRPC);
                    break;

                case RpcCalls.SetName:
                    var setname = RpcSetName.Deserialize(reader);
                    DumpToConsole(setname, LogRPC);
                    break;

                case RpcCalls.SetTasks:
                    var SetTasks = RpcSetTasks.Deserialize(reader);
                    DumpToConsole(SetTasks, LogRPC);
                    break;

                case RpcCalls.SetInfected:
                    var infected = RpcSetInfected.Deserialize(reader);
                    DumpToConsole(infected);
                    break;

                case RpcCalls.SetScanner:
                    var SetScanner = RpcSetScanner.Deserialize(reader);
                    DumpToConsole(SetScanner, LogRPC);
                    break;

                case RpcCalls.AddVote:
                    var addvote = RpcAddVote.Deserialize(reader);
                    DumpToConsole(addvote, LogRPC);
                    break;

                case RpcCalls.PlayAnimation:
                    var anim = RpcPlayAnimation.Deserialize(reader);
                    DumpToConsole(anim, LogRPC);
                    break;

                case RpcCalls.CastVote:
                    var castvote = CmdCastVote.Deserialize(reader);
                    DumpToConsole(castvote, LogRPC);
                    break;

                case RpcCalls.CompleteTask:
                    var complete = RpcCompleteTask.Deserialize(reader);
                    DumpToConsole(complete, LogRPC);
                    break;

                case RpcCalls.MurderPlayer:
                    var MurderPlayer = RpcMurderPlayer.Deserialize(reader);
                    var player       = EntityTracker.Get(MurderPlayer.netId);
                    DumpToConsole(MurderPlayer, LogRPC);
                    break;

                case RpcCalls.RepairSystem:
                    var RepairSystem = RpcRepairSystem.Deserialize(reader);
                    DumpToConsole(RepairSystem, LogRPC);
                    break;

                case RpcCalls.ReportDeadBody:
                    var ReportDeadBody = CmdReportDeadBody.Deserialize(reader);
                    DumpToConsole(ReportDeadBody, LogRPC);
                    break;

                case RpcCalls.SnapTo:
                    var SnapTo = RpcSnapTo.Deserialize(reader);
                    DumpToConsole(SnapTo, LogRPC);
                    break;

                case RpcCalls.StartMeeting:
                    var StartMeeting = RpcStartMeeting.Deserialize(reader);
                    DumpToConsole(StartMeeting, LogRPC);
                    break;

                case RpcCalls.VotingComplete:
                    var VotingComplete = RpcVotingComplete.Deserialize(reader);
                    DumpToConsole(VotingComplete, LogRPC);
                    break;

                case RpcCalls.SetStartCounter:
                    var startcounter = RpcSetStartCounter.Deserialize(reader);
                    DumpToConsole(startcounter, LogRPC);
                    break;

                case RpcCalls.SyncSettings:
                    var syncsettings = RpcSyncSettings.Deserialize(reader);
                    DumpToConsole(syncsettings, LogRPC);
                    break;

                //Dont have a message body
                case RpcCalls.Close:
                    break;

                //ComponentSpecific - it contains diffrent data depending on what component it's inteded for
                case RpcCalls.UpdateGameData:
                    var update = RpcUpdateGameData.Deserialize(reader);
                    DumpToConsole(update, LogRPC);
                    break;

                default:
                    Console.WriteLine($"Unhandled RPC command: " + RPC.callId);
                    break;
                }
                if (reader.GetBytesLeft() > 0 && LogNotConsumed)
                {
                    Console.WriteLine($"[{RPC.callId}]{reader.GetBytesLeft()} bytes not cunsumed");
                    reader.ReadBytesToEnd();
                }
                break;

            case GameDataType.Data:
                var            data = Data.Deserialize(reader);
                InnerNetObject entity;
                if (!EntityTracker.entities.TryGetValue(data.netId, out entity))
                {
                    Console.WriteLine($"Entity missing for id: {data.netId} size: {data.data.Length}");
                    return;
                }
                if (!(entity is CustomNetworkTransform))
                {
                    Console.WriteLine($"Recived Data for: {entity.GetType().Name} size: {data.data.Length}");
                }

                entity.Deserialize(new HazelBinaryReader(data.data), false);

                if (LogMoves && entity is CustomNetworkTransform move)
                {
                    Console.WriteLine($"[{dir}]Move command player: {move.OwnerId:0000} seq: {move.seq:0000} pos: {move.position} delta: {move.velocity}");
                }

                break;

            case GameDataType.Spawn:
                var spawn = Spawn.Deserialize(reader);
                Console.WriteLine("Spawning: " + spawn.spawnId);
                switch (spawn.spawnId)
                {
                case 0:
                    var shipStatus = new ShipStatus();
                    shipStatus.OwnerId = spawn.ownerId;
                    shipStatus.NetId   = spawn.children[0].netId;
                    shipStatus.Deserialize(new HazelBinaryReader(spawn.children[0].body), true);
                    EntityTracker.Add(shipStatus);
                    break;

                case 1:
                    var meeting = new MeetingHud();
                    meeting.OwnerId = spawn.ownerId;
                    meeting.NetId   = spawn.children[0].netId;
                    meeting.Deserialize(new HazelBinaryReader(spawn.children[0].body), true);
                    EntityTracker.Add(meeting);
                    break;

                case 2:
                    var lobby = new LobbyBehaviour();
                    lobby.OwnerId = spawn.ownerId;
                    lobby.NetId   = spawn.children[0].netId;
                    EntityTracker.Add(lobby);
                    break;

                case 3:
                    var gdc = new GameDataComponent();
                    gdc.OwnerId = spawn.ownerId;
                    gdc.NetId   = spawn.children[0].netId;
                    gdc.Deserialize(new HazelBinaryReader(spawn.children[0].body), true);
                    EntityTracker.Add(gdc);

                    var dummy2 = new DummyComponent();
                    dummy2.name    = "gamedata.dummy1";
                    dummy2.OwnerId = spawn.ownerId;
                    dummy2.NetId   = spawn.children[1].netId;
                    dummy2.Deserialize(new HazelBinaryReader(spawn.children[1].body), true);
                    EntityTracker.Add(dummy2);
                    break;

                case 4:        //player character
                    var player = new PlayerControl();
                    player.OwnerId = spawn.ownerId;
                    player.NetId   = spawn.children[0].netId;
                    player.Deserialize(new HazelBinaryReader(spawn.children[0].body), true);
                    EntityTracker.Add(player);

                    player.dummy1         = new DummyComponent();
                    player.dummy1.name    = "player.dummy1";
                    player.dummy1.OwnerId = spawn.ownerId;
                    player.dummy1.NetId   = spawn.children[1].netId;
                    player.dummy1.Deserialize(new HazelBinaryReader(spawn.children[1].body), true);
                    EntityTracker.Add(player.dummy1);

                    player.transform         = new CustomNetworkTransform();
                    player.transform.OwnerId = spawn.ownerId;
                    player.transform.NetId   = spawn.children[2].netId;
                    player.transform.Deserialize(new HazelBinaryReader(spawn.children[2].body), true);
                    EntityTracker.Add(player.transform);
                    DumpToConsole(player);
                    break;

                case 5:        //HeadQuarters
                    var hq = new ShipStatus();
                    hq.OwnerId = spawn.ownerId;
                    hq.NetId   = spawn.children[0].netId;
                    hq.Deserialize(new HazelBinaryReader(spawn.children[0].body), true);
                    EntityTracker.Add(hq);
                    break;

                case 6:        //PlanetMap
                    var polus = new ShipStatus();
                    polus.OwnerId = spawn.ownerId;
                    polus.NetId   = spawn.children[0].netId;
                    polus.Deserialize(new HazelBinaryReader(spawn.children[0].body), true);
                    EntityTracker.Add(polus);
                    break;

                case 7:        //AprilShipStatus
                default:
                    Console.WriteLine($"Unhandled spawnid: {spawn.spawnId}");
                    break;
                }
                break;

            case GameDataType.SceneChange:
                var scene = SceneChange.Deserialize(reader);
                if (scene.sceneName == "OnlineGame")
                {
                    //Starting game
                }
                DumpToConsole(scene);
                break;

            case GameDataType.Despawn:
                var despawn = Despawn.Deserialize(reader);
                EntityTracker.entities.Remove(despawn.netId);
                LogToConsole("Despawn Netid: " + despawn.netId);
                break;

            case GameDataType.Ready:
                var ready = Ready.Deserialize(reader);
                Console.WriteLine($"Ready: " + ready.playerId);
                break;

            case GameDataType.ChangeSettings:
                var changesettings = ChangeSettings.Deserialize(reader);
                DumpToConsole(changesettings);
                break;

            default:
                Console.WriteLine($"Unhandled Gamedatatype: {datatype}");
                break;
            }

            if (reader.GetBytesLeft() > 0 && LogNotConsumed)
            {
                Console.WriteLine($"[{datatype}]{reader.GetBytesLeft()} bytes not cunsumed");
                reader.ReadBytesToEnd();
            }
        }
Beispiel #7
0
        /// <summary>
        /// 根据数据名称释放数据资源
        /// </summary>
        /// <param name="type">Type.</param>
        private void ReleaseDataWithName(GameDataType type)
        {
            switch (type)
            {
            case GameDataType.GameSettings:
                mGameSettings = null;
                break;

            case GameDataType.GameLevelDatas:
                mGameLevelDatas.Clear();
                break;

            case GameDataType.EquipmentModels:
                mAllEquipmentModels.Clear();
                break;

            case GameDataType.ConsumablesModels:
                mAllConsumablesModels.Clear();
                break;

            case GameDataType.SkillGemstoneModels:
                mAllPropertyGemstoneModels.Clear();
                break;

            case GameDataType.SpecialItemModels:
                mAllSpecialItemModels.Clear();
                break;

            case GameDataType.SpellItemModels:
                mAllSpellItemModels.Clear();
                break;

            case GameDataType.SkillScrollModels:
                mAllSkillScrollModels.Clear();
                break;

            case GameDataType.EquipmentSprites:
                mAllEquipmentSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allEquipmentSpritesBundleName, true);
                break;

            case GameDataType.ConsumablesSprites:
                mAllConsumablesSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allConsumablesSpritesBundleName, true);
                break;

            case GameDataType.SkillGemstoneSprites:
                mAllPropertyGemstoneSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allPropertyGemstoneSpritesBundleName, true);
                break;

            case GameDataType.SpecialItemSprites:
                mAllSpecialItemSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allSpecialItemSpritesBundleName, true);
                break;

            case GameDataType.SkillScrollSprites:
                mAllSkillScrollSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allSkillScrollSpritesBundleName, true);
                break;

            case GameDataType.MapSprites:
                mAllMapSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allMapSpritesBundleName, true);
                break;

            case GameDataType.MapTileAtlas:
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.mapTileset_1_BundleName, true);
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.mapTileset_2_BundleName, true);
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.mapTileset_3_BundleName, true);
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.mapTileset_4_BundleName, true);
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.mapTileset_5_BundleName, true);
                break;

            case GameDataType.CharacterSprites:
                mAllCharacterSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allCharacterSpritesBundleName, true);
                break;

            case GameDataType.Skills:
                mAllSkills.Clear();
                TransformManager.DestroyTransfromWithName("AllSkills");
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allSkillsBundleName, true);
                break;

            case GameDataType.SkillSprites:
                mAllSkillSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allSkillSpritesBundleName, true);
                break;

            case GameDataType.MiniMapSprites:
                mAllMinimapSprites.Clear();
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allMinimapSpritesBundleName, true);
                break;

            case GameDataType.Monsters:
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allMonstersBundleName, true);
                break;

            case GameDataType.MonstersUI:
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allMonstersUIBundleName, true);
                break;

            case GameDataType.MonstersData:
                mAllMonstersData.Clear();
                break;

            case GameDataType.NPCs:
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allMapNpcBundleName, true);
                break;

            case GameDataType.Effects:
                mAllEffects.Clear();
                TransformManager.DestroyTransfromWithName("AllEffects");
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.allEffectsBundleName, true);
                break;

            case GameDataType.Diary:
                mAllDiaryModels.Clear();
                break;

            case GameDataType.Proverbs:
                mAllProverbs.Clear();
                break;

            case GameDataType.Puzzle:
                mAllPuzzles.Clear();
                break;

            case GameDataType.PlayRecord:
                mAllPlayRecords.Clear();
                break;

            case GameDataType.ChatRecord:
                mChatRecords.Clear();
                break;

            case GameDataType.CurrentMapMiniMapRecord:
                mCurrentMapMiniMapRecord = null;
                break;

            case GameDataType.MapEventsRecords:
                mMapEventsRecords.Clear();
                break;

            case GameDataType.CurrentMapEventsRecord:
                mCurrentMapEventsRecord = null;
                break;

            case GameDataType.CurrentMapWordsRecord:
                mCurrentMapWordRecords.Clear();
                break;

            case GameDataType.BagCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("BagCanvas");
                break;

            case GameDataType.SettingCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("SettingCanvas");
                break;

            case GameDataType.ShareCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("ShareCanvas");
                break;

            case GameDataType.NPCCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("NPCCanvas");
                break;

            case GameDataType.LoadingCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("LoadingCanvas");
                break;

            case GameDataType.GuideCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("GuideCanvas");
                break;

            case GameDataType.RecordCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("RecordCanvas");
                break;

            case GameDataType.HomeCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("HomeCanvas");
                break;

            case GameDataType.ExploreScene:
                GameManager.Instance.UIManager.RemoveCanvasCache("ExploreCanvas");
                MyResourceManager.Instance.UnloadAssetBundle(CommonData.exploreSceneBundleName, true);
                break;

            case GameDataType.PlayRecordCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("PlayRecordCanvas");
                break;

            case GameDataType.UpdateDataCanvas:
                GameManager.Instance.UIManager.RemoveCanvasCache("UpdateDataCanvas");
                break;
            }
        }
    private void isPopup(GameData data, string v, out bool ispop, out GameDataType type)
    {
        if (v.StartsWith("Buff") && data.DataType == GameDataType.UnitSetting)
        {
            ispop = true;
            type  = GameDataType.UnitBuff;
            return;
        }
        if (v.StartsWith("CityBuff") && data.DataType == GameDataType.City)
        {
            ispop = true;
            type  = GameDataType.TeamBuff;
            return;
        }
        if (v.StartsWith("Buff") && data.DataType == GameDataType.Hero)
        {
            ispop = true;
            type  = GameDataType.TeamBuff;
            return;
        }
        if (v.StartsWith("Skill"))
        {
            ispop = true;
            type  = GameDataType.Skill;
            return;
        }
        if (v.StartsWith("Army"))
        {
            ispop = true;
            type  = GameDataType.Army;
            return;
        }
        if (v.StartsWith("King"))
        {
            ispop = true;
            type  = GameDataType.King;
            return;
        }
        if (v.StartsWith("Team") || v.StartsWith("ShopTeam"))
        {
            ispop = true;
            type  = GameDataType.Team;
            return;
        }
        if (v.StartsWith("MainHero") || v.StartsWith("MinorHero"))
        {
            ispop = true;
            type  = GameDataType.Hero;
            return;
        }
        if (v.StartsWith("Unit"))
        {
            ispop = true;
            type  = GameDataType.Unit;
            return;
        }
        if (v.StartsWith("Setting"))
        {
            ispop = true;
            type  = GameDataType.UnitSetting;
            return;
        }
        if (v.StartsWith("EffectIDs") && data.DataType == GameDataType.Skill)
        {
            ispop = true;
            type  = GameDataType.SkillEffect;
            return;
        }
        if (v.StartsWith("EffectIDs") && data.DataType == GameDataType.TeamBuff)
        {
            ispop = true;
            type  = GameDataType.TeamEffect;
            return;
        }
        if (v.StartsWith("EffectIDs") && data.DataType == GameDataType.UnitBuff)
        {
            ispop = true;
            type  = GameDataType.UnitEffect;
            return;
        }

        if (v.StartsWith("NextComm_"))
        {
            ispop = true;
            type  = GameDataType.ConversationData;
            return;
        }

        if (v.StartsWith("CommunicationEntry") || v.StartsWith("CommEntry"))
        {
            ispop = true;
            type  = GameDataType.ConversationData;
            return;
        }

        ispop = false; type = GameDataType.Other;
    }
Beispiel #9
0
        /// <summary>
        /// Opens a window on screen using GameDataStore data.
        /// </summary>
        /// <param name="name">Name of the window to open.</param>
        /// <param name="type">The type of game data to pass to the window.</param>
        /// <param name="dataName">Name of the data to pass to the window.</param>
        public void OpenWindow(string name, GameDataType type, string dataName)
        {
            object data = GameDataStore.Get(type, dataName);

            OpenWindow(name, data);
        }
 public GameData(GameDataType type, object data)
 {
     Type = type;
     Data = data;
 }
 public GameData(GameDataType type, object data)
 {
     Type = type;
     Data = data;
 }
Beispiel #12
0
        public void SendGameData(UserClient player, int playerId, MsgType messageType, bool messageState, GameDataType gameDataType, string gameDataObject = "")
        {
            var gameServerStream = new GameServerStream()
            {
                MessageType  = messageType,
                MessageState = messageState,
                Message      = JsonConvert.SerializeObject(new GameData()
                {
                    GameId         = GameId,
                    PlayerId       = playerId,
                    GameDataType   = gameDataType,
                    GameDataObject = gameDataObject
                })
            };

            player.responseQueue.Enqueue(gameServerStream);

            player.Visitors.ForEach(p => {
                p.responseQueue.Enqueue(gameServerStream);
            });

            if (true)
            {
                var gameLogPath = UserById(playerId) == Player1 ? _player1GameLogName : _player2GameLogName;

                using (StreamWriter outputFile = new StreamWriter(Path.Combine(Environment.CurrentDirectory, gameLogPath), true))
                {
                    outputFile.WriteLine(JsonConvert.SerializeObject(gameServerStream));
                }
            }
        }
Beispiel #13
0
 public void SendGameData(UserClient player, MsgType messageType, bool messageState, GameDataType gameDataType, string gameDataObject = "")
 {
     SendGameData(player, player.PlayerId, messageType, messageState, gameDataType, gameDataObject);
 }
Beispiel #14
0
 private void SendActionToPlayers(int playerId, GameDataType gameDataType, string gameDataObject)
 {
     SendGameData(Player1, playerId, MsgType.InGame, true, gameDataType, gameDataObject);
     SendGameData(Player2, playerId, MsgType.InGame, true, gameDataType, gameDataObject);
 }
Beispiel #15
0
        private static Dictionary <ElfType, List <Element <T> > > ParseData <T>(List <Section> sections,
                                                                                List <SectionRela> relas, GameDataType dataType, List <Symbol> symbolTable, out Dictionary <ElfType, List <long> > dataOffsets)
        {
            (IDictionary <ElfType, List <object> > data, Dictionary <ElfType, List <long> > offsets) = ParseData(sections, relas, dataType, symbolTable);
            Dictionary <ElfType, List <Element <T> > > typedData = new Dictionary <ElfType, List <Element <T> > >();

            foreach ((ElfType type, List <object> instances) in data)
            {
                typedData[type] = instances
                                  .Select(instance => new Element <T>((T)instance))
                                  .ToList();
            }

            dataOffsets = offsets;

            return(typedData);
        }
Beispiel #16
0
        private static byte[] SerializeRelaData(SortedDictionary <long, SectionPointer> stringRelocTable, GameDataType dataType)
        {
            using MemoryStream stream = new MemoryStream();
            using BinaryWriter writer = new BinaryWriter(stream);

            foreach ((long originOffset, SectionPointer pointer) in stringRelocTable)
            {
                if (pointer == SectionPointer.NULL)
                {
                    continue;
                }

                SectionRela rela = dataType switch
                {
                    // 0xB7E00000101 for strings and 0xB7F00000101 for pointers to .rodata
                    GameDataType.DataNpcModel => new SectionRela(originOffset, pointer.Metadata - 0x600000101 + 0xB7E00000101, pointer.Pointer),

                    _ => new SectionRela(originOffset, pointer.Metadata, pointer.Pointer),
                };

                rela.ToBinaryWriter(writer);
            }

            return(stream.ToArray());
        }
    private void DisplayPopInput(GameDataType type, int index)
    {
        string[] s_names = GetGameDataNames(DynamicAndStaicGameDatas, type);
        string[] names   = new string[s_names.Length + 1];
        names[0] = "无";
        s_names.CopyTo(names, 1);


        Array array = null;

        //
        if (type == GameDataType.SkillEffect)
        {
            array = Enum.GetValues(typeof(SkillEffectName));
        }
        else if (type == GameDataType.UnitEffect)
        {
            array = Enum.GetValues(typeof(UnitEffectName));
        }
        else if (type == GameDataType.TeamEffect)
        {
            array = Enum.GetValues(typeof(TeamEffectName));
        }
        //


        if (array == null)
        {
            for (int i = 0; i < names.Length; i++)
            {
                if (InputStrings[index] == names[i])
                {
                    PopupSelect[index] = i;
                }
            }
        }
        else
        {
            for (int i = 0; i < array.Length; i++)
            {
                if (InputStrings[index] == "" + (int)array.GetValue(i))
                {
                    PopupSelect[index] = i + 1;
                }
            }
        }

        PopupSelect[index] = EditorGUILayout.Popup(PopupSelect[index], names);
        if (PopupSelect[index] == 0)
        {
            InputStrings[index] = "";
        }
        else
        {
            if (array != null)
            {
                InputStrings[index] = "" + (int)array.GetValue(PopupSelect[index] - 1);
            }
            else
            {
                InputStrings[index] = names[PopupSelect[index]];
            }
        }
    }