package dfproto;

option optimize_for = LITE_RUNTIME;

message EnumItemName {
    required int32 value = 1;
    optional string name = 2;

    // For bitfield members
    optional int32 bit_size = 3 [default = 1];
};

message BasicMaterialId {
    required int32 type = 1;
    required sint32 index = 2;
};

message BasicMaterialInfo {
    required int32 type = 1;
    required sint32 index = 2;

    // The raw token
    required string token = 3;

    // IF mask.flags:
    // List of material_flags indices
    repeated int32 flags = 4;

    // Material type/index expanded:
    optional int32 subtype = 5 [default = -1];
    optional int32 creature_id = 6 [default = -1];
    optional int32 plant_id = 7 [default = -1];
    optional int32 histfig_id = 8 [default = -1];

    optional string name_prefix = 9 [default = ""];

    // IF mask.states: in listed order;
    // ELSE: one state matching mask.temperature
    repeated fixed32 state_color = 10;
    repeated string state_name = 11;
    repeated string state_adj = 12;

    // IF mask.reaction:
    message Product {
        required string id = 1;
        required int32 type = 2;
        required sint32 index = 3;
    };
    repeated string reaction_class = 13;
    repeated Product reaction_product = 14;

    // IF mask.flags:
    repeated int32 inorganic_flags = 15;
};

message BasicMaterialInfoMask {
    enum StateType {
        Solid = 0;
        Liquid = 1;
        Gas = 2;
        Powder = 3;
        Paste = 4;
        Pressed = 5;
    };
    repeated StateType states = 1;
    optional int32 temperature = 4 [default = 10015];

    optional bool flags = 2 [default = false];
    optional bool reaction = 3 [default = false];
};

message JobSkillAttr {
    required int32 id = 1;
    required string key = 2;

    optional string caption = 3;
    optional string caption_noun = 4;

    optional int32 profession = 5;
    optional int32 labor = 6;
    optional string type = 7;
};

message ProfessionAttr {
    required int32 id = 1;
    required string key = 2;

    optional string caption = 3;
    optional bool military = 4;
    optional bool can_assign_labor = 5;

    optional int32 parent = 6;
};

message UnitLaborAttr {
    required int32 id = 1;
    required string key = 2;

    optional string caption = 3;
};

message NameInfo {
    optional string first_name = 1;
    optional string nickname = 2;

    optional int32 language_id = 3 [default = -1];

    optional string last_name = 4;
    optional string english_name = 5;
};

message NameTriple {
    required string normal = 1;
    optional string plural = 2;
    optional string adjective = 3;
};

message UnitCurseInfo {
    required fixed32 add_tags1 = 1;
    required fixed32 rem_tags1 = 2;
    required fixed32 add_tags2 = 3;
    required fixed32 rem_tags2 = 4;

    optional NameTriple name = 5;
};

message SkillInfo {
    required int32 id = 1;
    required int32 level = 2;
    required int32 experience = 3;
};

message UnitMiscTrait {
    required int32 id = 1;
    required int32 value = 2;
};

message BasicUnitInfo {
    required int32 unit_id = 1;

    required int32 pos_x = 13;
    required int32 pos_y = 14;
    required int32 pos_z = 15;

    optional NameInfo name = 2;

    required fixed32 flags1 = 3;
    required fixed32 flags2 = 4;
    required fixed32 flags3 = 5;

    required int32 race = 6;
    required int32 caste = 7;
    optional int32 gender = 8 [default = -1];

    optional int32 civ_id = 9 [default = -1];
    optional int32 histfig_id = 10 [default = -1];

    optional int32 death_id = 17 [default = -1];
    optional uint32 death_flags = 18;

    // IF mask.profession:
    optional int32 squad_id = 19 [default = -1];
    optional int32 squad_position = 20 [default = -1];

    optional int32 profession = 22 [default = -1];
    optional string custom_profession = 23;

    // IF mask.labors:
    repeated int32 labors = 11;

    // IF mask.skills:
    repeated SkillInfo skills = 12;

    // IF mask.misc_traits:
    repeated UnitMiscTrait misc_traits = 24;

    optional UnitCurseInfo curse = 16;

    repeated int32 burrows = 21;
};

message BasicUnitInfoMask {
    optional bool labors = 1 [default = false];
    optional bool skills = 2 [default = false];
    optional bool profession = 3 [default = false];
    optional bool misc_traits = 4 [default = false];
};

message BasicSquadInfo {
    required int32 squad_id = 1;

    optional NameInfo name = 2;

    // A special field completely overriding the name:
    optional string alias = 3;

    // Member histfig ids:
    repeated sint32 members = 4;
};

message UnitLaborState {
    required int32 unit_id = 1;
    required int32 labor = 2;
    required bool value = 3;
};