/// <summary> /// to be called to raise the destruction event /// </summary> /// <param name="e"></param> protected virtual void OnDestruction(BlockDestructEvent e) { EventHandler <BlockDestructEvent> handler = this.destruction; if (handler != null) { handler(this, e); } }
/// <summary> /// gets called if the block is mined /// call to mine a block immediately /// </summary> /// <param name="silent">wether the block should be hidden or not</param> public void Destruct(Boolean silent = false) { // set hitpoints to minus one this.hitpoints = -1; // call onDestruction event BlockDestructEvent destructevent = new BlockDestructEvent(); destructevent.silent = silent; this.OnDestruction(destructevent); }
/// <summary> /// to be called to raise the destruction event /// </summary> /// <param name="e"></param> protected virtual void OnDestruction(BlockDestructEvent e) { EventHandler<BlockDestructEvent> handler = this.destruction; if (handler != null) handler(this, e); }
/// <summary> /// handles the event thats get raised if a blocks get destructed /// </summary> /// <param name="block">the block</param> /// <param name="arguments">the arguments</param> private void OnBlockDestructed(object block, BlockDestructEvent arguments) { try { Block theBlock = block as Block; this.OnDestructBlockEvent(theBlock); } catch (Exception e) { FenrirGame.Instance.Log(LogLevel.Error, "failed to handle block destruction event! " + ((Block)block).GridPosition + " - " + e.Message); FenrirGame.Instance.Log(LogLevel.Error, e.StackTrace); } }