Skip to content

OnStructureDemolish

Usage

  • Return a non-null value to override default behavior

Example Autogenerated

csharp
private object OnStructureDemolish( DecayEntity instance, BasePlayer player, bool false )
{
    Puts( "OnStructureDemolish works!" );
    return null;
}
csharp
private object OnStructureDemolish( DecayEntity instance, BasePlayer player, bool true )
{
    Puts( "OnStructureDemolish works!" );
    return null;
}

Location

  • DecayEntity::DoDemolish(BaseEntity.RPCMessage msg)
  • DecayEntity::DoImmediateDemolish(BaseEntity.RPCMessage msg)
csharp
[RPC_Server.MaxDistance(3f)]
[RPC_Server]
private void DoDemolish(RPCMessage msg)
{
	if (msg.player.CanInteract() && CanDemolish(msg.player) && Interface.CallHook("OnStructureDemolish", this, msg.player, false) == null)
	{
		StabilityEntity stabilityEntity = this as StabilityEntity;
		if (stabilityEntity != null)
		{
			Facepunch.Rust.Analytics.Azure.OnBuildingBlockDemolished(msg.player, stabilityEntity);
//---
csharp
[RPC_Server.MaxDistance(3f)]
[RPC_Server]
private void DoImmediateDemolish(RPCMessage msg)
{
	if (msg.player.CanInteract() && msg.player.IsAdmin && Interface.CallHook("OnStructureDemolish", this, msg.player, true) == null)
	{
		StabilityEntity stabilityEntity = this as StabilityEntity;
		if (stabilityEntity != null)
		{
			Facepunch.Rust.Analytics.Azure.OnBuildingBlockDemolished(msg.player, stabilityEntity);
//---

Released under the MIT License.