EntityComponentSystem/src/main/java/com/example/model/OrcFactory.java

33 lines
998 B
Java

package com.example.model;
import com.example.components.Health;
import com.example.components.Hero;
import com.example.components.Stats;
import com.example.ecs.Entity;
import com.example.ecs.Registry;
public class OrcFactory implements Factory {
@Override
public Entity createUnit(Registry registry) {
Stats stats = new Stats(33, 1, 0.3, Race.Orc);
Health health = new Health(140, 140);
Entity orc = new Entity();
registry.addComponent(orc, stats);
registry.addComponent(orc, health);
return orc;
}
@Override
public Entity createHero(Registry registry) {
Stats stats = new Stats(33, 1, 0.3, Race.Orc);
Health health = new Health(140 * 1.2, 140 * 1.2);
Hero hero = new Hero("Farseer", 1.2, Element.Earth);
Entity orc = new Entity();
registry.addComponent(orc, stats);
registry.addComponent(orc, health);
registry.addComponent(orc, hero);
return orc;
}
}