Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi every one

I'll try to keep this short, my problem is i'm making some kind of a "game" (maybe more of an engine?) and the whole idea in what i try to make is that i have made everything ready for others to do, in other words you make your own game but i have made some basic things ready to use, maybe a little like minecraft, where you have some basic stuff but can add mods to it easily.

what i'm thinking is to make some class partial, e.g. i have a input system and i wanna have my own stuff there with some basic movement, but i wanna let the "modders" have the ability to add their own inputs by using a partial class and "simply" load every mod into the solution and just extend the input system with the user made partial class.

now here is the problem i honestly have no clue how i can add this class into the solution at runtime and still make it possible for the program to find these classes and use them as if they're partial/extender to my main input class.

so is this possible and how? code simples and sources would be lovely.

or if there is a better way of doing this, how?

or if it isn't possible, is there any other way i can make it work just the same?

Thanks for reading i appreciate you time and help :)

- Jackie

EDIT:

fast update: it just came to my mind i could also just load an assembly, however i feel this might be much more advance and it would also require the player/"modder"/stuff to compile every thing to a dll or exe which i really just wanna try to avoid since i wanna keep it simple for the modder/player so he can go right ahead in notepad or something.

an other one also go abit advance since this will require to almost make a whole new language which i REALLY wanna avoid, i can go in on a ini file scanner maybe but please no more here :)

Edit:

Ps. im using mono development for this game so the solution should be multi platform usable if possible.
Posted
Updated 2-Jun-12 19:44pm
v3

1 solution

The concept of partial class has nothing to do with run time. The question makes no sense.

To understand what partial declaration does, read carefully: http://msdn.microsoft.com/en-us/library/wa80x488.aspx[^].

It looks like you do not really understand what a project build does, how the application is compiled, loaded and executed.

When you learn it, you will be able to pose the valid questions and learn the advanced matter that you may need.

Basically, you might need to implement and use some pluggability feature. Please see my past answers on the topic:
Create WPF Application that uses Reloadable Plugins...[^],
AppDomain refuses to load an assembly[^],
code generating using CodeDom[^],
Create WPF Application that uses Reloadable Plugins...[^],
Dynamically Load User Controls[^],
C# Reflection InvokeMember on existing instance[^],
Projects and DLL's: How to keep them managable?[^].

You might also consider using MEF. Please see:
http://en.wikipedia.org/wiki/Managed_Extensibility_Framework[^],
http://mef.codeplex.com/[^].

It is possible that some simpler technique can suite your application goals, but then you would need to explain them properly. You would need some important skill of isolation of functional requirements from the possible technical solutions; that could help you to avoid loosing the ability to choose right solution due to wrong ideas you might be preoccupied with.

—SA
 
Share this answer
 
Comments
Jackie00100 3-Jun-12 1:41am    
i do know how partial works, you ca split classes up in multiple files, but i wanted to know if you from you program could load and use a class that just add user diff. stuff into an already existing file that way... :)
Sergey Alexandrovich Kryukov 3-Jun-12 2:01am    
Even if you know that, you might not understand what "load" means. You can load assembly, you can generate and load assembly during run-time, you can create a DynamicMethod during run-time, but not "extend" a type. If you just analyzed documentation and syntax, from one hand, and the documentation on the life cycle of the process, you would see it.
--SA
Jackie00100 3-Jun-12 8:57am    
"but not "extend" a type" aaah okay thanks for answer
Jackie00100 3-Jun-12 1:43am    
Ow yea i all forgot, im using mono for this game so the solution should be multi platform useable.
Sergey Alexandrovich Kryukov 3-Jun-12 2:04am    
We are discussing the topics where there is no essential difference between Mono and .NET. Everything I have written about on related topics works on Mono as well. I regularly test many my codes on Mono for Windows and Linux, also worked with Mac OS X.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900