public static void SpawnItemsFromReaction(ElementItem elementItem, Compound compound, int hydrogensSpawned, int compoundsSpawned) { //Give a chance to spawn Hydrogen item(s) as well as the corresponding CompoundItem TerraScience.SpawnScienceItem((int)elementItem.item.position.X, (int)elementItem.item.position.Y, 16, 16, ElementName(Element.Hydrogen), hydrogensSpawned, new Vector2(Main.rand.NextFloat(-1, 1), -4.2f)); TerraScience.SpawnScienceItem((int)elementItem.item.position.X, (int)elementItem.item.position.Y, 16, 16, CompoundUtils.CompoundName(compound, false), compoundsSpawned, new Vector2(Main.rand.NextFloat(-0.5f, 0.5f), -2.1f)); if (elementItem.item.stack > compoundsSpawned) { //If there's more than one item in this stack, reduce the stack and the timer int oldStack = elementItem.item.stack; elementItem.item.stack -= compoundsSpawned; elementItem.ReactionTimer = (int)(elementItem.ReactionTimer * (float)elementItem.item.stack / oldStack * Main.rand.NextFloat(0.7f, 0.95f)); } else { //Otherwise, make the item despawn (and make its stack to 0 for good measure) elementItem.item.stack = 0; elementItem.item.active = false; } }
public override bool Drop(int i, int j) { TerraScience.SpawnScienceItem(i * 16, j * 16, 16, 16, Name); return(true); }