public static GameEntity CreateOreBranch(GameContext context, GameEntity vein, Vector2 position) { var e = context.CreateEntity(); e.AddSprite("ore_branch"); e.AddPosition(position); var health = StatCalculator.Calculate(BaseBranchHealthPercentage, 1); e.AddHealth(health, health); e.isOre = true; e.isOreBranch = true; e.isKillable = true; e.isRemovedWhenDead = true; e.AddRoomChild(vein.roomChild.id); e.AddParent(vein.id.value); e.isOnGround = true; if (vein.hasBag == false) { vein.AddBag(new List <int>()); } vein.bag.items.Add(e.id.value); return(e); }
public static GameEntity CreateMiner(Contexts contexts, Vector2 pos) { var e = contexts.game.CreateEntity(); e.AddPrefab("Prefabs/Miners/miner_grunt"); e.AddPosition(pos); MovementHelpers.AddMovementComponents(e, 3f, .25f, .5f, .5f, .8f); SightHelpers.AddSightComponents(e, 10f); e.isMiner = true; var health = StatCalculator.Calculate(BaseHealth, 1); var damage = StatCalculator.Calculate(BaseMiningDamage, 1); var cooldown = StatCalculator.Calculate(BaseMiningSpeed, 1); CombatHelpers.AddCombatComponents(e, health, damage, cooldown); var animDirector = new AnimationDirector(e); e.AddAnimationDirector(animDirector); e.isKillable = true; var agent = new EntityGoapAgent(contexts, e); agent.AddAction(new CloseRangeAttackAction()); agent.AddAction(new GetCloseToTargetAction()); agent.AddAction(new TargetOreBranchAction()); agent.AddAction(new MineAction()); agent.AddGoal(new AcquireOreGoal()); e.AddGoapAgent(agent); var combatDirector = new CombatDirector(e); combatDirector.AddAttack(new MeleeAttack(e, "miner_grunt_mine_regular", new[] { 24 })); e.AddCombatDirector(combatDirector); e.AddBag(new List <int>()); return(e); }