internal static void RunDamageStructure(UnturnedStructure structure, ref ushort damage, ref bool cancel) { if (OnDamageStructure == null) { return; } OnDamageStructure(structure, ref damage, (damage > structure.Health), ref cancel); if (damage > structure.Health && !cancel) { RunDestroyStructure(structure, ref cancel); } }
internal static void RunStructureRemoved(UnturnedStructure structure, ref bool cancel) { if (OnStructureRemoved == null) { return; } OnStructureRemoved(structure, ref cancel); if (!cancel) { UnturnedServer.RemoveStructure(structure); } }
public static void askRepair(this Structure stru, ushort amount) { // Set the events bool cancel = false; // Run the events StructureEvents.RunRepairStructure(UnturnedStructure.FindStructure(stru), ref amount, ref cancel); // Run the original function if (!cancel) { DetourManager.CallOriginal(typeof(Structure).GetMethod("askRepair", BindingFlags.Instance | BindingFlags.Public), stru, amount); } }
public void askSalvageStructure(CSteamID steamID, byte x, byte y, ushort index) { StructureRegion structureRegion; bool cancel = false; if (StructureManager.tryGetRegion(x, y, out structureRegion)) { StructureData data = structureRegion.structures[(int)index]; StructureEvents.RunSalvageStructure(UnturnedStructure.Create(data), ref cancel); } if (!cancel) { DetourManager.CallOriginal(typeof(StructureManager).GetMethod("askSalvageStructure", BindingFlags.Instance | BindingFlags.Public), StructureManager.instance, steamID, x, y, index); } }
internal static void RunStructureCreated(StructureData structure, ref bool cancel) => OnStructureCreated?.Invoke(UnturnedStructure.Create(structure), ref cancel);
internal static void RunSalvageStructure(UnturnedStructure structure, ref bool cancel) => OnSalvageStructure?.Invoke(structure, ref cancel);
internal static void RunRepairStructure(UnturnedStructure structure, ref ushort repair, ref bool cancel) => OnRepairStructure?.Invoke(structure, ref repair, ref cancel);