Thursday, November 15, 2018

c# - Game engine: a decent way, architecture-wise, to implement scripting support?


I am developing a simple game engine (in C#, if it matters), and I can't think of a decent enough way to implement scripting in terms of architecture.


It's a simple turn-based strategy with custom, logic-independent animations for battles. It has a global architecture layer for system/low-level stuff and, most importantly, two main modules - logic and game-view thingy - that communicate using an event manager.


And the thing is, I would really like to have the scripts influence both stuff related to the game logic (changing unit parameters, etc) and stuff related to the game-view, such as special animations/dialogues for battles that might depend on a certain scripted trigger.



(To be honest, ideally I want the script to control the game flow, leaving only the core mechanics/graphics to the logic/view, but I'm new to this, so I'm not sure I can do it right now)


I've been thinking of three options:




  • Just let the scripting live in the logic, but let it know about the graphical side of the game. But this would make the logic/view division very vague, won't it...




  • Make the scripting a separate module that will exchange events with the others using the same event manager. But this would require to be very careful about event synchronization, I guess... and also add a whopping lot of event types to the manager. (Still, personal favorite)





  • Make the scripting a module above all, so it can directly influence/call functions of the logic/view. This allows for an inherently wider functionality at the cost of sort of screwing the entire event exchange scheme and being afraid that the script can break stuff even when it really shouldn't.




So, I can neither decide on one of these nor think of a better way to insert the scripting module... Any suggestions or useful links?


Thank you!


P.s. thanks for migrating the question, didn't know there was a specialized section for gamedev




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...