Skip to content

Commit

Permalink
Feature/get draw argument value (#264)
Browse files Browse the repository at this point in the history
Added `unit:getDrawArgumentValue(name)` to the rust-server. 

This is handy for checking things on units like: 
- doors open/close
- flaps
- hook for carrier aircraft
and more

Tested with F-14 on the deck with hook down (cannot go down 100% due to it touching the ground):
  • Loading branch information
dutchie032 authored Aug 30, 2024
1 parent a075e32 commit 610edcf
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `DestroyUnit` API
- Added `GetClients` to `SrsService`, which retrieves a list of units that are connected to SRS and the frequencies they are connected to.
- Added `SrsConnectEvent` and `SrsDisconnectEvent` events
- Added `GetDrawArgumentValue` API for units, which returns the value for drawing. (useful for "hook down", "doors open" checks)

### Fixed
- Fixed `MarkAddEvent`, `MarkChangeEvent` and `MarkRemoveEvent` position
Expand Down
2 changes: 1 addition & 1 deletion STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ Primarily enhanced with `GRPC.exporters.unit`
- [ ] `getSensors`
- [ ] `hasSensors`
- [ ] `getRadar`
- [ ] `getDrawArgumentValue`
- [x] `getDrawArgumentValue`
- [ ] `getNearestCargos`
- [ ] `enableEmission`
- [ ] `getDescentCateogry`
Expand Down
12 changes: 12 additions & 0 deletions lua/DCS-gRPC/methods/unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ GRPC.methods.getRadar = function(params)
})
end

GRPC.methods.getDrawArgumentValue = function (params)
-- https://wiki.hoggitworld.com/view/DCS_func_getDrawArgumentValue
local unit = Unit.getByName(params.name)
if unit == nil then
return GRPC.errorNotFound("unit does not exist")
end

return GRPC.success({
value = unit:getDrawArgumentValue(params.argument)
})
end

GRPC.methods.getUnitPosition = function(params)
-- https://wiki.hoggitworld.com/view/DCS_func_getByName
local unit = Unit.getByName(params.name)
Expand Down
12 changes: 12 additions & 0 deletions protos/dcs/unit/v0/unit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ service UnitService {

// https://wiki.hoggitworld.com/view/DCS_func_destroy
rpc Destroy(DestroyRequest) returns (DestroyResponse) {}

// https://wiki.hoggitworld.com/view/DCS_func_getDrawArgumentValue
rpc GetDrawArgumentValue(GetDrawArgumentValueRequest) returns (GetDrawArgumentValueResponse) {}
}

message GetRadarRequest {
Expand All @@ -50,6 +53,15 @@ message GetPositionResponse {
dcs.common.v0.Position position = 1;
}

message GetDrawArgumentValueRequest {
string name = 1;
uint32 argument = 2;
}

message GetDrawArgumentValueResponse {
double value = 1;
}

message GetTransformRequest {
string name = 1;
}
Expand Down
8 changes: 8 additions & 0 deletions src/rpc/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ impl UnitService for MissionRpc {
Ok(Response::new(res))
}

async fn get_draw_argument_value(
&self,
request: Request<unit::v0::GetDrawArgumentValueRequest>,
) -> Result<Response<unit::v0::GetDrawArgumentValueResponse>, Status> {
let res = self.request("getDrawArgumentValue", request).await?;
Ok(Response::new(res))
}

async fn get(
&self,
request: Request<unit::v0::GetRequest>,
Expand Down

0 comments on commit 610edcf

Please sign in to comment.