teeworlds_network 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0917309ae467aafcdef2b1702b59c9729034958a3558391a2c1db0e33affab7d'
4
- data.tar.gz: 61b27d40bd5911485d66822ccc10627d6dfce535609f1ec5c89b4898b064441d
3
+ metadata.gz: e05ee8e23b3dc0fc5d0d3127cbdeec642f5c190bfc2884c8deb8215d59df9940
4
+ data.tar.gz: e65baec89be5759245aecc3de871ecec301a2118d0e4b3fc81f9acfa1598fad7
5
5
  SHA512:
6
- metadata.gz: 94e0e1be27b60ad6f235f7ba4147ef8b967caab99600b86d102fb4a498eb035e57ca510fa2eb236ed461987c1d656b683e60f53161771bb5a5650bf412ff6fa7
7
- data.tar.gz: efd4698d4f273212367481d341c864837e86c7be6fb9829bcb4720c03bd61ec9c0d7d66745e8be577a21a9c79701fb2302568a8bc28d1413c46e90948ae9f22d
6
+ metadata.gz: 37b19d41df9ab97d97f2c59a097647eb03ce0cb5c016d88cdfea7e16923e9ecec20aae196f803f440610db3e599283898f1aa42b1d76829da457eaf8708bc6c4
7
+ data.tar.gz: e01dda2a1988295908bd18b5e9965089286627f37daaa72001f1bdf7f5ebb11b6d3173528493f582655be823f37f7deb879b7a0e0a5f51b4a332970eae4fdd43
data/lib/game_client.rb CHANGED
@@ -38,6 +38,10 @@ class GameClient
38
38
  context
39
39
  end
40
40
 
41
+ def on_tick
42
+ call_hook(:tick, nil)
43
+ end
44
+
41
45
  def on_auth_on
42
46
  return if call_hook(:auth_on, Context.new(nil)).nil?
43
47
 
@@ -40,6 +40,7 @@ class TeeworldsClient
40
40
  auth_off: [],
41
41
  rcon_cmd_add: [],
42
42
  rcon_cmd_rem: [],
43
+ tick: [],
43
44
  maplist_entry_add: [],
44
45
  maplist_entry_rem: []
45
46
  }
@@ -76,6 +77,10 @@ class TeeworldsClient
76
77
  @rcon_authed
77
78
  end
78
79
 
80
+ def on_tick(&block)
81
+ @hooks[:tick].push(block)
82
+ end
83
+
79
84
  def on_auth_on(&block)
80
85
  @hooks[:auth_on].push(block)
81
86
  end
@@ -310,18 +315,18 @@ class TeeworldsClient
310
315
  )
311
316
  end
312
317
 
313
- def send_input
318
+ def send_input(input = {})
314
319
  inp = {
315
- direction: -1,
316
- target_x: 10,
317
- target_y: 10,
318
- jump: rand(0..1),
319
- fire: 0,
320
- hook: 0,
321
- player_flags: 0,
322
- wanted_weapon: 0,
323
- next_weapon: 0,
324
- prev_weapon: 0
320
+ direction: input[:direction] || -1,
321
+ target_x: input[:target_x] || 10,
322
+ target_y: input[:target_y] || 10,
323
+ jump: input[:jump] || rand(0..1),
324
+ fire: input[:fire] || 0,
325
+ hook: input[:hook] || 0,
326
+ player_flags: input[:player_flags] || 0,
327
+ wanted_weapon: input[:wanted_weapon] || 0,
328
+ next_weapon: input[:next_weapon] || 0,
329
+ prev_weapon: input[:prev_weapon] || 0
325
330
  }
326
331
 
327
332
  data = []
@@ -466,6 +471,7 @@ class TeeworldsClient
466
471
  puts 'retrying connection ...'
467
472
  end
468
473
  end
474
+ @game_client.on_tick
469
475
  return unless pck
470
476
 
471
477
  data = pck.first
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- TEEWORLDS_NETWORK_VERSION = 'v0.0.3'
3
+ TEEWORLDS_NETWORK_VERSION = 'v0.0.5'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teeworlds_network
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ChillerDragon