pointcache / JECSu

Just another ecs for unity
54 stars 6 forks source link

Templating/blueprinting #3

Open pointcache opened 8 years ago

pointcache commented 8 years ago

Task:

Example: The way how Dwarf Fortress stores game data/definitions is perfect example:


[OBJECT:CREATURE]

[CREATURE:WORM]
    [DESCRIPTION:A tiny burrowing creature, found in moist soil.  It is legless, long and thin.]
    [NAME:worm:worms:worm]
    [CASTE_NAME:worm:worms:worm]
    [CREATURE_TILE:'~'][COLOR:7:0:0]
    [PETVALUE:10]
    [VERMIN_SOIL][FREQUENCY:100][VERMIN_HATEABLE]
    [SMALL_REMAINS][VERMIN_NOTRAP][NOBONES]
    [NATURAL][PET]
    [NOT_BUTCHERABLE]
pointcache commented 8 years ago

Idea: Have a mechanism allowing to read text files in game directory and load data from them as entities on demand.

Benefits:

Proposal:

  1. first step would be to have a "database" like system, that scans some root directory for all files of template format, builds a database from them.
  2. the database itself must be configurable outside of editor through yaml file.
  3. templates will use yaml as its a reliable serialization.
  4. we will use YamlDotNet, and not unity serialization, because YamlDotNet comes with open source.
  5. When system is established, expose request calls by database id
  public Entity Template.LoadByName(string name) // LoadById(string id) 
  1. work out entity construction from template/factory
  2. make sure mechanism for dynamic replacement is provided
pointcache commented 8 years ago
< chicken
        name = "Chicken"
    [Position]
    [Creature]
        max_hp = 90000
        attack_dmg = 1
        attack = "meelee"
        range = 1
        speed = 1
        run_speed = 3

    [Animal]
        type = "Chicken"
    [ColorComponent]
        color = #ffffff
    [WorldView]
        prefab = "animals/chicken";
    [Loot]
        loot_table{
            "chicken", 1, 10
            "feather", 3, 6
        }
>       

< chicken_brown
    parent = chicken
    [ColorComponent]
        color = #ffffff
>
< feather
    name = "Feather"
    [Position]
    [Item]
        mass = 0.01
>       

an example of a template document, several in one, parenting, custom serialization