package physics_sys import ( "github.com/yohamta/donburi/filter" "joylink.club/ecs" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/consts" ) type TwoPositionMovementSys struct { query *ecs.Query } func NewTwoPositionMovementSys() *TwoPositionMovementSys { return &TwoPositionMovementSys{ query: ecs.NewQuery(filter.Contains(component.TwoPositionTransformType)), } } // 更新位置 func (tp *TwoPositionMovementSys) Update(w ecs.World) { tp.query.Each(w, func(entry *ecs.Entry) { position := component.TwoPositionTransformType.Get(entry) if position.Speed != 0 { position.Pos += position.Speed if position.Pos < consts.PosMin { position.Pos = consts.PosMin } else if position.Pos > consts.PosMax { position.Pos = consts.PosMax } } }) }