31 lines
972 B
Go
31 lines
972 B
Go
package memory
|
|
|
|
import (
|
|
"fmt"
|
|
"joylink.club/bj-rtsts-server/dto"
|
|
"joylink.club/bj-rtsts-server/sys_error"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/component/component_proto"
|
|
"joylink.club/rtsssimulation/entity"
|
|
)
|
|
|
|
func TransponderMove(simulation *VerifySimulation, req *dto.TransponderMoveReqDto) error {
|
|
worldData := entity.GetWorldData(simulation.World)
|
|
link := worldData.Repo.FindLink(simulation.uidMap[req.LinkId].Uid)
|
|
if link == nil {
|
|
panic(sys_error.New(fmt.Sprintf("未找到[id:%s]的Link", link.Id())))
|
|
}
|
|
if req.Offset > link.Length() {
|
|
panic(sys_error.New(fmt.Sprintf("偏移量[%d]超出Link长度", req.Offset)))
|
|
}
|
|
te, ok := entity.GetEntityByUid(simulation.World, req.TransponderId)
|
|
if !ok {
|
|
panic(sys_error.New(fmt.Sprintf("没有[id:%s]的应答器", req.TransponderId)))
|
|
}
|
|
component.LinkPositionType.SetValue(te, component_proto.LinkPosition{
|
|
LinkId: req.LinkId,
|
|
Offset: req.Offset,
|
|
})
|
|
return nil
|
|
}
|