-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make entrypoint for other mods to add money #67
Comments
EDIT: I have since learned a better way, see my comment down below.
|
Added in 1.15.0. AddMoneyExternal in the MoneySharingHooks class. |
To enable cross compatibility of your mod with ShareSuite, you will need to do the following things:
You must use those additional methods, because an end user might not have ShareSuite installed, so the types for it may not be in the AppDomain, causing the JIT to crash. You may combine those additional methods if you really want to, but make sure they aren't being tried to call whenever you are not sure that ShareSuite is currently available. Here's an example: using ShareSuite;
class myPlugin {
private bool hasShareSuite= false;
public void awake(){
if (Chainloader.PluginInfos.ContainsKey("com.funkfrog_sipondo.sharesuite")) {
this.hasShareSuite = true;
}
}
void myMoneyAddingStuff(CharacterMaster target, int amount){
if(this.hasShareSuite && checkUseShareSuite()){
//maybe divide the amount of money gained by players in the game or something, who knows?
giveMoneyShareSuite(amount);
return;
} else {
target.GiveMoney(amount);
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
bool checkUseShareSuite(){
return ShareSuite.ShareSuite.MoneyIsShared.Value;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
void ShareSuiteGive(int amount)
{
ShareSuite.MoneySharingHooks.AddMoneyExternal(amount);
}
} You'll notice I use |
Is your feature request related to a problem? Please describe.
Mods are currenunable to add money easily when moneysharing is enabled.
Describe the solution you'd like
A method in the main plugin class to add money to a charactermaster/body. This could be found using reflection so that other mods can make themselves compatible with sharesuites moneysharing.
Describe alternatives you've considered
The better solution would be changing how money is handled by sharesuite in the firdt place, but the first solution provides a bandaid fix.
Additional context
BiggerBazaar and Debugtoolkit are noteworthy incompatibilities.
The text was updated successfully, but these errors were encountered: