#Ill add a few more examples here
1 messages ยท Page 1 of 1 (latest)
God bless.
You would need to do something like this if you wanted to write to the hashmap in parallel
It will not auto resize then however, so you need to set the Capacity to what it should be
I see. That's fine with me.
I'm starting to get the grasp of things ๐
If you have a lot of readonly data I think the unity recommended approach are blob assets
Maybe something to look into, see if it works for you ๐คท
That's what I've seen, I'm not sure how usable it is for my purpose.
Right now I'm working on an effect system that basically does:
EffectSystem => Map of EffectType, Action<> => Static method that executes said effect type
yep, although building blobs takes some use and I'd honestly only recommend blobs if you feel like data access to it starts being a bottleneck
Having access to my data in the static method feels like a bit of an issue
Well, I can access it, just not with burst-compiled code..
You can call static methods from burst
The problem is loading the specific effect type in the static method^
Yeah, that makes sense
I'd not recommend static methods. If you are in a job just write a method. It can get burst compiled and you don't have to deal with limited data access and endless parameters
I wanted to make my effects be entities, but they need a lot of data from the target unit. It may just be bad design of the effect system itself causing this issue, to be fair.
Although you do need to use a static method if you are just writing a short Entities.ForEach job
also static burst methods are translated to function pointers which are limited to just basic parameter types which can be a total pain
Yea what I'm currently doing feels like more of a hack than a truly well put together system
That's why I don't use Entities.ForEach anymore. Using methods in them is horrible ๐
Yeah, I think unless it's a very small operation using a "fully fledged job" makes more sense
Eh, effect systems that need lots of data is pretty normal ^^
There's lots of different ways to work around your issue, hard to say without all of the context
DamageEffects with ~40 parameters are not fun.
I'm not sure what's better syntax than ForEach
You can define a job directly by creating a struct that implements one of the job interfaces, such as IJob, IJobChunk, etc
40 might be a tad too much ๐ค
Damage is one of the bigger ones, but I have over 100 such effects ๐
I think it depends on how they work, but if I were to implement an effects system I would try and move each "part" of the effect to a component, and then write systems that modify your effect targets as needed. But again, it's hard to say without seeing how it's set up
I only have access to the server, the client is already made and I can't modify it
Why do you want to switch to ECS at all then?
Performance
Depending on how late you are in the project I think it can be very hard to switch
you might want to take a look at this: https://forum.unity.com/threads/sources-included-polymorphism-in-dots-now-with-source-generators.1264616/ might be helpful to you
If you need performance, just use jobs without ECS
It's an MMO with ~100k NPCs and the goal is to handle up to 10k CCU
You can still write bursted code completely without entities
What type of MMO is it? Similar to WoW?
ArcheAge. It's more action-based than WoW
I wrote an almost finished emulator for it in .net but now I ran into some perf issues and other limitations, Unity seemed like a good choice to continue
ah so we are talking about a private server?
Currently just an emulator
well yes, i do think it's a good choice. the data setup might be a little problematic because you are not as flexible
was it .net 6?
Yes it was
I think I need to detach myself from the idea that entities are in-world elements
hm, .net 6 is really fast. not as fast as burst though
I tend to think of an entity as a Unit (npc, player, house, vehicle) rather than a bit of data
Yeah it can really be anything
it makes sense for some cases and then it doesn't for others ๐
But then the issue becomes how well can one entity's component affect another entity's component
is there an effect list somwhere? I have played Archeage only for a very very short time
I can probably pull it out
https://github.com/AAEmu/AAEmu/tree/develop/AAEmu.Game/Models/Game/Skills/Effects
- The file SpecialEffectType
It's missing a bunch that aren't implemented yet iirc
Thanks, okay from a first look. Hardly any effects have a logical relation to each other. they are pretty much their own mechanics. which means every specialType would work as its own component
this whole data lends itself very well to blobdata
SpecialEffects are very generic compared to the rest - 4 integers as parameters instead of whatever else
You can author the spells as mono behaviour component but I'd not save them as entity with components but convert them to blobs
I'd rather not use monobehaviors at all - currently I use none and it's great
just for authoring, not for runtime
in case you are not familiar with authoring: https://docs.unity3d.com/Packages/com.unity.entities@0.7/manual/gp_overview.html
this is what I do in my spell system. from GO to prefab entities to blob data. spells as entities don't work when you want your server to scale
then I save the blob in a NativeHashMap and a job can lookup the spell ID and get all the data.
"and a job can lookup the spell ID" => this is the step I'm currently wondering about
the great thing about blobs is that you can allocate BlobPtr or BlobArray which are useful in case a spell doesn't have a certain mechanic but you still want easy access to the data
the NativeHashMap makes this all possible and very easy to use
That's how I do it too, I just don't have the nativehashmap reference in my job ๐
But all the advice helps
np, I'm afk for some minutes
I guess maybe having a BlobAsset with nativehashmaps is the way to go ?
public NativeHashMap<int, BlobAssetReference<SpellBlobRoot>> blobLookup; this is my spell lookup map
And where do you pass the blobLookup reference to your job ?
the hashmap is public in the SpellLoader system. Then in another system I get the reference via spellLoader = World.GetExistingSystem<SpellLoader>();