2021-06-19 00:04:34 +02:00
|
|
|
from survival.components.on_collision_component import OnCollisionComponent
|
2021-03-28 18:56:32 +02:00
|
|
|
from survival.components.camera_target_component import CameraTargetComponent
|
2021-06-06 19:55:55 +02:00
|
|
|
from survival.components.consumption_component import ConsumptionComponent
|
2021-03-28 18:56:32 +02:00
|
|
|
from survival.components.input_component import InputComponent
|
2021-05-24 13:10:10 +02:00
|
|
|
from survival.components.inventory_component import InventoryComponent
|
2021-06-06 19:55:55 +02:00
|
|
|
from survival.components.learning_component import LearningComponent
|
2021-03-28 18:56:32 +02:00
|
|
|
from survival.components.movement_component import MovementComponent
|
|
|
|
from survival.components.position_component import PositionComponent
|
|
|
|
from survival.components.sprite_component import SpriteComponent
|
2021-04-18 19:53:51 +02:00
|
|
|
from survival.components.time_component import TimeComponent
|
2021-06-06 19:55:55 +02:00
|
|
|
from survival.components.vision_component import VisionComponent
|
|
|
|
from survival.generators.resource_type import ResourceType
|
|
|
|
from survival.settings import PLAYER_START_POSITION, STARTING_RESOURCES_AMOUNT
|
2021-03-28 18:56:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
class PlayerGenerator:
|
|
|
|
def create_player(self, world, game_map):
|
|
|
|
player = world.create_entity()
|
2021-06-06 19:55:55 +02:00
|
|
|
pos = PositionComponent([PLAYER_START_POSITION[0] * 32, PLAYER_START_POSITION[1] * 32],
|
|
|
|
PLAYER_START_POSITION)
|
2021-03-28 18:56:32 +02:00
|
|
|
world.add_component(player, pos)
|
|
|
|
world.add_component(player, MovementComponent())
|
|
|
|
world.add_component(player, InputComponent())
|
2021-05-21 20:14:00 +02:00
|
|
|
world.add_component(player, OnCollisionComponent())
|
2021-06-06 19:55:55 +02:00
|
|
|
inv = InventoryComponent()
|
|
|
|
for resource in ResourceType:
|
|
|
|
inv.add_item(resource, STARTING_RESOURCES_AMOUNT)
|
2021-06-20 16:27:38 +02:00
|
|
|
world.add_component(player, ConsumptionComponent())
|
2021-06-06 19:55:55 +02:00
|
|
|
world.add_component(player, inv)
|
2021-03-28 18:56:32 +02:00
|
|
|
camera_target = CameraTargetComponent(pos)
|
|
|
|
world.add_component(player, camera_target)
|
2021-06-06 19:55:55 +02:00
|
|
|
# world.add_component(player, AutomationComponent())
|
2021-03-28 18:56:32 +02:00
|
|
|
game_map.add_entity(player, pos)
|
|
|
|
sprite = SpriteComponent('stevenson.png')
|
|
|
|
sprite.set_scale(1)
|
|
|
|
world.add_component(player, sprite)
|
2021-06-06 19:55:55 +02:00
|
|
|
world.add_component(player, TimeComponent())
|
|
|
|
world.add_component(player, VisionComponent())
|
|
|
|
world.add_component(player, LearningComponent())
|
2021-03-28 18:56:32 +02:00
|
|
|
|
|
|
|
return player
|