Post by Admin on Jul 16, 2016 4:18:48 GMT
Maxim Zaks @mzaks Sep 16 2015 00:19
@bitbutter may I write an answer in a blog post and quote your question. I just think that a blog post would be a better fit.
bitbutter @bitbutter Sep 16 2015 00:19
@mzaks absolutely!
Maxim Zaks @mzaks Sep 16 2015 00:19
it might take a while I will try to do it today in the evening
Maxim Zaks @mzaks Sep 16 2015 04:23
@bitbutter Hi, I published the blog post
medium.com/@icex33/separation-of-concerns-e00f89fdc277
I am not sure if I could answer your questions clearly enough, please don't hesitate to ask more specific here in the chat so I can explain what I meant or give a better explanation . I just wanted to write this article ASAP so you don't have to wait long for the answer.
bitbutter @bitbutter Sep 16 2015 05:53
@mzaks That's very useful thanks. So the way I'm imagining it now, I might have objects like the one below expressed somewhere in (for instance) a JSON txt file:
{
"Resource": "EnemyGreenHealer",
"Position": "0,0",
"Move": "0,0",
"CanHeal": 10,
"HitPoints":50
}
And in one of the game systems I'd need to figure out a smart way to translate the above configuration into the (equivalent of) the code below:
_pool.CreateEntity()
.AddResource("EnemyGreenHealer")
.AddPosition(0, 0,)
.AddMove(0, 0)
.AddCanHeal(10);
.AddHitPoints(50);
Does this sound something like the right track?
Maxim Zaks @mzaks Sep 16 2015 06:25
exactly. You can have a method CreateUnitForType where you pass in the type which is a string. Than you can lookup by type in JsonObject and construct entity in a generic way.
@bitbutter may I write an answer in a blog post and quote your question. I just think that a blog post would be a better fit.
bitbutter @bitbutter Sep 16 2015 00:19
@mzaks absolutely!
Maxim Zaks @mzaks Sep 16 2015 00:19
it might take a while I will try to do it today in the evening
Maxim Zaks @mzaks Sep 16 2015 04:23
@bitbutter Hi, I published the blog post
medium.com/@icex33/separation-of-concerns-e00f89fdc277
I am not sure if I could answer your questions clearly enough, please don't hesitate to ask more specific here in the chat so I can explain what I meant or give a better explanation . I just wanted to write this article ASAP so you don't have to wait long for the answer.
bitbutter @bitbutter Sep 16 2015 05:53
@mzaks That's very useful thanks. So the way I'm imagining it now, I might have objects like the one below expressed somewhere in (for instance) a JSON txt file:
{
"Resource": "EnemyGreenHealer",
"Position": "0,0",
"Move": "0,0",
"CanHeal": 10,
"HitPoints":50
}
And in one of the game systems I'd need to figure out a smart way to translate the above configuration into the (equivalent of) the code below:
_pool.CreateEntity()
.AddResource("EnemyGreenHealer")
.AddPosition(0, 0,)
.AddMove(0, 0)
.AddCanHeal(10);
.AddHitPoints(50);
Does this sound something like the right track?
Maxim Zaks @mzaks Sep 16 2015 06:25
exactly. You can have a method CreateUnitForType where you pass in the type which is a string. Than you can lookup by type in JsonObject and construct entity in a generic way.