From 8e2144c20f3c291744331d29795a4bb946fb418c Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Thu, 29 Oct 2020 02:02:43 +0000 Subject: [PATCH] oh noooo lol --- internal/sim/entity.go | 8 ++++++++ internal/sim/player.go | 5 +---- internal/ui/mode.go | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/internal/sim/entity.go b/internal/sim/entity.go index d5c0138..da6f3bf 100644 --- a/internal/sim/entity.go +++ b/internal/sim/entity.go @@ -2,6 +2,8 @@ package sim import ( "time" + + "github.com/jordanorelli/astro-domu/internal/wire" ) type Entity struct { @@ -11,6 +13,12 @@ type Entity struct { behavior } +func (Entity) NetTag() string { return "entity" } + +func init() { + wire.Register(func() wire.Value { return new(Entity) }) +} + type behavior interface { // update is the standard tick function update(time.Duration) diff --git a/internal/sim/player.go b/internal/sim/player.go index 19bc859..ae2a96a 100644 --- a/internal/sim/player.go +++ b/internal/sim/player.go @@ -34,12 +34,9 @@ func (m *Move) exec(r *room, p *player, seq int) result { return result{reply: wire.Errorf("target cell (%d, %d) is occupied", target[0], target[1])} } p.entity.Position = target - return result{reply: wire.OK{}} + return result{reply: p.entity, announce: p.entity} } -// type pawn struct { -// } - // SpawnPlayer is a request to spawn a player type SpawnPlayer struct { Outbox chan wire.Response diff --git a/internal/ui/mode.go b/internal/ui/mode.go index 34b4f84..c735826 100644 --- a/internal/ui/mode.go +++ b/internal/ui/mode.go @@ -23,16 +23,16 @@ func (m *roomDisplay) handleEvent(ui *UI, e tcell.Event) bool { if key == tcell.KeyRune { switch v.Rune() { case 'w': - ui.client.Send(sim.Move{0, -1}) + go ui.client.Send(sim.Move{0, -1}) // m.move(0, -1) case 'a': - ui.client.Send(sim.Move{-1, 0}) + go ui.client.Send(sim.Move{-1, 0}) // m.move(-1, 0) case 's': - ui.client.Send(sim.Move{0, 1}) + go ui.client.Send(sim.Move{0, 1}) // m.move(0, 1) case 'd': - ui.client.Send(sim.Move{1, 0}) + go ui.client.Send(sim.Move{1, 0}) // m.move(1, 0) } }