Ejemplo n.º 1
0
        public void TestSerialize()
        {
            var obj = new MixedType()
            {
                F1 = System.Array.Empty <byte>(),
                F2 = 0xab,
                F3 = 0x123,
                F4 = new byte[] { 0x45, 0x67, 0x89 },
                F5 = new byte[] { 0xab, 0xcd, 0xef },
            };
            var serialzier = new TableSerializer(new BaseSerializer[]
            {
                new BytesSerializer(obj.F1),
                new ByteSerializer(obj.F2),
                new UInt32Serializer(obj.F3),
                new ArraySerializer <byte, ByteSerializer>(obj.F4),
                new BytesSerializer(obj.F5),
            }
                                                 );
            var expected = new byte[]
            {
                0x2b, 0, 0, 0,
                0x18, 0, 0, 0, 0x1c, 0, 0, 0, 0x1d, 0, 0, 0, 0x21, 0, 0, 0, 0x24, 0, 0, 0,
                0, 0, 0, 0,
                0xab,
                0x23, 0x01, 0, 0,
                0x45, 0x67, 0x89,
                0x03, 0, 0, 0, 0xab, 0xcd, 0xef
            };

            Assert.Equal(expected, serialzier.Serialize());
        }
Ejemplo n.º 2
0
    public static T LoadTable <T>(string tableName)
    {
        TextAsset table = AssetManager.Instance.Table.Retrieve(tableName);
        var       ret   = TableSerializer.Derialize <T>(table.bytes);

        return(ret);
    }
