Comments (9)
Is it a good practice to do inject like that?
public class ShootingProvider : MonoProvider<ShootingComponent>
{
[Inject] private BulletFactory _bulletFactory;
protected override void Initialize()
{
Entity.GetComponent<ShootingComponent>().BulletFactory = _bulletFactory;
}
}
public struct ShootingComponent : IComponent
{
public BulletFactory BulletFactory;
}
from morpeh.
I think it’s worth leaving example until Morpeh version 2024.1 comes out.
What about injections, I recommend doing them inside systems, not providers.
Instead of Entity.GetComponent() you should use ref GetData() when you want to get provider component.
from morpeh.
Thanks for the explanation.
When will 2024.1 come out?
from morpeh.
No specific dates yet. I would potentially like to greatly rework the internal part of the framework, maybe it will even be 2025.1
We need deeper support for Burst/Jobs in the core, and this may lead to the abandonment of reference Entity and so on.
In fact, the current version has almost exhausted the limit of algorithmic optimizations that are available when using reference Entity and it all depends on what code generates IL2CPP.
At the same time, our games require performance increases, including at the kernel level of Morpeh, because we have a huge code base and each saved instruction is multiplied by tens, hundreds and thousands.
That’s why I’m still thinking about how to improve the current situation without breaking backward compatibility too much.
Let's not look that far yet, for now we need to finish 2023.1.1
from morpeh.
Well, that's a lot to cover.
Definitely will be waiting for it.
And would create another sample if I have time)
But for now, will continue working on a sample for the current version.
Don't close this issue please.
Will close when it's done.
from morpeh.
Almost finished the core of the game.
it was really fun and I got a couple of new questions.
In one of previous replies you mentioned that it's possible to get data from a provider, so the data should be in IComponent, and all Unity stuff should go into provider, am I correct?
How to inject into systems?
I don't remember if Zenject can inject into scriptables, but VContainer definitely can't.
So, I had to create my own version of installer and inject like this:
My_ecs_installer.cs is an inheritor of Installer
[SerializeField] private OnDamageGameOverSystem onDamageGameOverSystem;
[Inject] private GameStateMachine _gameStateMachine;
private void Start()
{
onDamageGameOverSystem.Inject(_gameStateMachine);
}
onDamageGameOverSystem.cs
private GameStateMachine _gameStateMachine;
public void Inject(GameStateMachine gameStateMachine) => _gameStateMachine = gameStateMachine;
from morpeh.
It's done,
I wanted to add some fancy graphics, SFX, etc.
But it would be a game, not an example.
Will create a pull request after your answers to my previous questions.
from morpeh.
It is better to create an InjectableInstaller into which the entire container is injected, and through the container the injection is called for systems (all or specific ones)
from morpeh.
It's definitely a smarter solution than mine.
Just implemented and it looks much better.
Thanks for your time and help.
from morpeh.
Related Issues (20)
- [2023.1-rc] Incremental Generator for Aspects HOT 1
- Add debug exception when user trying commit world in foreach loop HOT 1
- Unity Project window right click context menu missing ECS options HOT 1
- Filter is null when trying to World.(Any)Update(deltaTime) HOT 6
- [Bug][stage-2023.1] NullReferenceExcpetion when opened WorldViewer Editor Window without created world HOT 1
- Make world disposing more safely HOT 2
- Add MORPEH_DISABLE_AUTOINITIALIZATION to docs
- ReadMe file has wrong IAspect explanation
- Migration URL doesnt work
- NativeFilter Dispose docs is wrong
- Readme missing links HOT 1
- Hypercasual Example Project by Me HOT 5
- Add implicit operator in FIlter.cs for auto FilterBuilder.Build() conversion
- World Browser does't work with Odin inspector
- Items are never removed from map in EntityProvider HOT 2
- Add DISABLE_COMPILE_REPORT define support HOT 1
- Customizing System Group Updates in Morpeh for Network Synchronization in Online Games HOT 2
- Add metrics and verbose log for stash resize event
- A component is added to stash on creation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from morpeh.