-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
237 library designs scrambled (#257)
* Delete an unused Galaxy.Load method overload * Made coupling between MountedComponentTemplate and Design looser, so as to avoid corrupting designs when switching mods
- Loading branch information
Showing
5 changed files
with
106 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
FrEee/Game/Objects/Technology/MountedComponentTemplateContainerPopulator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using FrEee.Game.Interfaces; | ||
using FrEee.Game.Objects.Space; | ||
using FrEee.Utility; | ||
|
||
namespace FrEee.Game.Objects.Technology | ||
{ | ||
/// <summary> | ||
/// Populates the <see cref="MountedComponentTemplate.Container"/> property. | ||
/// </summary> | ||
public class MountedComponentTemplateContainerPopulator | ||
: IPopulator | ||
{ | ||
public object? Populate(object? context) | ||
{ | ||
if (context is MountedComponentTemplate mct) | ||
{ | ||
return Galaxy.Current.Referrables.OfType<IDesign>().SingleOrDefault(q => q.Components.Contains(mct)); | ||
} | ||
else | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FrEee.Utility | ||
{ | ||
public interface IPopulator | ||
{ | ||
/// <summary> | ||
/// Performs potentially expensive lookup logic to retrieve that data which needs to be populated | ||
/// into the cache. | ||
/// </summary> | ||
/// <param name="context"></param> | ||
/// <returns>The data retrieved, or null if it was not found.</returns> | ||
public object? Populate(object? context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FrEee.Utility | ||
{ | ||
public class PopulateAttribute<T> | ||
: Attribute | ||
where T : IPopulator | ||
{ | ||
} | ||
} |