具有多种插件类型的插件架构(XNA)
我希望在 XNA 中为自己设计一个多用途 RPG 引擎,并希望使其依赖于插件。在大多数情况下,我理解整个一般概念......并且我有一个基本的 IPlugin 界面。
然而,当您意识到您需要针对不同系统的多种类型的插件以及一种容纳所有插件的方法时,问题就出现了。事实上,你可以说我正在努力让一切都变得调制。我应该使用多个接口来实现不同的东西吗?不同的主机接口?任何提示表示赞赏。 :)
I'm looking to design a multi purpose RPG engine for myself in XNA, and would like to make it reliant on plugins. For the most part, I understand the whole general concept... and I have a basic IPlugin interface.
However, the problem arises when you realize you need several types of plugins for different systems, and a way to accommodate it all. In fact, you could say I'm trying to make everything modulated. Should I use multiple interfaces, that implement different things? Different host interfaces? Any tips are appreciated. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
取决于您将如何管理以及从性能角度看待这一点。但是你可以做这样的事情。 伪代码:
非常基本的想法。但它在真正的实现中肯定会变得更加复杂,并且之后很容易变得更加复杂。请注意复杂性,因为它会影响性能,因为遵循“最大灵活性”模式很容易忽略它。
问候。
Depends how you gonna manage and also look from performance perspective on this. BUt yu can do something like this. Pseudocode:
Very basic idea. But it for sure will become more complicated in real implementation, and can easily become much more complicated after. Keep attention on complexity as it affects performance cause it's something that easily can be missed following "maximum flexibility" pattern.
Regards.
您没有
IPlugin
界面。您有一个IEnemy
接口和IWeapon
接口等。You don't have a
IPlugin
interface. You have anIEnemy
interface and anIWeapon
interface etc.您可以使用您自己的组件或游戏组件,默认情况下这些组件是不活动的。
然后您可以自己选择要激活的内容,例如 xml 文档。
然后您可以激活选定的插件:
You can use components, either your own or gameComponents, that are by default inactive.
Then you can yourself choose which ones to activate with for example a xml doc.
And then you can activate the selected plugins: