
syntax = "proto2";

package SC2APIProtocol;

import "s2clientprotocol/common.proto";

//
// Observation - Feature Layer
//

message ObservationFeatureLayer {
  optional FeatureLayers renders = 1;
  optional FeatureLayersMinimap minimap_renders = 2;
}

message FeatureLayers {
  optional ImageData height_map = 1;                // uint8. Terrain height. World space units of [-200, 200] encoded into [0, 255].
  optional ImageData visibility_map = 2;            // uint8. 0=Hidden, 1=Fogged, 2=Visible, 3=FullHidden
  optional ImageData creep = 3;                     // 1-bit. Zerg creep.
  optional ImageData power = 4;                     // 1-bit. Protoss power.
  optional ImageData player_id = 5;                 // uint8. Participants: [1, 15] Neutral: 16
  optional ImageData unit_type = 6;                 // int32. Unique identifier for type of unit.
  optional ImageData selected = 7;                  // 1-bit. Selected units.
  optional ImageData unit_hit_points = 8;           // int32.
  optional ImageData unit_hit_points_ratio = 17;    // uint8. Ratio of current health to max health. [0%, 100%] encoded into [0, 255].
  optional ImageData unit_energy = 9;               // int32.
  optional ImageData unit_energy_ratio = 18;        // uint8. Ratio of current energy to max energy. [0%, 100%] encoded into [0, 255].
  optional ImageData unit_shields = 10;             // int32.
  optional ImageData unit_shields_ratio = 19;       // uint8. Ratio of current shields to max shields. [0%, 100%] encoded into [0, 255].
  optional ImageData player_relative = 11;          // uint8. See "Alliance" enum in raw.proto. Range: [1, 4] 
  optional ImageData unit_density_aa = 14;          // uint8. Density of units overlapping a pixel, anti-aliased. [0.0, 16.0f] encoded into [0, 255].
  optional ImageData unit_density = 15;             // uint8. Count of units overlapping a pixel.
  optional ImageData effects = 20;                  // uint8. Visuals of persistent abilities. (eg. Psistorm)
  optional ImageData hallucinations = 21;           // 1-bit. Whether the unit here is a hallucination.
  optional ImageData cloaked = 22;                  // 1-bit. Whether the unit here is cloaked. Hidden units will show up too, but with less details in other layers.
  optional ImageData blip = 23;                     // 1-bit. Whether the unit here is a blip.
  optional ImageData buffs = 24;                    // int32. One of the buffs applied to this unit. Extras are ignored.
  optional ImageData buff_duration = 26;            // uint8. Ratio of buff remaining. [0%, 100%] encoded into [0, 255].
  optional ImageData active = 25;                   // 1-bit. Whether the unit here is active.
  optional ImageData build_progress = 27;           // uint8. How far along the building is building something. [0%, 100%] encoded into [0, 255].
  optional ImageData buildable = 28;                // 1-bit. Whether a building can be built here.
  optional ImageData pathable = 29;                 // 1-bit. Whether a unit can walk here.
  optional ImageData placeholder = 30;              // 1-bit. Whether the unit here is a placeholder building to be constructed.
}

message FeatureLayersMinimap {
  optional ImageData height_map = 1;                // uint8. Terrain height. World space units of [-200, 200] encoded into [0, 255].
  optional ImageData visibility_map = 2;            // uint8. 0=Hidden, 1=Fogged, 2=Visible, 3=FullHidden
  optional ImageData creep = 3;                     // 1-bit. Zerg creep.
  optional ImageData camera = 4;                    // 1-bit. Area covered by the camera.
  optional ImageData player_id = 5;                 // uint8. Participants: [1, 15] Neutral: 16
  optional ImageData player_relative = 6;           // uint8. See "Alliance" enum in raw.proto. Range: [1, 4] 
  optional ImageData selected = 7;                  // 1-bit. Selected units.
  optional ImageData alerts = 9;                    // 1-bit. Shows 'UnitAttacked' alert location.
  optional ImageData buildable = 10;                // 1-bit. Whether a building can be built here.
  optional ImageData pathable = 11;                 // 1-bit. Whether a unit can walk here.

  // Cheat layers, enable with SpatialCameraSetup.allow_cheating_layers.
  optional ImageData unit_type = 8;                 // int32. Unique identifier for type of unit.
}


//
// Observation - Rendered
//

message ObservationRender {
  optional ImageData map = 1;
  optional ImageData minimap = 2;
}


//
// Action
//

message ActionSpatial {
  oneof action {
    ActionSpatialUnitCommand unit_command = 1;
    ActionSpatialCameraMove camera_move = 2;
    ActionSpatialUnitSelectionPoint unit_selection_point = 3;
    ActionSpatialUnitSelectionRect unit_selection_rect = 4;
  }
}

message ActionSpatialUnitCommand {
  optional int32 ability_id = 1;
  oneof target {
    PointI target_screen_coord = 2;
    PointI target_minimap_coord = 3;
  }

  optional bool queue_command = 4;          // Equivalent to shift+command.
}

message ActionSpatialCameraMove {
  optional PointI center_minimap = 1;       // Simulates a click on the minimap to move the camera.
}

message ActionSpatialUnitSelectionPoint {
  optional PointI selection_screen_coord = 1;
  enum Type {
    Select = 1;         // Equivalent to normal click. Changes selection to unit.
    Toggle = 2;         // Equivalent to shift+click. Toggle selection of unit.
    AllType = 3;        // Equivalent to control+click. Selects all units of a given type.
    AddAllType = 4;     // Equivalent to shift+control+click. Selects all units of a given type.
  }
  optional Type type = 2;
}

message ActionSpatialUnitSelectionRect {
  repeated RectangleI selection_screen_coord = 1;   // Eventually this should not be an array, but a single field (multiple would be cheating).
  optional bool selection_add = 2;                  // Equivalent to shift+drag. Adds units to selection.
}
