What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

public static values between plugins

Inrego

New Member
Joined
Feb 7, 2010
Messages
2,765
Reaction score
71
I'm playing around with 2 plugins, and I want them to be able to access eachothers static values, and I am able to do it one way, but not the other way around.

For example:
Plugin A is able to get a static value from plugin B, but plugin B is not able to get a static value from plugin A. I get this error instead:
Code:
The name 'PluginA' does not exist in the current context
 
Maybe have both plugins write to the same .cfg file? That way, both can read the variables at any given time, and when 1 variable changes, the other plugin will be able to read it also.
 
Use reflection

But use it wisely. Reflection is realy slow.

Inrego and I was talking about his problem, he want's to track completed games in the other plugin.

IMHO the best way to archive that is to:

Keep track of GameStats.Instance.NumGamesJoined
And register to the BrainBehavior.OnScheduling event. Just make sure you do some sanity checks in there.

Conclusio: Avoid Reflection when ever it's possible. Especialy in Performance sensitive environments.
 
BrainBehavior.OnScheduling when exactly is that being fired?
 
Idk exactly but it should be fireing even out of game. But i'm not totaly sure how often it is fired.

P.S.: Here is why Reflection is bad: Reflection vs. compiled expressions vs. delegates - Performance comparision - www.palmmedia.de

You know that these results are for 1.000.000 iterations right ?
As your using "Reflection with cached PropertyInfo" when using reflection usually, this in turn makes accessing the property take time of 0,00050 miliseconds

So watch out once start accessing the variable 2000 times in rapid succession as then it will approach 1 ms
 
Last edited:
You know that these results are for 1.000.000 iterations right ?
As your using "Reflection with cached PropertyInfo" when using reflection usually, this in turn makes accessing the property take time of 0,00050 miliseconds

A STAGGERING 5 MICROSECONDS

So watch out once start accessing the variable 2000 times in rapid succession as then it will approach 1 ms

It's still 16 times slower than normal property access. But I don't like to debate about it, I just wanted to point out that Reflection is slow.
 
Just implement a common interface, or use RPC. Take your pick.
 
Back
Top