Skip to content
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

Sound rework for turbine & transformer #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kumpuu
Copy link

@kumpuu kumpuu commented Nov 4, 2022

Both were not even audible to me before...
They get a bit louder with increasing load, and the turbine also changes in pitch. It sounds really cool if I may say so!
turbine.ogg is actually from a real nuclear power plant in sweden if you can believe it.

Some code changes were required, so I figured out how to use dnSpy. I manually copied this, hope I didn't forget anything.

Rimatomics.Turbine
	public void StartWickSustainer()
	{
		SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick);
		this.wickSustainer = SoundDef.Named("Turbine").TrySpawnSustainer(info);
	}

	public override void Tick()
	{
		...
			this.RPM = Mathf.SmoothDamp(this.RPM, target, ref this.SpinVelocity, 2f, 100f, 0.0166f); //changed smooth time to 2 because it sounds better
			this.powerOutput = this.GenerationCapacity * this.RPM;
			if (this.RPM > 0.01f)
			{
				if (this.wickSustainer == null)
				{
					this.StartWickSustainer();
					return;
				}
				if (this.wickSustainer.Ended)
				{
					this.StartWickSustainer();
					return;
				}
				this.wickSustainer.info.volumeFactor = Mathf.Lerp(1f, 1.35f, this.RPM);
				this.wickSustainer.info.pitchFactor = Mathf.Lerp(0.6f, 1.3f, this.RPM);
				this.wickSustainer.Maintain();
		}
	}


Rimatomics.Transformer
	public override void Tick()
	{
		...
		if (this.power.PowerOutput > 5000f)
		{
			if (this.humSustainer == null)
			{
				this.StartHumSustainer();
			}
			else if (this.humSustainer.Ended)
			{
				this.StartHumSustainer();
			}
			else
			{
				this.humSustainer.info.volumeFactor = Mathf.Lerp(0.5f, 1.6f, this.power.PowerOutput / this.MaxCap);
				this.humSustainer.Maintain();
			}
		}
		...
	}

P.S: Tested in 1.3

assembly changes:

Rimatomics.Turbine
	public void StartWickSustainer()
	{
		SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick);
		this.wickSustainer = SoundDef.Named("Turbine").TrySpawnSustainer(info);
	}

	public override void Tick()
	{
	...
			this.wickSustainer.info.volumeFactor = Mathf.Lerp(0.8f, 1.2f, this.RPM);
			this.wickSustainer.info.pitchFactor = Mathf.Lerp(0.6f, 1.4f, this.RPM);
			this.wickSustainer.Maintain();
		}
	}
More in line with vanilla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant