public IGameAction CreateTrainAction(ITrainableDef trainableDef, ITrainingEntity trainingEntity) { IGameAction gameAction = new GameAction(trainableDef.IconData); gameAction.Clicked += () => { UnitFactory unitFactory = new UnitFactory(trainingEntity.Faction, game); ITrainable spawnable = unitFactory.CreateNewTrainable(trainableDef); if (!trainingEntity.Faction.CanPurchase(spawnable.Def)) { return; } trainingEntity.Faction.Purchase(spawnable.Def); trainingEntity.TrainingQueue.Enqueue(spawnable); }; return(gameAction); }
public ITrainable CreateNewTrainable(ITrainableDef def) { return(CreateNewSpawnable(def) as ITrainable); }