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

HorseDung #539

Closed
wants to merge 3 commits into from
Closed

HorseDung #539

wants to merge 3 commits into from

Conversation

IIIaKa
Copy link
Contributor

@IIIaKa IIIaKa commented Nov 18, 2024

Adding two hooks to track and optionally cancel Dung creation for BaseRidableAnimal.
At the moment, only RidableHorse exists.

1. The OnDungProduction hook is called before the creation of a dung item. Returning a non-null value overrides the default behavior.

object OnDungProduction(BaseRidableAnimal animal, ItemDefinition itemDefinition)
{
    Puts($"{animal.GetType()} is about to produce a dung item({itemDefinition.shortname}).");
    return null;
}

2. The OnDungProduced hook is called after the dung item is created and dropped on the ground. No return behavior.

void OnDungProduced(BaseRidableAnimal animal, Item item)
{
    Puts($"{animal.GetType()} produced a dung item({item.info.shortname}) in quantity: {item.amount}.");
}

Code before:

private void DoDung()
{
	this.dungProduction -= 1f;
	global::ItemManager.Create(this.Dung, 1, 0uL, true).Drop(base.transform.position + -base.transform.forward + Vector3.up * 1.1f + UnityEngine.Random.insideUnitSphere * 0.1f, -base.transform.forward, default(Quaternion));
}

Code after:

private void DoDung()
{
	this.dungProduction -= 1f;
	if (Interface.CallHook("OnDungProduction", this, this.Dung) != null)
	{
		return;
	}
	global::Item OxideGen_ = global::ItemManager.Create(this.Dung, 1, 0uL, true);
	OxideGen_.Drop(base.transform.position + -base.transform.forward + Vector3.up * 1.1f + UnityEngine.Random.insideUnitSphere * 0.1f, -base.transform.forward, default(Quaternion));
	Interface.CallHook("OnDungProduced", this, OxideGen_);
}

Adding two hooks to track Dung creation.
@MrBlue
Copy link
Member

MrBlue commented Dec 30, 2024

Is there a reason you're using Modify hooks instead of simple hooks?
If not can you please update this to use simple hooks instead?

And please make sure you're adding the hooks in the right place. You're currently adding them to the Rust.Clans.Local dll not Assembly-CSharp

@IIIaKa IIIaKa closed this Jan 2, 2025
@IIIaKa IIIaKa deleted the HorseDung branch January 2, 2025 12:21
@IIIaKa IIIaKa mentioned this pull request Jan 2, 2025
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.

2 participants