-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
68 additions
and
113 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
src/Apps/GameDesktop/CompositionRoots/Entities/PlayerEntityCompositionRoot.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
1 change: 0 additions & 1 deletion
1
src/Apps/GameDesktop/CompositionRoots/Entities/StaticEntityCompositionRoot.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
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 was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
src/Libs/Entities/Factories/Characters/DummyEntityFactory.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Entities.Factories.Characters; | ||
using Entities.Factories.Items.Rocks; | ||
using Entities.Factories.Items.Trees; | ||
using LDtk; | ||
using LightInject; | ||
using Scellecs.Morpeh; | ||
|
||
namespace Entities.Factories; | ||
|
||
public class EntitiesFactory(IServiceFactory serviceFactory) : IEntitiesFactory | ||
{ | ||
private readonly Dictionary<string, IAbstractEntityFactory> _abstractFactories = new() | ||
{ | ||
{ "Rock", serviceFactory.GetInstance<AbstractRockFactory>() }, | ||
{ "Tree", serviceFactory.GetInstance<AbstractTreeFactory>() }, | ||
// { "Default", null } | ||
}; | ||
|
||
private readonly Dictionary<string, EntityFactory> _concreteFactories = new() | ||
{ | ||
{ "Player", serviceFactory.GetInstance<PlayerFactory>() }, | ||
// { "Default", null } | ||
}; | ||
|
||
public Entity? CreateEntity(EntityInstance entity, World @in) => CreateEntity(entity._Identifier, @in) ?? | ||
entity._Tags | ||
.Select(tag => | ||
CreateEntity(entity._Identifier, @in)) | ||
.OfType<Entity>().FirstOrDefault(); | ||
|
||
public Entity? CreateEntity(string tag, World @in) | ||
{ | ||
if (_abstractFactories.TryGetValue(tag, out var @abstract)) return @abstract.CreateEntity(tag, @in); | ||
|
||
if (_concreteFactories.TryGetValue(tag, out var concrete)) return concrete.CreateEntity(@in); | ||
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using LDtk; | ||
using Scellecs.Morpeh; | ||
|
||
namespace Entities.Factories; | ||
|
||
public interface IEntitiesFactory : IAbstractEntityFactory | ||
{ | ||
Entity? CreateEntity(EntityInstance entity, World @in); | ||
} |
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
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
10 changes: 4 additions & 6 deletions
10
src/Libs/Entities/Factories/Items/Trees/AbstractTreeFactory.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 |
---|---|---|
@@ -1,19 +1,17 @@ | ||
using Entities.Factories.Items.Rocks; | ||
using LDtk; | ||
using LightInject; | ||
using LightInject; | ||
using Scellecs.Morpeh; | ||
|
||
namespace Entities.Factories.Items.Trees; | ||
|
||
public class AbstractTreeFactory(IServiceFactory serviceFactory) : IAbstractEntityFactory | ||
{ | ||
private readonly Dictionary<string, ConcreteEntityFactory> _factories = new() | ||
private readonly Dictionary<string, EntityFactory> _factories = new() | ||
{ | ||
{ "Tree", serviceFactory.GetInstance<TreeFactory>() }, | ||
}; | ||
|
||
public Entity? CreateEntity(EntityInstance entity, World @in) => | ||
_factories.TryGetValue(entity._Identifier, out var factory) | ||
public Entity? CreateEntity(string tag, World @in) => | ||
_factories.TryGetValue(tag, out var factory) | ||
? factory.CreateEntity(@in) | ||
: 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
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
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