Ejemplo n.º 3
0
        private static void DeserializeAndSerialize_BinariesShouldBeIdentical_Base <T>(string path, Endianness endianness = Endianness.LittleEndian)
        {
            using (var fileStream = File.OpenRead(path))
            {
                var table = TableSerializer.Deserialize <T>(fileStream);

                using (var memoryStream = new MemoryStream())
                {
                    TableSerializer.Serialize(table, memoryStream, endianness);

                    try
                    {
                        using (var test = File.Create("test"))
                        {
                            memoryStream.Position = 0;
                            memoryStream.CopyTo(test);
                        }

                        fileStream.Position   = 0;
                        memoryStream.Position = 0;

                        for (int i = 0; i < memoryStream.Length; i++)
                        {
                            Assert.AreEqual(fileStream.ReadByte(), memoryStream.ReadByte(),
                                            $"Different byte at {i:X4}");
                        }
                    }
                    finally
                    {
                        File.Delete("test");
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void EncodeInto(StringBuilder sb, object value)
 {
     if (value != null)
     {
         TableSerializer.EncodeAndAppend(sb, (string)value);
     }
 }
Ejemplo n.º 5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (CurrentNpc != null)
            {
                SaveCurrentNpc();
            }
            if (CurrentItem != null)
            {
                SaveCurrentItem();
            }

            SaveCurrentGroup();

            TableSerializer.Save("lstGroups", lstGroups.SaveState());
            TableSerializer.Save("lstNpcs", lstNpcs.SaveState());
            TableSerializer.Save("lstNpcItems", lstNpcItems.SaveState());
            TableSerializer.Save("lstPerks", lstPerks.SaveState());

            if (this.GroupParser.Save(Groups, Config.PathGroups, Config.PathWorldmapHeader))
            {
                //this.Close();
                Message.Show("Groups saved successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Message.Show("Groups failed to save.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 6
0
    public static void Load()
    {
        string       savePath = Util.GetDataPath(LocalData.SaveFileName);
        StreamReader sr       = null;

        try
        {
            if (false == System.IO.File.Exists(savePath))
            {
                Save();
            }

            sr = new StreamReader(savePath);

            s_intance = (LocalData)TableSerializer.Derialize <LocalData>(sr);
            sr.Close();
            sr = null;
        }
        catch (System.Exception e)
        {
            if (null != sr)
            {
                sr.Close();
            }

            System.IO.File.Delete(savePath);
            Debug.Log("LocalSaveData Load Exception : " + e.Message);
            s_intance = new LocalData();
        }
    }
        private static void RandomizeUnitTable(string tablePath)
        {
            var table  = TableSerializer.Deserialize <UnitTable>(tablePath);
            var values = GetTableDistinctValues(table);

            var unitValues = (Dictionary <string, List <object> >)values[nameof(table.Units)][0];

            for (int i = 0; i < table.Units.Length; i++)
            {
                ref var unit = ref table.Units[i];

                unit.ArcanaId  = GetRandom <byte>(unitValues[nameof(unit.ArcanaId)]);
                unit.Level     = GetRandom <byte>(unitValues[nameof(unit.Level)]);
                unit.Strength  = GetRandom <byte>(unitValues[nameof(unit.Strength)]);
                unit.Magic     = GetRandom <byte>(unitValues[nameof(unit.Magic)]);
                unit.Endurance = GetRandom <byte>(unitValues[nameof(unit.Endurance)]);
                unit.Agility   = GetRandom <byte>(unitValues[nameof(unit.Agility)]);
                unit.Luck      = GetRandom <byte>(unitValues[nameof(unit.Luck)]);
                for (int j = 0; j < unit.SkillIDs.Length; j++)
                {
                    unit.SkillIDs[j] = (ushort)Random.Next(0, AtlusTableLib.Persona4.Constants.SKILL_COUNT_REAL - 1);
                }

                unit.ExpReward    = GetRandom <ushort>(unitValues[nameof(unit.ExpReward)]);
                unit.YenReward    = GetRandom <ushort>(unitValues[nameof(unit.YenReward)]);
                unit.AttackDamage = GetRandom <ushort>(unitValues[nameof(unit.AttackDamage)]);
            }
        public void Serialize_AddsPropertyElements()
        {
            var classDefinition        = MappingConfiguration.Current.GetTypeDefinition(typeof(Ceo));
            var propertySerializerStub = MockRepository.GenerateStub <IPropertySerializer>();
            var expected1 = new XElement("property1");
            var expected2 = new XElement("property2");

            propertySerializerStub
            .Stub(
                _ => _.Serialize(
                    Arg.Is(classDefinition.GetPropertyDefinition("Remotion.Data.DomainObjects.UnitTests.Persistence.Rdbms.SchemaGenerationTestDomain.Ceo.Name")),
                    Arg <IRdbmsPersistenceModelProvider> .Is.Anything))
            .Return(expected1);
            propertySerializerStub
            .Stub(
                _ => _.Serialize(
                    Arg.Is(classDefinition.GetPropertyDefinition("Remotion.Data.DomainObjects.UnitTests.Persistence.Rdbms.SchemaGenerationTestDomain.Ceo.Company")),
                    Arg <IRdbmsPersistenceModelProvider> .Is.Anything))
            .Return(expected2);
            var tableSerializer = new TableSerializer(propertySerializerStub);

            var actual = tableSerializer.Serialize(classDefinition).Single();

            Assert.That(actual.Elements(), Is.EqualTo(new[] { expected1, expected2 }));
        }
Ejemplo n.º 9
0
        public override JsStoreData LoadList(ILoadListQuery clientQuery)
        {
            Contract.Requires(clientQuery != null);

            using (var session = _sessionFactory.OpenSession())
            {
                var query = session.Query <WmsReport2Entity>()
                            .Where(p => p.ObjectName_r == "CSTREQCUSTOMS")
                            .Select(p => p.Report_r);

                query = (IQueryable <WmsReport>)_linqQueryBuilder.ApplyConditions(query, clientQuery.Conditions.OfType <IFieldValueCondition>(), Bindings);
                var count = _linqQueryBuilder.Count(query);

                query = (IQueryable <WmsReport>)_linqQueryBuilder.ApplySorting(query, clientQuery.SortItems, Bindings);
                if (clientQuery.Page.IsDefined)
                {
                    query = (IQueryable <WmsReport>)_linqQueryBuilder.ApplyPaging(query, clientQuery.Page.StartRow, clientQuery.Page.Size);
                }

                var dynamicQuery = _linqQueryBuilder.ApplyProjection(query, Bindings);
                var listObj      = _linqQueryBuilder.List(dynamicQuery);

                var dataTable = _dataTableByBindingsFactory.CreateDataTable(Bindings);
                _bindingDataTableFiller.FillTableFromList(dataTable, listObj, Bindings);

                var dataPage = new DataPage(dataTable, count);
                return(TableSerializer.Serialize(dataPage.Data, dataPage.Count));
            }
        }
Ejemplo n.º 10
0
        public void TestEmptyObject()
        {
            TableType obj              = null;
            var       serializer       = new TableSerializer(new BaseSerializer[] { new ByteSerializer(1), new UInt32Serializer(2) });
            var       optionSerializer = new OptionSerializer <TableType, TableSerializer>(obj, serializer);
            var       expected         = System.Array.Empty <byte>();

            Assert.Equal(expected, optionSerializer.Serialize());
        }
        private static void RandomizeAICalculationTableFES(string tablePath)
        {
            var table = TableSerializer.Deserialize <AICalculationTableF>(tablePath);

            table.PlayerAIScript = ScriptRandomizer.RandomizeFlowScript(table.PlayerAIScript);
            table.BossAIScript   = ScriptRandomizer.RandomizeFlowScript(table.BossAIScript);

            TableSerializer.Serialize(table, tablePath + "_Randomized");
        }
        public void Serialize_CreatesTableElement()
        {
            var tableSerializer = new TableSerializer(MockRepository.GenerateStub <IPropertySerializer>());

            var actual =
                tableSerializer.Serialize(MappingConfiguration.Current.GetTypeDefinition(typeof(ClassWithAllDataTypes))).Single();

            Assert.That(actual.Name.LocalName, Is.EqualTo("table"));
            Assert.That(actual.Attributes().Select(a => a.Name.LocalName), Contains.Item("name"));
            Assert.That(actual.Attribute("name").Value, Is.EqualTo("TableWithAllDataTypes"));
        }
Ejemplo n.º 13
0
        public JsStoreData LoadList(ILoadListQuery query)
        {
            var dataPage = _entitiesLoader.LoadList(EntityDescriptor.EntityType,
                                                    Bindings,
                                                    query.SortItems,
                                                    query.Conditions.OfType <IFieldValueCondition>(),
                                                    query.Page,
                                                    true);

            return(TableSerializer.Serialize(dataPage.Data, dataPage.Count));
        }
Ejemplo n.º 14
0
        public void TestNonEmptyObject()
        {
            var obj              = new TableType(0x01, 2);
            var serializer       = new TableSerializer(new BaseSerializer[] { new ByteSerializer(obj.F1), new UInt32Serializer(obj.F2) });
            var optionSerializer = new OptionSerializer <TableType, TableSerializer>(obj, serializer);
            var expected         = new byte[]
            {
                17, 0, 0, 0, 12, 0, 0, 0, 13, 0, 0, 0, 1, 2, 0, 0, 0
            };

            Assert.Equal(expected, optionSerializer.Serialize());
        }
Ejemplo n.º 15
0
        public MainWindow()
        {
            var     serializer = new TableSerializer();
            dynamic table      = serializer.Deserialize <Persona5PS3EncounterTable>(@"D:\Modding\Persona 5\Dump\battle\table.pac files\table\ENCOUNT.TBL");

            serializer.Serialize(table, @"D:\Modding\Persona 5\Dump\battle\table.pac files\table\ENCOUNT.TBL_");

            table = serializer.Deserialize <Persona4.MessageTable>(@"D:\Modding\Persona 3 & 4\Persona4\CVM_BTL\BATTLE\MSG.TBL");
            serializer.Serialize(table, @"D:\Modding\Persona 3 & 4\Persona4\CVM_BTL\BATTLE\MSG.TBL_");


            InitializeComponent();
        }
        public JsStoreData LoadLookup(ILoadLookupQuery loadLookupQuery)
        {
            var dataPage = LoadLookupInternal(
                loadLookupQuery.QueryText,
                loadLookupQuery.EncloseValueInPercent,
                EntityDescriptor.EntityType,
                Bindings,
                loadLookupQuery.SortItems,
                loadLookupQuery.Conditions.OfType <IFieldValueCondition>(),
                loadLookupQuery.Page,
                true);

            return(TableSerializer.Serialize(dataPage.Data, dataPage.Count));
        }
Ejemplo n.º 17
0
        public object GetAccountsList(EntityId entityId)
        {
            using (var session = _factory.OpenSession())
            {
                var wb2Customs = session
                                 .Query <CstReqCustoms2WB>()
                                 .Where(i => i.ReqCustoms.ReqCustomsID == int.Parse(entityId.Id.ToString()));


                var dataTable = new DataTable();
                dataTable.Columns.Add(new DataColumn("AccountNumber", typeof(string)));
                dataTable.Columns.Add(new DataColumn("AccountAmount", typeof(decimal)));
                dataTable.Columns.Add(new DataColumn("AccountCurrency", typeof(string)));

                if (wb2Customs.Any(i => i.IWB != null))
                {
                    var iwbCpvLsts =
                        wb2Customs.SelectMany(i => i.IWB.CPV_List)
                        .Where(
                            c =>
                            new[] { "IWBTIRAccountAmount", "IWBTIRAccountCurrency", "IWBTIRAccountNumber" }
                            .Contains(c.CustomParam.CustomParamCode));


                    foreach (
                        var cpvParent in iwbCpvLsts.Where(x => x.CustomParam.CustomParamCode == "IWBTIRAccountNumber").Distinct())
                    {
                        var raw = dataTable.NewRow();

                        var accCurrency =
                            iwbCpvLsts.FirstOrDefault(
                                x =>
                                x.Parent.CPVID == cpvParent.CPVID &&
                                x.CustomParam.CustomParamCode == "IWBTIRAccountCurrency");
                        var accountAmount = iwbCpvLsts.Where(x => x.Parent.CPVID == cpvParent.CPVID &&
                                                             x.CustomParam.CustomParamCode == "IWBTIRAccountAmount").ToList();

                        var accountAmountSum = accountAmount.Sum(i => decimal.Parse(i.CPVValue));

                        raw["AccountNumber"]   = cpvParent.CPVValue;
                        raw["AccountCurrency"] = accCurrency == null ? string.Empty : accCurrency.CPVValue;
                        raw["AccountAmount"]   = accountAmountSum;

                        dataTable.Rows.Add(raw);
                    }
                }
                var dataPage = new DataPage(dataTable, dataTable.Rows.Count);
                return(TableSerializer.Serialize(dataPage.Data, dataPage.Count));
            }
        }
Ejemplo n.º 18
0
        public JsStoreData LoadList(ILoadListQuery clientQuery)
        {
            Contract.Requires(clientQuery != null);
            using (var session = _sessionFactory.OpenSession())
            {
                var query = session.Query <WmsIWB>().Where(i => !session.Query <CstReqCustoms2WB>().Any(j => j.IWB.IWBID == i.IWBID));

                var mandantIDField = clientQuery.Conditions.OfType <IFieldValueCondition>().SingleOrDefault(f => f.Field.Name == "MandantID");
                if (mandantIDField != null)
                {
                    var mandantEntityID = (EntityReference)mandantIDField.Value.Single();
                    var mandantID       = mandantEntityID.GetConvertedId <Int32>();;
                    query = query.Where(i => i.Partner.PartnerID == mandantID);
                }
                else
                {
                    query = query.Where(i => 1 == 0);
                }

                var typeField = clientQuery.Conditions.OfType <IFieldValueCondition>().SingleOrDefault(f => f.Field.Name == "WBType");
                if (typeField != null && typeField.Value.Any())
                {
                    var valueType = typeField.Value.Single().ToString();
                    if (!string.IsNullOrEmpty(valueType))
                    {
                        query = query.Where(i => i.IWBType == valueType);
                    }
                }

                query = (IQueryable <WmsIWB>)_linqQueryBuilder.ApplyConditions(query, clientQuery.Conditions.OfType <IFieldValueCondition>(), Bindings);
                var count = _linqQueryBuilder.Count(query);

                query = (IQueryable <WmsIWB>)_linqQueryBuilder.ApplySorting(query, clientQuery.SortItems, Bindings);
                if (clientQuery.Page.IsDefined)
                {
                    query = (IQueryable <WmsIWB>)_linqQueryBuilder.ApplyPaging(query, clientQuery.Page.StartRow, clientQuery.Page.Size);
                }

                var dynamicQuery = _linqQueryBuilder.ApplyProjection(query, Bindings);
                var listObj      = _linqQueryBuilder.List(dynamicQuery);

                var dataTable = _dataTableByBindingsFactory.CreateDataTable(Bindings);
                _bindingDataTableFiller.FillTableFromList(dataTable, listObj, Bindings);

                var dataPage = new DataPage(dataTable, count);
                return(TableSerializer.Serialize(dataPage.Data, dataPage.Count));
            }
        }
Ejemplo n.º 19
0
    public static AnimatedModel Deserialize(GamePlatform p, string data)
    {
        AnimatedModel model = new AnimatedModel();

        model.nodes      = new Node[256];
        model.keyframes  = new Keyframe[1024];
        model.animations = new Animation[128];
        AnimatedModelBinding b = new AnimatedModelBinding();

        b.p = p;
        b.m = model;
        TableSerializer s = new TableSerializer();

        s.Deserialize(p, data, b);
        return(model);
    }
        public void Serialize_CreatesPersistenceModelProvider()
        {
            var propertySerializerMock = MockRepository.GenerateMock <IPropertySerializer>();
            var tableSerializer        = new TableSerializer(propertySerializerMock);

            propertySerializerMock.Expect(
                _ => _.Serialize(
                    Arg <PropertyDefinition> .Is.NotNull,
                    Arg <IRdbmsPersistenceModelProvider> .Is.NotNull))
            .Return(null)
            .Repeat.AtLeastOnce();

            propertySerializerMock.Replay();
            tableSerializer.Serialize(MappingConfiguration.Current.GetTypeDefinition(typeof(ClassWithAllDataTypes))).ToArray();
            propertySerializerMock.VerifyAllExpectations();
        }
Ejemplo n.º 21
0
    public static void Save()
    {
        if (null == s_intance)
        {
            s_intance = new LocalData();
        }

        string savePath = Util.GetDataPath(LocalData.SaveFileName);

        Debug.Log(savePath);
        System.IO.StreamWriter sw = null;
        sw = new StreamWriter(savePath);

        TableSerializer.Serialize <LocalData>(sw, s_intance);
        sw.Close();
    }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            Console.Write("Path to .TBL or folder containing decompiled .txt files: ");
            string path = Console.ReadLine();

            if (File.Exists(path) && Path.GetExtension(path).ToUpper() == ".TBL")
            {
                var table = TableSerializer.Deserialize(path, (Game)Enum.Parse(typeof(Game), "Persona5PS3EU"));
                DumpNameTable(table, Path.GetDirectoryName(path));
            }
            else if (Directory.Exists(path))
            {
                List <string> nameTypes = new List <string> {
                    "ArcanaNames", "SkillNames", "UnitNames", "PersonaNames", "AccessoryNames", "ArmorNames",
                    "ConsumableItemNames", "KeyItemNames", "MaterialNames", "MeleeWeaponNames", "BattleActionNames", "OutfitNames", "SkillCardNames", "ConfidantNames", "PartyMemberLastNames", "PartyMemberFirstNames", "RangedWeaponNames",
                };
                using (FileStream fs = File.Create(Path.Combine(path, "newName.tbl")))
                    using (EndianBinaryWriter bw = new EndianBinaryWriter(fs, Endianness.BigEndian))
                    {
                        foreach (string nameType in nameTypes)
                        {
                            int[] tableDataOffsets = UpdateNameTable($"{path}\\{nameType}.txt", out byte[] tableData);

                            //Write size & offsets and pad by 16-byte alignment
                            bw.Write(tableDataOffsets.Count() * 2);
                            byte offsetFiller = 0x00;
                            bw.Write(offsetFiller);
                            bw.Write(offsetFiller);
                            for (int i = 0; i < tableDataOffsets.Count() - 1; i++)
                            {
                                bw.Write(Convert.ToUInt16(tableDataOffsets[i]));
                            }
                            byte[] filler = new byte[AlignmentHelper.GetAlignedDifference(bw.Position, 16)];
                            bw.Write(filler);
                            //Write size & names and pad by 16-byte alignment
                            bw.Write(tableData.Length);
                            bw.Write(tableData);
                            filler = new byte[AlignmentHelper.GetAlignedDifference(bw.Position, 16)];
                            bw.Write(filler);
                        }
                    }
            }
        }
Ejemplo n.º 23
0
        private static void RandomizeElsaiTable(string tablePath)
        {
            string output = tablePath + "_Randomized";
            var    table  = TableSerializer.Deserialize <AtlusTableLib.Persona5.ElsaiTable>(tablePath);

            var ais = new List <ushort>();

            foreach (var ai in table.Segment1)
            {
                if (!ais.Contains(ai.AiId))
                {
                    ais.Add(ai.AiId);
                }
            }

            for (int i = 0; i < table.Segment1.Length; i++)
            {
                ref var ai = ref table.Segment1[i];

                ai.AiId = GetRandom(ais);
            }
        public void Serialize_OnlyAddsPersistentProperties()
        {
            var classDefinition        = MappingConfiguration.Current.GetTypeDefinition(typeof(Ceo));
            var propertySerializerMock = MockRepository.GenerateStrictMock <IPropertySerializer>();

            Expression <Predicate <PropertyDefinition> > propertyDefinitionConstraint =
                p => p.StorageClass == StorageClass.Persistent;

            propertySerializerMock.Expect(
                _ => _.Serialize(
                    Arg <PropertyDefinition> .Matches(propertyDefinitionConstraint),
                    Arg <IRdbmsPersistenceModelProvider> .Is.Anything))
            .Return(new XElement("property"))
            .Repeat.AtLeastOnce();

            var tableSerializer = new TableSerializer(propertySerializerMock);

            propertySerializerMock.Replay();
            tableSerializer.Serialize(classDefinition).ToArray();
            propertySerializerMock.VerifyAllExpectations();
        }
Ejemplo n.º 25
0
        public void Execute()
        {
            var deleteSet = new HashSet <ulong>(
                _pks.Select(x => x.ToHash()).ToList());

            foreach (var ix in _ixs)
            {
                var dataFile = Path.Combine(_directory, ix.VersionId + ".rdb");

                using (var stream = new FileStream(dataFile, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
                {
                    stream.Seek(ix.DocHashOffset, SeekOrigin.Begin);

                    var buffer = new byte[TableSerializer.SizeOfDocHash()];

                    while (stream.Position < ix.DocAddressesOffset)
                    {
                        stream.Read(buffer, 0, buffer.Length);

                        var hash = TableSerializer.DeserializeDocHash(buffer);

                        if (deleteSet.Contains(hash.Hash))
                        {
                            stream.Position = stream.Position - buffer.Length;
                            buffer[0]       = 1;
                            stream.Write(buffer, 0, buffer.Length);
                            deleteSet.Remove(hash.Hash);
                        }
                        if (deleteSet.Count == 0)
                        {
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
    private static void LoadTable <T>(string tableName)
    {
        TextAsset table = AssetManager.Instance.Table.Retrieve(tableName);

        TableSerializer.Derialize <T>(table.bytes);
    }
Ejemplo n.º 27
0
        private void frmEncounterGroupEditor_Paint(object sender, PaintEventArgs e)
        {
            if (IsFirstPaint)
            {
                cmbGroupPosition.SelectedIndex = 0;
                numDialog.Maximum = Int32.MaxValue;
                numProto.Maximum  = Int32.MaxValue;
                Groups            = GroupParser.GetGroups();

                foreach (FOCommon.Worldmap.EncounterGroup.EncounterGroup Grp in Groups)
                {
                    CalculateGroupZoneStats(Grp);
                }

                List <Item> items = ItemPid.GetItems();

                foreach (Item item in items)
                {
                    cmbItemPid.Items.Add(item.Define);
                }
                cmbItemPid.Sorted = true;


                if (TableSerializer.Exists("lstGroups"))
                {
                    lstGroups.RestoreState(TableSerializer.Load("lstGroups"));
                }
                if (TableSerializer.Exists("lstNpcs"))
                {
                    lstNpcs.RestoreState(TableSerializer.Load("lstNpcs"));
                }
                if (TableSerializer.Exists("lstNpcItems"))
                {
                    lstNpcItems.RestoreState(TableSerializer.Load("lstNpcItems"));
                }

                Factions = GameParser.GetFactions();

                ProtoNames = FODLG.GetData();

                foreach (KeyValuePair <int, string> kvp in ProtoNames)
                {
                    if (kvp.Key % 2 == 1)
                    {
                        continue;
                    }
                    CritterProto CrP = new CritterProto((kvp.Key / 10));
                    CrP.Name = kvp.Value;
                    CrProtos.Add(CrP);
                }
                foreach (FOCommon.Worldmap.EncounterGroup.EncounterGroup grp in Groups)
                {
                    foreach (Faction f in Factions)
                    {
                        if (grp.FactionId == f.Id)
                        {
                            grp.FactionName = f.Name;
                        }
                    }
                }


                lstGroups.SetObjects(Groups);

                cmbPerkDefine.Items.AddRange(DefineParser.GetDefinesByPrefix("PE_").Keys.ToArray <String>());

                IsFirstPaint = false;
            }
        }
Ejemplo n.º 28
0
        public static void Randomize(string path, bool bossRush = false)
        {
            string output = path + "_Randomized";
            var    table  = TableSerializer.Deserialize <AtlusTableLib.Persona5.EncounterTable>(path);

            var encounterTypes  = new List <ushort>();
            var field02s        = new List <ushort>();
            var field04s        = new List <ushort>();
            var field06s        = new List <ushort>();
            var unitIds         = new List <ushort>();
            var fieldAndRoomIds = new List <Tuple <ushort, ushort> >();
            var musicIds        = new List <ushort>();

            foreach (var encounter in table.Encounters)
            {
                if (!encounterTypes.Contains(encounter.EncounterType))
                {
                    encounterTypes.Add(encounter.EncounterType);
                }

                if (!field02s.Contains(encounter.Field02))
                {
                    field02s.Add(encounter.Field02);
                }

                if (!field04s.Contains(encounter.Field04))
                {
                    field04s.Add(encounter.Field04);
                }

                if (!field06s.Contains(encounter.Field06))
                {
                    field06s.Add(encounter.Field06);
                }

                for (int i = 0; i < encounter.UnitIDs.Length; i++)
                {
                    if (!unitIds.Contains(encounter.UnitIDs[i]))
                    {
                        unitIds.Add(encounter.UnitIDs[i]);
                    }
                }

                var fieldAndRoomTuple = new Tuple <ushort, ushort>(encounter.FieldId, encounter.RoomId);
                if (!fieldAndRoomIds.Contains(fieldAndRoomTuple))
                {
                    fieldAndRoomIds.Add(fieldAndRoomTuple);
                }

                if (!musicIds.Contains(encounter.MusicId))
                {
                    musicIds.Add(encounter.MusicId);
                }
            }

            for (int i = 0; i < table.Encounters.Length; i++)
            {
                ref var encounter = ref table.Encounters[i];

                //encounter.EncounterType = GetRandom(encounterTypes);
                //encounter.Field02 = GetRandom(field02s);
                //encounter.Field04 = GetRandom(field04s);
                //encounter.Field06 = GetRandom(field06s);
                if (bossRush)
                {
                    encounter.EncounterType = 0;
                    encounter.Field02       = 0;
                    encounter.Field04       = 0;
                    encounter.Field06       = 0;
                }

                /*if (bossRushAlt)
                 * {
                 *  for (int j = 0; j < 5; j++)
                 *  {
                 *      encounter.UnitIDs[j] = 0;
                 *  }
                 *
                 *  encounter.UnitIDs[0] = (ushort)Random.Next(190, 351);
                 * }
                 * else
                 * {*/
                for (int j = 0; j < Random.Next(5); j++)
                {
                    if (bossRush)
                    {
                        encounter.UnitIDs[j] = (ushort)Random.Next(190, 351);
                    }
                    else
                    {
                        encounter.UnitIDs[j] = GetRandom(unitIds);
                    }
                }

                var fieldAndRoomTuple = GetRandom(fieldAndRoomIds);
                encounter.FieldId = fieldAndRoomTuple.Item1;
                encounter.RoomId  = fieldAndRoomTuple.Item2;
                encounter.MusicId = GetRandom(musicIds);
            }
Ejemplo n.º 29
0
 public static AnimatedModel Deserialize(GamePlatform p, string data)
 {
     AnimatedModel model = new AnimatedModel();
     model.nodes = new Node[256];
     model.keyframes = new Keyframe[1024];
     model.animations = new Animation[128];
     AnimatedModelBinding b = new AnimatedModelBinding();
     b.p = p;
     b.m = model;
     TableSerializer s = new TableSerializer();
     s.Deserialize(p, data, b);
     return model;
 }
Ejemplo n.º 30
0
        public JsStoreData LoadCard(EntityId entityId)
        {
            var source = _entitiesLoader.LoadCard(entityId, Bindings);

            return(TableSerializer.Serialize(source, 1));
        }