@@ -72,14 +72,27 @@ func (p *Parser) bindEntities() {
7272func (p * Parser ) bindBomb () {
7373 bomb := & p .gameState .bomb
7474
75- // Track bomb when it is not held by a player
76- scDroppedC4 := p .stParser .ServerClasses ().FindByName ("CC4" )
77- scDroppedC4 .OnEntityCreated (func (bomb * st.Entity ) {
78- bomb .OnPositionUpdate (func (pos r3.Vector ) {
75+ // Track bomb when it is dropped on the ground or being held by a player
76+ scC4 := p .stParser .ServerClasses ().FindByName ("CC4" )
77+ scC4 .OnEntityCreated (func (bombEntity * st.Entity ) {
78+ bombEntity .OnPositionUpdate (func (pos r3.Vector ) {
7979 // Bomb only has a position when not held by a player
80- p . gameState . bomb .Carrier = nil
80+ bomb .Carrier = nil
8181
82- p .gameState .bomb .LastOnGroundPosition = pos
82+ bomb .LastOnGroundPosition = pos
83+ })
84+
85+ bombEntity .FindPropertyI ("m_hOwner" ).OnUpdate (func (val st.PropertyValue ) {
86+ bomb .Carrier = p .gameState .Participants ().FindByHandle (val .IntVal )
87+ })
88+
89+ bombEntity .FindPropertyI ("m_bStartedArming" ).OnUpdate (func (val st.PropertyValue ) {
90+ if val .IntVal != 0 {
91+ p .gameState .currentPlanter = bomb .Carrier
92+ } else if p .gameState .currentPlanter != nil {
93+ p .gameState .currentPlanter .IsPlanting = false
94+ p .eventDispatcher .Dispatch (events.BombPlantAborted {Player : p .gameState .currentPlanter })
95+ }
8396 })
8497 })
8598
@@ -91,14 +104,6 @@ func (p *Parser) bindBomb() {
91104
92105 bomb .LastOnGroundPosition = bombEntity .Position ()
93106 })
94-
95- // Track bomb when it is being held by a player
96- scPlayerC4 := p .stParser .ServerClasses ().FindByName ("CC4" )
97- scPlayerC4 .OnEntityCreated (func (bombEntity * st.Entity ) {
98- bombEntity .FindPropertyI ("m_hOwner" ).OnUpdate (func (val st.PropertyValue ) {
99- bomb .Carrier = p .gameState .Participants ().FindByHandle (val .IntVal )
100- })
101- })
102107}
103108
104109func (p * Parser ) bindTeamStates () {
0 commit comments