Jump to content

Question: plugin career mode integration. how?


Recommended Posts

Really nonspecifically (at work, not at home where I could get you code samples), you could check the status of the tech node in question. It should still be something like


var status = ResearchAndDevelopment.Instance.GetTechState(techID);

which you would then check to see if it's "Available". TechID is the internal name for the node, like (can't remember any specific names off the top of me head) "advControl"

Link to comment
Share on other sites

would that restrict it from being in a config file though? Also I'm very new to modding. so actual working code snippet is probably what I'll need.....please :)

If you're using VisualStudio I highly suggest taking a look through the Object Browser, specifically at what's available in the ResearchAndDevelopment class. It also will have code completion which will make things simpler.

As I said before, I'm at work so I won't be able to provide working examples yet, but I can provide things that with a few corrections should work. It'd be nice to know what you're trying to do specifically, so I can try to provide specific examples.

Also, I don't know what you mean by "would that restrict it from being in a config file though?" If you mean that you want to have the option of defining which node has to be unlocked for your plugin to work, then you'd just put the techID in the config file and people could change it to any other valid techID. If you're worrying about tech nodes that are added in the tech tree config file, those will be loaded and will have valid techIDs as well. So both of those cases should be fine (but you might need to check that the techID is valid first. You'd find that out through testing).

Ok, say you have a function that does the work for your plugin called DoPluginWork() which gets called during the FixedUpdate(), or Start(), or on a button press, or whatever else condition you have. If you wanted it to only work when the "survivability" tech node is unlocked, then you might have something like this (once again, you'll need to do a bit of correction on your own to make sure the comparison is correct):


public void DoPluginWork()
{
if (ResearchAndDevelopment.Instance.GetTechState("survivability") == RDTech.State.Available)
{
//Do your plugin's job here
}
}

If it's going to be doing something every single update, that might not be the best way of doing it (lot's of somewhat expensive calls to check the status), but it'll work. The other ways that might work better would be to update the status of a variable during Start() (so once per scene change) or to use the GameEvents.OnTechnologyResearched event.

For checking during Start() you could try this:


string techID = "survivability";
bool techIsUnlocked = false;

public void Start()
{
techIsUnlocked = (ResearchAndDevelopment.Instance.GetTechState(techID) == RDTech.State.Available)
}

public void DoPluginWork()
{
if (techIsUnlocked)
{
//Do your plugin's job here
}
}

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...