Пример #1
0
        public static Entity CreateHouse(Vector3Int pos)
        {
            var house = new EntityBuilder(World, Engine, Level, EntityType.HOUSE)
                        .Net()
                        .build();

            house.AddComponent <MapObjectComponent>().SetSpawnLocation(pos);
            house.AddComponent <HealthComponent>().Health = 100;
            house.AddComponent <HouseComponent>().Set(Constants.HOUSE_CAPACITY);
            return(house);
        }
Пример #2
0
        public static Entity CreatePlayer(int clientID)
        {
            var player = new EntityBuilder(World, Engine, Level, EntityType.PLAYER)
                         .Net()
                         .build();

            player.AddComponent <ClientComponent>().ID          = clientID;
            player.AddComponent <ResourceComponent>().OreAmount = 0;
            player.AddComponent <TaskFactoryComponent>().Set(new TaskFactory(Engine));
            player.AddComponent <TaskQueueComponent>();
            player.AddComponent <OwnedWorkersComponent>().Set(maxWorkers: Constants.MAX_WORKERS_PER_PLAYER);
            return(player);
        }
Пример #3
0
        public static Entity CreateOre(Vector3Int pos)
        {
            var ore = new EntityBuilder(World, Engine, Level, EntityType.ORE)
                      .Net()
                      .build();

            ore.AddComponent <MapObjectComponent>().SetSpawnLocation(pos);
            ore.AddComponent <HealthComponent>();
            ore.AddComponent <OreComponent>().Amount = Constants.ORE_AMOUNT;
            ore.AddComponent <SlotComponent>()
            .AddSlot(new Vector2(-0.1f, 0.3f))
            .AddSlot(new Vector2(-0.25f, 0))
            .AddSlot(new Vector2(0, -0.25f))
            .AddSlot(new Vector2(0.3f, -0.1f));
            return(ore);
        }
Пример #4
0
        public static Entity CreateLandingPad(Vector3Int pos)
        {
            var house = new EntityBuilder(World, Engine, Level, EntityType.LANDING_PAD)
                        .Net()
                        .build();

            house.AddComponent <MapObjectComponent>().SetSpawnLocation(pos);
            return(house);
        }
Пример #5
0
        public static EntityBuilder AddPlayerLifecycleComponents(this EntityBuilder entityBuilder,
                                                                 string clientAccess,
                                                                 string serverAccess)
        {
            var clientHeartbeat = PlayerHeartbeatClient.Component.CreateSchemaComponentData();
            var serverHeartbeat = PlayerHeartbeatServer.Component.CreateSchemaComponentData();

            return(entityBuilder
                   .AddComponent(clientHeartbeat, clientAccess)
                   .AddComponent(serverHeartbeat, serverAccess));
        }
        public static EntityBuilder AddTransformSynchronizationComponents(this EntityBuilder entityBuilder,
                                                                          string writeAccess,
                                                                          Quaternion rotation,
                                                                          Vector3 location = default(Vector3),
                                                                          Vector3 velocity = default(Vector3))
        {
            var transform = TransformInternal.Component.CreateSchemaComponentData(
                location.ToImprobableLocation(),
                rotation.ToImprobableQuaternion(),
                velocity.ToImprobableVelocity(),
                0,
                1f / Time.fixedDeltaTime
                );

            return(entityBuilder.AddComponent(transform, writeAccess));
        }
Пример #7
0
        public static Entity CreateColonist(Vector3 spawn)
        {
            var colonist = new EntityBuilder(World, Engine, Level, EntityType.COLONIST)
                           .Net()
                           .build();

            colonist.AddComponent <PositionComponent>().SetSpawn(spawn);
            colonist.AddComponent <WorkerComponent>();
            colonist.AddComponent <NotOwnedComponent>();
            colonist.AddComponent <PathComponent>();
            colonist.AddComponent <StateComponent>().State = (int)EntityState.IDLE;
            colonist.AddComponent <StatsComponent>().Set(walkSpeed: Constants.COLONIST_SPEED, mineSpeed: Constants.COLONIST_MINE_RATE);
            colonist.AddComponent <ResidentComponent>();
            return(colonist);
        }