Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Ian Sly
@uzkbwza
Oh, funny. it even mentions shrev in the specs book. https://slide-rs.github.io/specs/07_setup.html
This is exactly what i needed! lol.
Daniel Salvadori
@danaugrs
@uzkbwza wow yep that explains it pretty well :D
Thomas Schaller
@torkleyy
@WaDelma Dispatcher isn't Send because it can contain thread-local systems.
Roman Holovin
@roman-holovin

I have a problem with pathfinding. I wrote a function to calculate paths. It needs bunch of storages, read-only. Unfortunately, one system that interacts with pathfinding requires one of this storages for mutable access. I had to specify WriteStorage for pathfinding arguments just because one of system needs it this way. Documentation specifies that it is forbidden to require both ReadStorage and WriteStorage simultaneously, so I cannot do that. At this point it doesn't really bother me that much, but I suspect I will have problem with FlaggedStorage in future.

Is there way to specify argument type for function so it would accept both ReadStorage and WriteStorage whichever is available for me in the system, so I can pass it to pathfinding?

Daniel Salvadori
@danaugrs
@roman-holovin Could try one of the storage traits
WaDelma
@WaDelma
@torkleyy Makes sense
So that probably could be added to the documentation, because it confused me quite bit
Ian Sly
@uzkbwza

i'm having trouble using the .join() method outside of the System trait implementation block. anyone know how i should fix it?

pardon the ugly code, but here is something that I'm having issues with.
https://pastebin.com/wzURVPS5

the method at line 121 does not work when used in a method for the Ai struct, but it does inside the system's .run() function at line 156. what am i doing wrong? perhaps am I just structuring my code wrong in the first place? should I be approaching this sort of thing in a different way?

Aleksi Juvani
@aleksijuvani
i think you're just missing borrows there
try for (player_entity, target_pos, player) in (&data.entities, &data.positions, &data.players).join()
Ian Sly
@uzkbwza
ahh, thanks. dumb mistake on my part
Aleksi Juvani
@aleksijuvani
oof the saveload api seems like a whole ordeal
i was expecting just to be able to call serialize on the world and be done with it
but this seems to expect that i want to use markers and do some kind of error handling stuff in a trait when i don't care about any of that
Vladimir Zaytsev
@vladimir.zaytsev_gitlab

Hi,

I'm new to rust and specs. I writing a system that needs to access a data that is not owned by specs::World and cannot be copied into world as a resource. What is a good way to pass a data's reference into system's run method? I also cannot store a reference to the data inside of system type because it's lifetime much shorter than the system.

Vladimir Zaytsev
@vladimir.zaytsev_gitlab
nvm, a found similar use-case in examples/cluster_bomb.rs. I think reading world's entities from storage and processing them outside of specs is what I actually should do.
Roman Holovin
@roman-holovin
Hi, is there a reason why GenericReadStorage does not implement Join trait? I'm trying to implement a function that will accept both ReadStorage and WriteStorage, but it seems I cannot join it.
Ian Sly
@uzkbwza
How are you guys handling entity templates? i don't want to be using hard-coded functions for entity generation after a certain point. something like Dwarf Fortress's raw files come to mind, or Caves of Qud saving entity "types" in xml files. Just wondering what your processes are.
Andrew
@robo-corg
@uzkbwza I use serde to deserialize json into an intermediary blueprint format. Then I use serde again to instantiate an entity from that intermediate format. I might rewrite it some since its a bit clunky and probably slow.
Ian Sly
@uzkbwza
Cool, I'd like to see how you've implemented it, if you don't mind. I've gone through a couple different implementations but I'm not happy with anything I've written so far.
FlorentKl
@FlorentKl
Hi. Maybe i am an idiot, but i'm pretty new to Rust, and can't figure out how to import the saveload module. I use "use specs::saveload::{SimpleMarker, SimpleMarkerAllocator};", but keep getting an error : "could not find saveload in specs" or "no saveload in the root" for "use specs::saveload;". In Cargo.toml, i have 0.15.1 version. Thanks all.
WaDelma
@WaDelma
You need to enable serde feature in your Cargo.toml. Here is the documentation on how to do it.
FlorentKl
@FlorentKl
Thanks, it work now.
Bastczuak
@Bastczuak
Hello guys, I am new here and I have a general questions regarding specs and maps. This stuff is all new for me and I don't really know if it is a good approach to use ECS for map rendering? For example right now I use a "map" as a component. This map contains lines, points and so on. For each map I then create entities which represents a "level". And one system which is responsible for handling the rendering in the end? Why I am asking? Because technically a map is not a entity. Right, or do I miss something?
Troels Jessen
@Sheepyhead
Hey friends, this is somewhat of a long shot, but I'm at my wit's end with specs. How do you folks manage to draw anything inside a system? I stumbled upon the ability to define thread local systems, but the system isn't the problem, the problem is the resource. To draw something generally you need a graphics context, and generally that context absolutely cannot be shared between threads, and I cannot seem to find a way to add a resource like that. All I want is to use a Draw system to render my entities based on their Position and Sprite components, but at this point I have no idea how to do this. Right now I'm using ggez as my game engine, but I had the same problem when I was using Piston.
I'm currently looking through the docs for Amethyst, since none of the specs examples seem to have any actual rendering happening, but I figured it wouldn't hurt to ask here.
What I was expecting to work was to insert the resource using world.insert or a variant that works with thread local systems, but I can't seem to find anything in the docs that appear to be what I need to pass a graphics context into a rendering system. Is it simply that I shouldn't be using systems to render things?
Troels Jessen
@Sheepyhead
No that can't be it, the chapter on rendering explicitly has a system named RenderSys, which sounds like it should be a rendering system. Unfortunately it neglects to display how such a system would actually do any rendering https://specs.amethyst.rs/docs/tutorials/10_rendering.html
Seems the only mention of this RenderSys in the repo is that one markdown file. I might be missing something obvious, but this seems like a major oversight to me. In any case I would really love some help with this, as it's currently blocking my entire game project from proceeding :(
Dmitriy
@dpogretskiy
RenderSys is a part of rendering bundle, you should probably dig the sources a bit to understand what's up with it, cause the one is used in amethyst tutorials is aready built in.
https://docs.rs/crate/amethyst_rendy/0.3.0/source/src/bundle.rs
2 interesting bits here are builder.add_barrier() and builder.add_thread_local()
Dmitriy
@dpogretskiy
from my understanding barrier suggests that all other systems should be finished by the time you actually run what comes next, and probably some explicit synchronization steps, to not get race conditions on resources and such, and add_thread_local would probably just run the system on current thread
Dmitriy
@dpogretskiy
so direct solution would be to slap your own bundle together and put the level rendering system before the actual rendering system, that doesn't seem too complicated
or something more hacky, creating a system that makes level entity from resource before the rendering, or if your level is not terribly dynamic, just leave it as an entity forever
Troels Jessen
@Sheepyhead
@dpogretskiy If you're talking to me, I'm looking through those docs right now, it's pretty complicated but I'll put in some more reading when I have time. In any case I feel like there should be at least somewhat of a documented approach to having a system that can render things based on a sprite component, for instance. I'm new to specs, but I can't seem to find out how you would achieve rendering while the context cannot be threaded, and as such needs to be given into a system to run the system in some sequential manner.
WaDelma
@WaDelma
@Sheepyhead In our game the rendering system own a hashmap that has as it's values the actual graphical resource and everybody else just refers to them by strings. Not sure if this helps your case
@Bastczuak I am not sure what is your map. Is it like minimap or overworld or some static map or?
Troels Jessen
@Sheepyhead
@WaDelma My problem isn't storing the Sprite/Texture/whatever, my problem is rendering it. To render it, at least using the engine I'm using (ggez), it requires a graphics context which I cannot pass in as a resource because of threading limitations on the context. To my knowledge most rendering systems has such a context at some level of the engine, so I'm just not sure how others manage to render anything in a specs system
Dmitriy
@dpogretskiy
oh, so you're using ggez with specs, that's what i did too
vblanco20-1
@vblanco20-1
@Sheepyhead i solved that problem on my own with some evil hackery
struct ContextWrapper{
pub ctx: *mut Context
}

impl ContextWrapper{
    fn get(&self) -> &mut Context
    {
        unsafe{
            &mut *self.ctx
        }
    }
}
unsafe impl Sync for ContextWrapper{}
unsafe impl Send for ContextWrapper{}
Dmitriy
@dpogretskiy
and my demo is a bit messy, but there's your answer, https://github.com/dpogretskiy/specs-ggez-showcase/blob/master/src/game.rs#L138
you just run the rendering system outside of specs dispatcher and can put whatever you want into it
also you run in whatever thread you want and it works
Troels Jessen
@Sheepyhead
Oh my god, thank you so much Dmitriy, I can't believe I didn't think of that! I'm gonna go implement that right now!
vblanco20-1
@vblanco20-1
in mine, i run it as a specs system
not outside of it