Beispiel #1
0
 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
     });
 }
Beispiel #3
0
 public AssetAlreadyQueuedException(AssetDefId assetDefId) : base($"Asset '{assetDefId.Id}' already queued.")
 {
 }
Beispiel #4
0
 public static AssetDef?GetAssetDef(this GameDef gameDef, AssetDefId assetDefId)
 {
     return(gameDef.Assets.SingleOrDefault(x => x.Id.Equals(assetDefId)));
 }
Beispiel #5
0
 // 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)));
 }
Beispiel #6
0
 public int TicksLeft(PlayerId playerId, AssetDefId assetDefId)
 {
     return(actionQueueRepository.TicksLeft(playerId, AssetBuildActionConstants.Name, new Dictionary <string, string> {
         { AssetBuildActionConstants.AssetDefId, assetDefId.Id }
     }).Tick);
 }
Beispiel #7
0
 public bool IsBuildQueued(PlayerId playerId, AssetDefId assetDefId)
 {
     return(actionQueueRepository.IsQueued(playerId, AssetBuildActionConstants.Name, new Dictionary <string, string> {
         { AssetBuildActionConstants.AssetDefId, assetDefId.Id }
     }));
 }
Beispiel #8
0
 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.")
 {
 }
Beispiel #10
0
 public AssetAlreadyBuiltException(AssetDefId assetDefId) : base($"Asset '{assetDefId.Id}' already built.")
 {
 }