Jump to content

  • Log In with Google      Sign In   
  • Create Account


Nypyren

Member Since 19 Aug 2002
Offline Last Active Yesterday, 11:11 PM

Posts I've Made

In Topic: How can I integrate a script project into my game server?

Yesterday, 11:12 PM

You're welcome! Glad it worked out for you!

In Topic: How can I integrate a script project into my game server?

18 August 2014 - 11:42 AM

What is the rationale for a dediciated init function and what might it contain?


My rationale is that it's a hassle (and inefficient) to call functions via reflection, but you have to use reflection at least once to run code in the script project, since the main project can't reference it directly. So I make a single function that I call with reflection, and have that function do the bulk of the work of "connecting" the script project to the main project. From that point on, the code can call functions "normally" to call functions in the script project.

The ways that I "connect" the script project to the main project at runtime are:

- The script project can register itself with public events in the main project. When those events get raised, the script project can handle them.
- The script project can instantiate classes and then register those classes with the main project. This might mean creating some derived factory classes, "manager" objects, "game objects", or whatever else you might think of.
- The script project can add itself to a list of objects that get called during the main update loop (this is implied in the previous line).

In Topic: How can I integrate a script project into my game server?

17 August 2014 - 09:41 PM

The circular reference is only bad at build time. You can just make it so the game server project doesn't directly reference the script project, but can still load it using reflection. There's no problem once it's loaded.

Here's what I've done in the past:

- In your game server project, define an interface or base class which something in your script project derives from. The interface should at least contain a "Initialize" method of some kind. The function can be static or an instance, whichever you want. You can add other methods as necessary. Think of this as the "Main" function for your script. You can use attributes as well, if you want.

- Set your script project to reference your game server project.

- Make sure your project configuration settings are set so that the script project is always built and copied to the game server project's output folder.

- When your game server runs, it can find all script projects by looking in its working folder for .DLLs. It can then load those using Assembly.LoadFile. LoadFile returns an Assembly object; you can search this assembly for type(s) which inherit from your interface/base class, instantiate them (if necessary) and then call the Initialize method using reflection.

- When your script's Initialize function is called, it can start calling methods in the game server project like normal, which will let you do anything you need to from that point on.

In Topic: I have this collision detection concept I want to discuss

16 August 2014 - 02:48 PM

Anyways I don't think anyone would help now, the general rule for programming places like this is if it  isn't clear and to the point by the first post it's ignored so I guess I'll just go solo now until I really made sure the concept is perfect.


The problem is that your posts use terms and diagrams that ONLY YOU are familiar with. We can't tell what you mean by "floorpad", "landpad" or what your diagrams are supposed to represent. These are terms that you came up with, so don't expect any of us to automatically know what you mean by them.

If you don't use words that people understand, or define them in terms of what people understand, we won't know what you're talking about.

- What is a floorpad?
- What is a landpad?
- What do you mean by "wall object"?
- Is your map grid-based?
- Are your wall objects aligned to anything?
- Is your character movement aligned to tiles?

In Topic: What's the problem here !?

15 August 2014 - 04:44 PM

Looks fine to me. What do you expect it to do on that line?

PARTNERS