Skip to content

Commit

Permalink
Rename factory classes to services (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekolis authored Jan 5, 2025
1 parent e6a1386 commit f8d90ed
Show file tree
Hide file tree
Showing 51 changed files with 172 additions and 170 deletions.
2 changes: 1 addition & 1 deletion FrEee.Core.Domain/FrEee.Core.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<Compile Remove="Gameplay\Commands\EditStrategyCommand.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Vehicles\IHullFactory.cs" />
<None Include="Vehicles\IHullService.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FrEee.Core.Utility\FrEee.Core.Utility.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
namespace FrEee.Gameplay.Commands.Designs;

/// <summary>
/// Builds various types of commands used for managing vehicle designs.
public interface IDesignCommandFactory
/// Creates various types of commands used for managing vehicle designs.
/// </summary>
public interface IDesignCommandService
{
ICreateDesignCommand CreateDesign<T>(IDesign<T> design)
where T : IVehicle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace FrEee.Gameplay.Commands.Fleets;

/// <summary>
/// Builds various types of commands used for managing fleets.
/// Creates various types of commands used for managing fleets.
/// </summary>
public interface IFleetCommandFactory
public interface IFleetCommandService
{
ICreateFleetCommand CreateFleet(Fleet fleet, Sector sector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace FrEee.Gameplay.Commands.Messages;

/// <summary>
/// Builds commands allowing players to manage diplomatic messages.
/// Creates commands allowing players to manage diplomatic messages.
/// </summary>
public interface IMessageCommandFactory
public interface IMessageCommandService
{
IDeleteMessageCommand DeleteMessage(IMessage message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace FrEee.Gameplay.Commands.Ministers;

/// <summary>
/// Builds commands used to manage AI ministers for an empire.
/// Creates commands used to manage AI ministers for an empire.
/// </summary>
public interface IMinisterCommandFactory
public interface IMinisterCommandService
{
IToggleMinistersCommand ToggleMinisters();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace FrEee.Gameplay.Commands.Notes;

/// <summary>
/// Builds various types of commands used for managing notes.
public interface INoteCommandFactory
/// Creates various types of commands used for managing notes.
/// </summary>
public interface INoteCommandService
{
ICommand ClearPlayerNote(IReferrable target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace FrEee.Gameplay.Commands.Orders;

/// <summary>
/// Builds various types of commands used for managing <see cref="IOrder">s.
/// Creates various types of commands used for managing <see cref="IOrder">s.
/// </summary>
public interface IOrderCommandFactory
public interface IOrderCommandService
{
IAddOrderCommand AddOrder(IOrderable target, IOrder order);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace FrEee.Gameplay.Commands.Projects;

/// <summary>
/// Builds commands for empire wide projects such as research and espionage.
/// Creates commands for empire wide projects such as research and espionage.
/// </summary>
public interface IProjectCommandFactory
public interface IProjectCommandService
{
/// <summary>
/// Creates an <see cref="IResearchCommand"/> to assign research spending.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace FrEee.Gameplay.Commands.Waypoints;

/// <summary>
/// Builds commands to manage waypoints.
/// Creates commands to manage waypoints.
/// </summary>
public interface IWaypointCommandFactory
public interface IWaypointCommandService
{
ICommand<Empire> CreateWaypoint(Waypoint waypoint);

Expand Down
2 changes: 1 addition & 1 deletion FrEee.Core.Domain/Modding/Loaders/HullLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override IEnumerable<IModObject> Load(Mod mod)
var hulltype = rec.Get<string>("Vehicle Type", null);
try
{
hull = DIRoot.Hulls.Build(Parser.ParseEnum<VehicleTypes>(hulltype));
hull = DIRoot.Hulls.CreateHull(Parser.ParseEnum<VehicleTypes>(hulltype));
}
catch (InvalidOperationException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void Execute(IOrderable ord)
// colonize now!!!
Planet.Colony = new Colony { Owner = sobj.Owner };
Owner.TriggerHappinessChange(hm => hm.PlanetColonized);
Planet.Colony.ConstructionQueue = DIRoot.ConstructionQueues.Build(Planet);
Planet.Colony.ConstructionQueue = DIRoot.ConstructionQueues.CreateConstructionQueue(Planet);
if (sobj is ICargoContainer cc)
{
foreach (var kvp in cc.Cargo.Population)
Expand Down
2 changes: 1 addition & 1 deletion FrEee.Core.Domain/Objects/GameState/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ public void MoveShips()
&& (!lastBattleTimestamps.ContainsKey(sector) || lastBattleTimestamps[sector] < Timestamp - (v.StrategicSpeed == 0 ? 1d : 1d / v.StrategicSpeed)))) // have we fought here too recently?
{
// resolve the battle
var battle = DIRoot.Battles.BuildSpaceBattle(sector);
var battle = DIRoot.Battles.CreateSpaceBattle(sector);
battle.Resolve();
Battles.Add(battle);
foreach (var emp in battle.Empires)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public IDictionary<string, object> Variables
{
get
{
var design = Container ?? DIRoot.Designs.Build(Mod.Current.Hulls.FirstOrDefault(h => ComponentTemplate.VehicleTypes.HasFlag(h.VehicleType)));
var design = Container ?? DIRoot.Designs.CreateDesign(Mod.Current.Hulls.FirstOrDefault(h => ComponentTemplate.VehicleTypes.HasFlag(h.VehicleType)));
var empire = Container == null ? Empire.Current : Container.Owner;
return new Dictionary<string, object>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
namespace FrEee.Processes.Combat;

/// <summary>
/// Builds battles.
/// Manages battles.
/// </summary>
public interface IBattleFactory
public interface IBattleService
{
/// <summary>
/// Builds a space battle.
/// Creates a space battle.
/// </summary>
/// <param name="location"></param>
/// <returns></returns>
IBattle BuildSpaceBattle(Sector location);
IBattle CreateSpaceBattle(Sector location);

/// <summary>
/// Builds a ground battle.
/// Creates a ground battle.
/// </summary>
/// <param name="location"></param>
/// <returns></returns>
IBattle BuildGroundBattle(Planet location);
IBattle CreateGroundBattle(Planet location);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
namespace FrEee.Processes.Combat.Grid;

/// <summary>
/// Builds <see cref="IConstructionQueue">s for <see cref="IConstructor"/>s
/// Creates <see cref="IConstructionQueue">s for <see cref="IConstructor"/>s
/// and serves as a utility class for <see cref=IConstructionQueue"/>s.
/// </summary>
public interface IConstructionQueueFactory
public interface IConstructionQueueService
{
/// <summary>
/// Builds a construction queue for a constructor.
/// Creates a construction queue for a constructor.
/// </summary>
/// <param name="constructor"></param>
/// <returns></returns>
IConstructionQueue Build(IConstructor constructor);
IConstructionQueue CreateConstructionQueue(IConstructor constructor);

/// <summary>
/// Computes the rate at which a construction queue can build.
Expand Down
2 changes: 1 addition & 1 deletion FrEee.Core.Domain/Processes/Setup/GameSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ private void PlaceEmpire(Galaxy gal, Empire emp, PRNG dice)
hw.Colony = new Colony
{
Owner = emp,
ConstructionQueue = DIRoot.ConstructionQueues.Build(hw),
ConstructionQueue = DIRoot.ConstructionQueues.CreateConstructionQueue(hw),
IsHomeworld = true,
};
hw.AddPopulation(emp.PrimaryRace, hw.Size.MaxPopulation);
Expand Down
26 changes: 13 additions & 13 deletions FrEee.Core.Domain/Utility/DIRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,67 +31,67 @@ public static class DIRoot
/// <summary>
/// Manages battles.
/// </summary>
public static IBattleFactory Battles => DI.Get<IBattleFactory>();
public static IBattleService Battles => DI.Get<IBattleService>();

/// <summary>
/// Allows players to manage designs.
/// </summary>
public static IDesignCommandFactory DesignCommands => DI.Get<IDesignCommandFactory>();
public static IDesignCommandService DesignCommands => DI.Get<IDesignCommandService>();

/// <summary>
/// Allows players to manage fleets.
/// </summary>
public static IFleetCommandFactory FleetCommands => DI.Get<IFleetCommandFactory>();
public static IFleetCommandService FleetCommands => DI.Get<IFleetCommandService>();

/// <summary>
/// Allows players to manage diplomatic messages.
/// </summary>
public static IMessageCommandFactory MessageCommands => DI.Get<IMessageCommandFactory>();
public static IMessageCommandService MessageCommands => DI.Get<IMessageCommandService>();

/// <summary>
/// Allows players to manage AI ministers.
/// </summary>
public static IMinisterCommandFactory MinisterCommands => DI.Get<IMinisterCommandFactory>();
public static IMinisterCommandService MinisterCommands => DI.Get<IMinisterCommandService>();

/// <summary>
/// Allows players to manage notes.
/// </summary>
public static INoteCommandFactory NoteCommands => DI.Get<INoteCommandFactory>();
public static INoteCommandService NoteCommands => DI.Get<INoteCommandService>();

/// <summary>
/// Allows players to issue orders.
/// </summary>
public static IOrderCommandFactory OrderCommands => DI.Get<IOrderCommandFactory>();
public static IOrderCommandService OrderCommands => DI.Get<IOrderCommandService>();

/// <summary>
/// Allows players to manage empire wide projects such as research and espionage.
/// </summary>
public static IProjectCommandFactory ProjectCommands => DI.Get<IProjectCommandFactory>();
public static IProjectCommandService ProjectCommands => DI.Get<IProjectCommandService>();

/// <summary>
/// Allows players to manage waypoints.
/// </summary>
public static IWaypointCommandFactory WaypointCommands => DI.Get<IWaypointCommandFactory>();
public static IWaypointCommandService WaypointCommands => DI.Get<IWaypointCommandService>();

/// <summary>
/// Creates vehicle hulls.
/// </summary>
public static IHullFactory Hulls => DI.Get<IHullFactory>();
public static IHullService Hulls => DI.Get<IHullService>();

/// <summary>
/// Creates vehicle designs.
/// </summary>
public static IDesignFactory Designs => DI.Get<IDesignFactory>();
public static IDesignService Designs => DI.Get<IDesignService>();

/// <summary>
/// Creates vehicles.
/// </summary>
public static IVehicleFactory Vehicles => DI.Get<IVehicleFactory>();
public static IVehicleService Vehicles => DI.Get<IVehicleService>();

/// <summary>
/// Creates construction queues.
/// </summary>
public static IConstructionQueueFactory ConstructionQueues => DI.Get<IConstructionQueueFactory>();
public static IConstructionQueueService ConstructionQueues => DI.Get<IConstructionQueueService>();

/// <summary>
/// Manages the GUI. Only available when there is a GUI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@
namespace FrEee.Vehicles;

/// <summary>
/// Build vehicle designs.
/// Manages vehicle designs.
/// </summary>
public interface IDesignFactory
public interface IDesignService
{
/// <summary>
/// Builds a design with a specific vehicle type.
/// Creates a design with a specific vehicle type.
/// </summary>
/// <param name="vehicleType">The vehicle type to build.</param>
/// <returns>The built design, with no hull or components.</returns>
IDesign Build(VehicleTypes vehicleType);
/// <returns>The new design, with no hull or components.</returns>
IDesign CreateDesign(VehicleTypes vehicleType);

/// <summary>
/// Builds a design with a specific hull.
/// Creates a design with a specific hull.
/// </summary>
/// <param name="hull">The hull to use on the design.</param>
/// <returns>The built design, with a hull but no components.</returns>
IDesign Build(IHull hull);
/// <returns>The new design, with a hull but no components.</returns>
IDesign CreateDesign(IHull hull);

/// <summary>
/// Imports designs from the user's library into the current game.
/// </summary>
IEnumerable<IDesign> ImportFromLibrary();
IEnumerable<IDesign> ImportDesignsFromLibrary();

/// <summary>
/// The standard militia unit design for use in defending colonies.
/// </summary>
IDesign<IUnit> Militia { get; }
IDesign<IUnit> MilitiaDesign { get; }
}
21 changes: 0 additions & 21 deletions FrEee.Core.Domain/Vehicles/IHullFactory.cs

This file was deleted.

21 changes: 21 additions & 0 deletions FrEee.Core.Domain/Vehicles/IHullService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FrEee.Vehicles.Types;

namespace FrEee.Vehicles;

/// <summary>
/// Creates vehicle hulls.
/// </summary>
public interface IHullService
{
/// <summary>
/// Creates a hull of a specific type.
/// </summary>
/// <param name="vehicleType">The type of hull to create.</param>
/// <returns>The new hull.</returns>
IHull CreateHull(VehicleTypes vehicleType);
}
21 changes: 0 additions & 21 deletions FrEee.Core.Domain/Vehicles/IVehicleFactory.cs

This file was deleted.

Loading

0 comments on commit f8d90ed

Please sign in to comment.