# Path: settings.py
# CLIENT_UPDATE_FREQ = MSPERSEC/CLIENT_NETWORK_FPS
# 
# DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S:%f'
# 
# Path: basetickserver.py
# class BaseTickServer(object):
#     '''This is a class that should be subclassed and tick() defined to do something
#     every "tick".'''
# 
#     def __init__(self):
#         self.tick_freq_multiplier = 1
# 
#     def tick(self):
#         '''Do things every tick. Should be overridden.'''
#         pass
# 
#     def start(self):
#         self.current_tick = 0
#         skip_ticks = CLIENT_UPDATE_FREQ
#         max_frameskip = 5
# 
#         next_tick = 0
#         self.running = True
# 
#         while self.running:
#             loops = 0
#             self.current_tick += 1
#             while (self.current_tick > next_tick) and (loops < max_frameskip):
#                 # dt = ((current_tick + skip_ticks) - next_tick) / skip_ticks
#                 self.tick()
#                 next_tick += skip_ticks
#                 loops += 1


from uuid import uuid4
from pymunk import Vec2d
from settings import CLIENT_UPDATE_FREQ, DATETIME_FORMAT
from basetickserver import BaseTickServer
import datetime
import pymunk as pm
    import sys

This should be started by the ZoneServer.
'''


# TODO: This still needs ported from Mongo to Peewee, but it's unused so I'm leaving it for now.

### Physics collision types
COLLTYPE_BALL = 2



class PhysicsServer(BaseTickServer):
    '''This class is responsible for simulating all the physics in the zone.'''

    def __init__(self, zoneid):
        super(PhysicsServer, self).__init__()
        self.zoneid = zoneid

        print "Started with data for zone: %s" % zoneid

        # Set up a PyMunk scene for our simulation.
        self.space = pm.Space()
        self.space.gravity = Vec2d(0.0, 0.0)
        self.space.damping = 0.5
#        self.space.idleSpeedThreshold = 1.0
#        self.space.sleepTimeThreshold = 0.05
        self.objects = {}

        # Initialize our scene by grabbing all the objects since the beginning of time.

# Path: settings.py
# CLIENT_UPDATE_FREQ = MSPERSEC/CLIENT_NETWORK_FPS
# 
# DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S:%f'
# 
# Path: basetickserver.py
# class BaseTickServer(object):
#     '''This is a class that should be subclassed and tick() defined to do something
#     every "tick".'''
# 
#     def __init__(self):
#         self.tick_freq_multiplier = 1
# 
#     def tick(self):
#         '''Do things every tick. Should be overridden.'''
#         pass
# 
#     def start(self):
#         self.current_tick = 0
#         skip_ticks = CLIENT_UPDATE_FREQ
#         max_frameskip = 5
# 
#         next_tick = 0
#         self.running = True
# 
#         while self.running:
#             loops = 0
#             self.current_tick += 1
#             while (self.current_tick > next_tick) and (loops < max_frameskip):
#                 # dt = ((current_tick + skip_ticks) - next_tick) / skip_ticks
#                 self.tick()
#                 next_tick += skip_ticks
#                 loops += 1


# Path: physicsserver.py
from uuid import uuid4
from pymunk import Vec2d
from settings import CLIENT_UPDATE_FREQ, DATETIME_FORMAT
from basetickserver import BaseTickServer
import datetime
import pymunk as pm
    import sys


This should be started by the ZoneServer.
'''


# TODO: This still needs ported from Mongo to Peewee, but it's unused so I'm leaving it for now.

### Physics collision types
COLLTYPE_BALL = 2



class PhysicsServer(BaseTickServer):
    '''This class is responsible for simulating all the physics in the zone.'''

    def __init__(self, zoneid):
        super(PhysicsServer, self).__init__()
        self.zoneid = zoneid

        print "Started with data for zone: %s" % zoneid

        # Set up a PyMunk scene for our simulation.
        self.space = pm.Space()
        self.space.gravity = Vec2d(0.0, 0.0)
        self.space.damping = 0.5
#        self.space.idleSpeedThreshold = 1.0
#        self.space.sleepTimeThreshold = 0.05
        self.objects = {}

        # Initialize our scene by grabbing all the objects since the beginning of time.

        self.last_update = datetime.datetime.strptime('0001-01-01 00:00:00:000000', DATETIME_FORMAT)