示例#1
0
            public new static CharacterSO ConvertRow(TableRow row, CharacterSO scriptableObject)
            {
                CharacterSO character = scriptableObject ? scriptableObject : CreateInstance <CharacterSO>();

                if (row.Fields.Count == 0)
                {
                    return(character);
                }

                DatabaseConfig config = TableBinary.Fetch();

                if (config != null)
                {
                    character.ID = row.RowId;
                    var entryId = (character.ID + 1).ToString();

                    if (!character.characterName.IsEmpty)
                    {
                        character.characterName.TableEntryReference = entryId;
                    }
                }

                foreach (var field in row.Fields)
                {
                    if (field.Key.Equals("id"))
                    {
                        character.ID = uint.Parse(field.Value.Data);
                    }
                }

                return(character);
            }
            public new static StorySO ConvertRow(TableRow row, StorySO scriptableObject = null)
            {
                StorySO story = scriptableObject ? scriptableObject : CreateInstance <StorySO>();

                if (row.Fields.Count == 0)
                {
                    return(story);
                }

                DatabaseConfig config = TableBinary.Fetch();

                if (config != null)
                {
                    story.ID = row.RowId;
                    var entryId = (story.ID + 1).ToString();
                    if (!story.title.IsEmpty)
                    {
                        story.title.TableEntryReference = entryId;
                    }

                    if (!story.Description.IsEmpty)
                    {
                        story.Description.TableEntryReference = entryId;
                    }
                }

                foreach (var field in row.Fields)
                {
                    if (field.Key.Equals("id"))
                    {
                        uint data = (uint)field.Value.Data;
                        story.ID = data == uint.MaxValue - 1 ? uint.MaxValue : data;
                    }

                    // Fetch the first dialogue we should start
                    if (field.Key.Equals("childId"))
                    {
                        // retrieve the necessary items
                        uint data = (uint)field.Value.Data;
                        story.childId = data == uint.MaxValue - 1 ? uint.MaxValue : data;
                    }

                    if (field.Key.Equals("parentId"))
                    {
                        // retrieve the necessary items
                        uint data = (uint)field.Value.Data;
                        story.parentId = data == uint.MaxValue - 1 ? uint.MaxValue : data;
                    }

                    if (field.Key.Equals("typeId"))
                    {
                        story.typeId = (StoryType)field.Value.Data;
                    }
                }

                return(story);
            }
示例#3
0
            public static T ConvertRow <T>(TableRow row, T scriptableObject = null) where T : ItemSO
            {
                T item = scriptableObject ? scriptableObject : CreateInstance <T>();

                if (row.Fields.Count == 0)
                {
                    return(item);
                }

                DatabaseConfig config = TableBinary.Fetch();

                if (config != null)
                {
                    item.ID = row.RowId;
                    var entryId = (item.ID + 1).ToString();
                    if (!item.ItemName.IsEmpty)
                    {
                        item.ItemName.TableEntryReference = entryId;
                    }

                    if (!item.Description.IsEmpty)
                    {
                        item.Description.TableEntryReference = entryId;
                    }
                }

                // public ItemType ItemType => itemType;

                foreach (var field in row.Fields)
                {
                    if (item is ItemRecipeSO so && field.Key.Equals("childId"))
                    {
                        so.ChildId = (uint)field.Value.Data;
                    }

                    if (field.Key.Equals("sellValue"))
                    {
                        item.SellValue = (double)field.Value.Data;
                    }

                    if (field.Key.Equals("sellable"))
                    {
                        item.Sellable = (bool)field.Value.Data;
                    }

                    // TODO keep reference
                    // if (field.Key.Equals("itemType"))
                    // {
                    // item.ItemType = (uint) field.Value.Data
                    // }
                }

                return(item);
            }
示例#4
0
        private TableDatabase()
        {
            // locate the data folder
            var config = TableBinary.Fetch();

            if (config == null)
            {
                return;
            }

            Reload(config);

            // Get database version
            // UpdateTime();
        }