Jump to content

[1.2.1] RoverScience Revisted (2.2.0) - Better, interactive science for rovers!


theSpeare

Recommended Posts

1 hour ago, theSpeare said:

Thanks @allista! You are clearly better at spotting these things than me. OnUpdate is clearly throwing a null since there is no instance of "Rover" as it's not declared in OnStart(); My confusion however lies with the code I took from KER a long long time ago:


// TAKEN FROM KERBAL ENGINEERING REDUX SOURCE by cybutek
// http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB
// This is to hopefully prevent multiple instances of this PartModule from running simultaneously
public bool IsPrimary {
	get {
		if (this.vessel != null) {
			foreach (Part part in this.vessel.parts) {
				if (part.Modules.Contains (this.ClassID)) {
					if (this.part == part) {
						return true;
					} else {
						break;
					}
				}
			}
		}
		return false;
	}
}

 

This property tells you one simple thing: if this PartModule resides in the first part that contains a RoverScience module within the current vessel. This is a standard way to elect a single working instance, making others idle. So in general there are always multiple instances, but they decide among themselves who's gonna do the work.

What seems strange to me is that you're mixing this with the singleton pattern. Usually you use a static T Instance field to make a singleton class which will indeed have only a single existing instance. This is appropriate e.g. for a GUI window, a scenario module, etc. But the whole point of a PartModule is that it is tied to a particular part instance and should operate independently from another one on another part, on another vessel.

Consider this:

1) you have a single loaded vessel with several RoverScience modules. They, by means of IsPrimary property, elect one of them to do the work; and after that you set this module instance as the static Instance. Then you could use this Instance to access the active RoverScience (as you do now).

2) you have two (or more) such vessels in close proximity. But there's only one static Instance in the whole ApplicationDomain. So either you need to set the Instance each time a vessel is switched or modified, or you need to query the active vessel for its active RoverScience module in singleton classes that are currently use the Instance field.

I would prefer the later, as it moves the responsibility of tracking the active instance to classes that require such active instance; while a vessel should not care if there are other vessels running RS.

In any case, what you need is to use the GameEvents.onVesselChange and probably GameEvents.onVesselWasModified events to handle vessel switches and changes of vessel's part content (staging, part destruction, etc.). This will also allow you to cache the IsPrimary state (and many other things), as it can only change when a vessel is modified so there's no need to compute its value each frame.

Link to comment
Share on other sites

3 minutes ago, theSpeare said:

While I'm at work with some bug fixes, does anyone have any suggestions for new features, or changes to the current ones?

I've a suggestion to add to the aesthetic of homing down and scanning objects.  I know you create an object to act as the point in which science can be scanned, as seen in the GIF you posted; to add to this, you could spawn a scatter object, such as a rock, at the center of the waypoint (as a way to visually identify a point of interest).

Otherwise, very nice mod, I like it.

Link to comment
Share on other sites

15 minutes ago, theSpeare said:

Love this idea of spawning a rock. Will probably have to learn how to do this now! Added to the feature list, and thanks very much. :)

You'd need to find a way of searching through KSP's AssetBundle to find the prefab for a rock dependent on the body you're landed on; as we've seen with terrain scatters, there are prefabs for those objects to be spawned.

The other alternative, is to create the model yourself, either procedurally (within code) or not.  For simplicity's sake, the object could be a small sphere with a texture you load within your plugin applied to it.

A few options there to get you going.

Edit: On a side note, you don't necessarily have to limit yourself to rocks; you could spawn a wreckage (as seen in the start menu of the game, with the 'Mun of bust' message).

Edited by udk_lethal_d0se
Link to comment
Share on other sites

I will so +1 the "spawn something" idea. Otherwise, you're just thinking "what is this, slightly more dirt-like dirt?"

I'm not sure what the incidence of science zones is (it seemed rather high,) but it might be stuff other than rocks too.

Side question - do you get (significantly) more science near Munoliths and the like? That might be something to check for as well.

Link to comment
Share on other sites

@udk_lethal_d0se neat! I could probably try something with spawning in existing parts, and disabling their mesh colliders. I had a big problem with spawning in the sphere GameObject as there's no easy way of determining surface altitude with a given long/lat position (which is why I changed it to a very long cylinder extending up and down.

@etmoonshade at the moment no check is being made while being near anomalies. I suppose if I had the long/lat positions I could check and add a bonus to the science generation. Neat idea.

The incidence of science spots are rather high, as I wanted to reduce the amount of time driving around randomly, and increase the effort in driving between science spots and selecting the best one. I think I need to re-write the tutorial to something more user friendly.

Is there anything particularly irritating while playing this mod that you guys wish me to revise, or fix?

