public static void ValidateAssetDefId(this GameDef gameDef, AssetDefId assetDefId, string hint) { if (!gameDef.Assets.Any(x => x.Id.Equals(assetDefId))) { throw new InvalidGameDefException($"Asset '{assetDefId}' not found. Check '{hint}'!"); } }
private void AddAsset(PlayerId playerId, AssetDefId assetDefId) { logger.LogDebug("Adding asset '{assetDefId}' to player '{playerId}'", assetDefId, playerId); Assets(playerId).Add(new Asset { AssetDefId = assetDefId, Level = 1 }); }
public AssetAlreadyQueuedException(AssetDefId assetDefId) : base($"Asset '{assetDefId.Id}' already queued.") { }
public static AssetDef?GetAssetDef(this GameDef gameDef, AssetDefId assetDefId) { return(gameDef.Assets.SingleOrDefault(x => x.Id.Equals(assetDefId))); }
// The first asset in prerequisites is the primary asset, where the unit can be built public static IEnumerable <UnitDef> GetUnitsForAsset(this GameDef gameDef, AssetDefId id) { return(gameDef.Units.Where(x => x.Prerequisites.Count > 0 && x.Prerequisites.First().Equals(id))); }
public int TicksLeft(PlayerId playerId, AssetDefId assetDefId) { return(actionQueueRepository.TicksLeft(playerId, AssetBuildActionConstants.Name, new Dictionary <string, string> { { AssetBuildActionConstants.AssetDefId, assetDefId.Id } }).Tick); }
public bool IsBuildQueued(PlayerId playerId, AssetDefId assetDefId) { return(actionQueueRepository.IsQueued(playerId, AssetBuildActionConstants.Name, new Dictionary <string, string> { { AssetBuildActionConstants.AssetDefId, assetDefId.Id } })); }
public bool HasAsset(PlayerId playerId, AssetDefId assetDefId) { return(GetAssets(playerId).Any(x => x.AssetDefId.Equals(assetDefId))); }
public AssetNotFoundException(AssetDefId assetDefId) : base($"Asset '{assetDefId.Id}' does not exist.") { }
public AssetAlreadyBuiltException(AssetDefId assetDefId) : base($"Asset '{assetDefId.Id}' already built.") { }