48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package memory
|
|
|
|
import (
|
|
"fmt"
|
|
"joylink.club/bj-rtsts-server/dto/data_proto"
|
|
"joylink.club/bj-rtsts-server/dto/request_proto"
|
|
"joylink.club/bj-rtsts-server/sys_error"
|
|
appcomponent "joylink.club/bj-rtsts-server/ts/simulation/app_component"
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/entity"
|
|
"unsafe"
|
|
)
|
|
|
|
func XcjOperation(simulation *VerifySimulation, req *request_proto.XcjOperationReq) *sys_error.BusinessError {
|
|
switch req.Operation {
|
|
case request_proto.Xcj_SetParams:
|
|
return setXcjParam(simulation, req)
|
|
default:
|
|
panic(fmt.Sprintf("未知的屏蔽门操作:%s", req.Operation))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func setXcjParam(simulation *VerifySimulation, req *request_proto.XcjOperationReq) *sys_error.BusinessError {
|
|
uid := QueryUidByMidAndComId(req.MapId, req.DeviceId, &data_proto.CarWashing{})
|
|
result := <-ecs.Request[ecs.EmptyType](simulation.World, func() ecs.Result[ecs.EmptyType] {
|
|
wd := entity.GetWorldData(simulation.World)
|
|
entry, ok := wd.EntityMap[uid]
|
|
if ok {
|
|
entry.AddComponent(appcomponent.XcjParamType, unsafe.Pointer(req.Param))
|
|
if req.Param.Fault == request_proto.Xcj_FA_Fault {
|
|
entry.AddComponent(component.XcjFaultTag)
|
|
} else {
|
|
entry.RemoveComponent(component.XcjFaultTag)
|
|
}
|
|
} else {
|
|
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的实体", uid))
|
|
}
|
|
return ecs.NewOkEmptyResult()
|
|
})
|
|
if result.Err != nil {
|
|
return sys_error.New("洗车机设置参数失败", result.Err)
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|