Link to comment
Share on other sites

Just now, theSpeare said:

@udk_lethal_d0se neat! I could probably try something with spawning in existing parts, and disabling their mesh colliders. I had a big problem with spawning in the sphere GameObject as there's no easy way of determining surface altitude with a given long/lat position (which is why I changed it to a very long cylinder extending up and down.

There's a way around the issue of getting the ground position, and that is to raycast down and use the hit.point.y as the surface coordinate.

I've had a thought, another option in regards to spawning in objects is to create a custom part (ie, rock) and spawn that in instead; it will already be loaded into AvailableParts. Have a play about and see what you come up with.

Link to comment
Share on other sites

Yeah I have a friend that might be able to make me some models; I'll bribe them with food or something. I'll see if I can do anything interesting in that sense.

Got any advice on raycasting? Never done it before (sorry about putting you through all these questions), and I'm pretty new at Unity stuff. Seems like if I can get the raycasting method down I can probably just change the marker back to a sphere, as that definitely looked better than the towering cylinder.

Link to comment
Share on other sites

3 minutes ago, theSpeare said:

Yeah I have a friend that might be able to make me some models; I'll bribe them with food or something. I'll see if I can do anything interesting in that sense.

Got any advice on raycasting? Never done it before (sorry about putting you through all these questions), and I'm pretty new at Unity stuff. Seems like if I can get the raycasting method down I can probably just change the marker back to a sphere, as that definitely looked better than the towering cylinder.

Hah, that's alright then.

Don't worry about it, I generally live and breathe Unity and C#, not just for KSP stuff.  Unity documentation is very good for this sort of thing and they have nice examples; here's a link to the relevant page: https://docs.unity3d.com/ScriptReference/Physics.Raycast.html

Don't hesitate to ask for advice, I'm always happy to assist.

Edited by udk_lethal_d0se
Link to comment
Share on other sites

minor update: thanks to @udk_lethal_d0se I got raycasting to work, so now I have terrain altitude. I switched back to a half-sphere marker now because I think it looks nicer.

Also fixed a big nullreference problem. 2.0.3 should not be working, but 2.0.4 should be fine now. I'll get a start on the other features now.

https://github.com/theSpeare/RoverScience-Revisit/releases/tag/2.0.4

 

Edited by theSpeare
Link to comment
Share on other sites

Updated to 2.1!

https://github.com/theSpeare/RoverScience-Revisit/releases/

Interesting Rocks

  • Rock models are now spawned at Science Spots. Two different models are included; more will be added later. Credit to udk_lethal_dose for the idea. Textures are a bit big; will look at compressing these further.

Anomalies

  • Anomalies are now recognized! Credit to etmoonshade for the idea.
  • ScienceSpots will generate at anomalies once rovers are within 100m and no other scienceSpots are active.
  • Anomalies provide a flat 300 science points (500, if you're lucky). However you can only analyze an anomaly ONCE.
  • Most anomalies have been charted, except for two Duna ones that do not appear above ground anymore.
  • Go send your rovers out to those anomalies!
Link to comment
Share on other sites

Update 2.1.2

GUI Polish & New Upgrade Type

  • Made GUI prettier. Now with colours and revised text to improve
    understandability.

  • Added new upgrade: "analyzedDecay". Upgrading this will increase the
    number of times a player may analyze before suffering science loss.

  • Quickloading and quicksaving will now restore window positions. GUI
    position and display status is now saved in persistence & quicksave.

  • Updated mod page. Much cleaner explanation of this mod, with new updated images.

As usual any feedback / feature requests appreciated. Thank you to everyone for supporting and staying with me while I update this mod :) You guys make it worth it.

 

Link to comment
Share on other sites

KSP 1.2 Pre-release compatibility.

https://github.com/theSpeare/RoverScience-Revisit/releases/tag/2.2.0-B1

I've made some progress on compatibility. The plugin seems to be working fine so I pushed this "patch" really quickly to get RoverScience compatible with 1.2-pre. Some rewriting had to be done to readjust to the some new KSP quirks. I haven't tested it thoroughly so please be careful with your saves.

Please please please report any problems that you encounter and include your output_log.txt.

EDIT: CKAN integration should be complete soon (but will only work for 1.1.3). I will not bother with CKAN integration for KSP 1.2 until the pre-release is over. For those who want pre-release versions of RoverScience, please follow the GitHub release page.

Edited by theSpeare
Link to comment
Share on other sites

Just to ask?

Would it be possible to make the rove brain cleanable by a high level (4 star+) scientist or engineer (at a reduced science cost?) so that it can be reused without having to build new rovers, but still having to send maintenance missions?

This would add some interaction between driving the rovers around and eva activities?

 

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...