Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Templating/blueprinting #3

Open
pointcache opened this issue Sep 7, 2016 · 2 comments
Open

Templating/blueprinting #3

pointcache opened this issue Sep 7, 2016 · 2 comments

Comments

@pointcache
Copy link
Owner

Task:

  • Have a way to store entity composition and its data in a simple extremely readable and editable format.
  • Have a serializer/deserializer that constructs entity from template

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
Copy link
Owner Author

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

Benefits:

  • example: will allow to have composition root logic depend on dynamically loaded data/entities instead of hardcoded.
  • allows for dynamic replacement of an entity/component with updated one
  • human readable format, with emphasis on editability outside of editor, modding

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
Copy link
Owner Author

< 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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant