Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Entity System - Networking  (Read 1937 times)
0 Members and 1 Guest are viewing this topic.
Offline seismic

Senior Member


Medals: 4
Projects: 1



« Posted 2014-03-30 17:27:17 »

Heya,

I know
Quote
Entity Systems will not get your game done

etc. etc. Cheesy

Anyway, maybe someone can give me some insight to this. I'm using Artemis Entity System (http://gamadu.com/artemis/) which is pretty easy to setup and use and I have really become a big fan of it. Now I have implemented the *most* simple client/server using Kryonet (server trusts the clients, clients just send positional updates at ~30 times per second, server distributes updates to the other clients, you know the drill), which also works fine.

But here comes the "problem". I'm not 100% sure about my way of implementation in regards to the entity system, because what I do now is:

* Client and Server both have their own entity system world (server runs on another thread).
- Client sends positional update to the server (I know, I know Cheesy).
- Server receives update and updates the corresponding entity (the player) the moment it receives the update.
- Server sends the update to the clients and they update the entity the moment they receive it

Now the last 2 parts are what concerns me. I don't know if that is the right way to go about networking in an entity system. If you tried an entity system you know the systems iterate through their components on every frame and *then* do their magic. I'm just not sure how to implement an "this-entity-received-an-update-so-update-it-on-the-next-turn" system.

I know it doesn't really matter in "the most simple client-server-game-thing", performance-wise, but I want to know the "correct" way to go about this.

Maybe someone here has done something like this before and can give some insight into this?

Thanks a lot Smiley

Offline breno.inojosa

Junior Newbie





« Reply #1 - Posted 2014-03-31 06:40:20 »

So... I'm not using Artemis Entity System because I created my own..

Basically, whenever I create a specific type of entity, I add it to a tree. Both in Client and Server. Works the same way.
When you receive a package that applies "Move X to the right", search for the entity in the tree and make your changes to it. Remember to always use thread-safe collections and consider that your networking events shouldn't change the order of the updates or change whatever is already built..

Not sure if I was clear.
Offline seismic

Senior Member


Medals: 4
Projects: 1



« Reply #2 - Posted 2014-03-31 10:53:06 »

Yep, so you update the entities the moment they're received on the client/server, not during the component-update-iteration loop. It's what I do too, I was just wondering if it's the "right way".

Thanks tho Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline junkdog
« Reply #3 - Posted 2014-03-31 15:01:47 »

Vanilla artemis hasn't been updated for quite some time and has a number of bugs. You're better off using a fork, like mine or this one.

artemis-odb: bugfixing and performance optimized fork of artemis ECS
Offline seismic

Senior Member


Medals: 4
Projects: 1



« Reply #4 - Posted 2014-04-09 06:14:18 »

I am using yours <3 Cheesy
Just didn't mention it Smiley

Btw. I just update the components the moment they're received now via
1  
entity.getComponent(Component.class).field = updatedField;


Don't think it has a huge performance impact anyway. Shouldn't be much slower than adding it to a queue and have the component update on the next system-iteration. Listening to myself, it's probably faster :p
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (14 views)
2014-09-19 03:14:18

Dwinin (31 views)
2014-09-12 09:08:26

Norakomi (58 views)
2014-09-10 13:57:51

TehJavaDev (79 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (62 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (31 views)
2014-09-07 01:12:14

Longarmx (36 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!