zone

package
v0.0.0-...-fee577c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	sync.RWMutex

	// Channel for sending zone event (one of NextZone, NextZoneTick, ZoneTickEnd)
	ZoneEventBroadcaster *broadcast.Broadcaster
	LastZoneEvent        interface{}
	// contains filtered or unexported fields
}

func NewController

func NewController(spotPosition s2.LatLng, spotRadiusInM float32, minZoneRadiusInM float32, nextZonePeriod time.Duration, nextZoneDelay time.Duration, zoneSpeedInKmPerH float64) *Controller

func (*Controller) Next

func (c *Controller) Next(nextZoneCreationTime time.Time)

Create next zone

func (*Controller) Start

func (c *Controller) Start() error

Function for starting zone changing workflow

Timer for new zone -> Timer for next zone delay -> Tick zone till next zone reached -> Restart next zone timer Workflow will work till zero zone reached

func (*Controller) Stop

func (c *Controller) Stop()

func (*Controller) Tick

func (c *Controller) Tick(now time.Time) (*Zone, bool, error)

Approximate zone to next zone

Function returns current zone, flag about last tick (true if it was last tick), error

type StartNextZoneTimerEvent

type StartNextZoneTimerEvent struct {
	CurrentZone  *Zone
	NextZoneTime time.Time
}

type StartZoneDelayTimerEvent

type StartZoneDelayTimerEvent struct {
	CurrentZone       *Zone
	NextZone          *Zone
	ZoneTickStartTime time.Time
}

type Zone

type Zone struct {
	Position s2.LatLng
	// Zone radius in meters
	Radius float32
	// Zone damage per period
	Damage float32
}

func NewZone

func NewZone(position s2.LatLng, radius float32, minZoneRadiusInMeter float32) *Zone

type ZoneTickEvent

type ZoneTickEvent struct {
	CurrentZone *Zone
	NextZone    *Zone
	LastTick    bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL