示例#1
0
		public IEnumerable<LogMessage> GetErrors(IOrderable executor)
		{
			if (!Source.IntrinsicAbilities.Contains(Ability))
				yield return executor.CreateLogMessage(executor + " does not intrinsically possess the ability \"" + Ability + "\" with ID=" + Ability.ID + ".");
			if (!Ability.Rule.IsActivatable)
				yield return executor.CreateLogMessage("The ability \"" + Ability + "\" cannot be activated. It is a passive ability.");
			if (Source is IDamageable && (Source as IDamageable).IsDestroyed)
				yield return executor.CreateLogMessage(executor + " cannot activate " + Source + "'s ability because " + Source + " is destroyed.");
		}
示例#2
0
 public IEnumerable <LogMessage> GetErrors(IOrderable o)
 {
     if (o is IMobileSpaceObject sobj)
     {
         if (sobj.Sector != Planet.Sector)
         {
             // can't colonize here, maybe the GUI should have issued a move order?
             yield return(sobj.CreateLogMessage(sobj + " cannot colonize " + Planet + " because it is not currently located at the planet.", LogMessageType.Warning));
         }
         if (Planet.Colony != null)
         {
             // planet is already colonized!
             yield return(Planet.CreateLogMessage(Planet + " cannot be colonized by " + sobj + " because there is already a colony there belonging to the " + Planet.Colony.Owner + ".", LogMessageType.Warning));
         }
         if (!(sobj.HasAbility(Planet.ColonizationAbilityName) || sobj is Fleet f && f.LeafVehicles.Any(v => v.HasAbility(Planet.ColonizationAbilityName))))
         {
             // no such colony module
             yield return(sobj.CreateLogMessage(sobj + " cannot colonize " + Planet + " because it lacks a " + Planet.Surface + " colony module.", LogMessageType.Warning));
         }
         if (Galaxy.Current.CanColonizeOnlyBreathable && Planet.Atmosphere != sobj.Owner.PrimaryRace.NativeAtmosphere)
         {
             // can only colonize breathable atmosphere (due to game setup option)
             yield return(sobj.CreateLogMessage(sobj + " cannot colonize " + Planet + " because we can only colonize " + sobj.Owner.PrimaryRace.NativeAtmosphere + " planets.", LogMessageType.Warning));
         }
         if (Galaxy.Current.CanColonizeOnlyHomeworldSurface && Planet.Surface != sobj.Owner.PrimaryRace.NativeSurface)
         {
             // can only colonize breathable atmosphere (due to game setup option)
             yield return(sobj.CreateLogMessage(sobj + " cannot colonize " + Planet + " because we can only colonize " + sobj.Owner.PrimaryRace.NativeSurface + " planets.", LogMessageType.Warning));
         }
     }
     else
     {
         yield return(o.CreateLogMessage($"{o} cannot colonize {Planet} because it is not a mobile space object.", LogMessageType.Error));
     }
 }
示例#3
0
        public IEnumerable <LogMessage> GetErrors(IOrderable ord)
        {
            if (ord is ConstructionQueue queue)
            {
                // validate that new facility is unlocked
                if (!queue.Owner.HasUnlocked(Upgrade.New))
                {
                    yield return(Upgrade.Old.CreateLogMessage(Upgrade.Old + " on " + queue.Container + " could not be upgraded to a " + Upgrade.New + " because we have not yet researched the " + Upgrade.New + "."));
                }

                // validate that new and old facilities are in the same family
                if (Upgrade.New.Family.Value != Upgrade.Old.Family.Value)
                {
                    yield return(Upgrade.Old.CreateLogMessage(Upgrade.Old + " on " + queue.Container + " could not be upgraded to a " + Upgrade.New + " because facilities cannot be upgraded to facilities of a different family."));
                }

                // validate that there is a facility to upgrade
                var planet = (Planet)queue.Container;
                var colony = planet.Colony;
                if (!colony.Facilities.Any(f => f.Template == Upgrade.Old))
                {
                    yield return(planet.CreateLogMessage("There are no " + Upgrade.Old + "s on " + planet + " to upgrade."));
                }
            }
            else
            {
                yield return(ord.CreateLogMessage($"{ord} cannot upgrade facilities because it is not a construction queue."));
            }
        }
示例#4
0
 public IEnumerable <LogMessage> GetErrors(IOrderable v)
 {
     if (!(v is IMobileSpaceObject))
     {
         yield return(v.CreateLogMessage($"{v} cannot move to a waypoint because it is not a mobile space object.", LogMessageType.Error));
     }
     if (PathfindingError != null)
     {
         yield return(PathfindingError);
     }
 }
示例#5
0
 public IEnumerable <LogMessage> GetErrors(IOrderable executor)
 {
     if (executor is ICargoTransferrer t)
     {
         if (Target != null && t.Sector != Target.Sector)
         {
             yield return(t.CreateLogMessage(executor + " cannot transfer cargo to " + Target + " because they are not in the same sector."));
         }
     }
     else
     {
         yield return(executor.CreateLogMessage($"{executor} cannot transfer cargo."));
     }
 }