/// <summary> /// Runs the script event with the given input. /// </summary> /// <param name="prio">The priority to run with.</param> /// <param name="oevt">The details of the script to be ran.</param> /// <returns>The event details after firing.</returns> public void Run(int prio, StructureDamagedEventArgs oevt) { StructureDamagedScriptEvent evt = (StructureDamagedScriptEvent)Duplicate(); evt.Cancelled = oevt.Cancelled; evt.Structure = oevt.Structure; evt.Amount = oevt.Amount; evt.Call(prio); oevt.Amount = evt.Amount; oevt.Cancelled = evt.Cancelled; }
public static bool StructureDamaged(Structure structure, ref ushort amount) { // TODO: causes? StructureTag structureTag = new StructureTag(structure); if (amount >= structure.health) { StructureDestroyedEventArgs deathevt = new StructureDestroyedEventArgs(); deathevt.Structure = structureTag; deathevt.Amount = new NumberTag(amount); UnturnedFreneticEvents.OnStructureDestroyed.Fire(deathevt); amount = (ushort)deathevt.Amount.Internal; return deathevt.Cancelled || EntityDestroyed(structureTag, ref amount); } StructureDamagedEventArgs evt = new StructureDamagedEventArgs(); evt.Structure = structureTag; evt.Amount = new NumberTag(amount); UnturnedFreneticEvents.OnStructureDamaged.Fire(evt); amount = (ushort)evt.Amount.Internal; return evt.Cancelled || EntityDamaged(structureTag, ref amount); }