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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

HorseDung #539

wants to merge 1 commit 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.
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