C#:
using Oxide.Core.Plugins;
using Rust;
using UnityEngine;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("Fun No Decay For TC", "Dopler", "1.3.2")]
[Description("Prevents decay of buildings and TopTier doors/window bars within the Tool Cupboard's area")]
public class FunNoDecayForTC : RustPlugin
{
private HashSet<string> toptierItems;
private void Init()
{
toptierItems = new HashSet<string>
{
"door.hinged.toptier",
"door.double.hinged.toptier",
"door.double.toptier",
"wall.window.bars.toptier" // <-- Добавлены бронированные решетки
};
}
private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
if (entity == null || info?.damageTypes == null || !info.damageTypes.Has(Rust.DamageType.Decay))
return;
BuildingPrivlidge tc = null;
bool shouldPreventDecay = false;
if (entity is BuildingBlock building)
{
if (building.grade == BuildingGrade.Enum.TopTier)
{
tc = building.GetBuildingPrivilege();
shouldPreventDecay = tc != null;
}
}
else if (entity.PrefabName != null)
{
foreach (var itemName in toptierItems)
{
if (entity.PrefabName.Contains(itemName))
{
tc = entity.GetBuildingPrivilege();
shouldPreventDecay = tc != null;
break;
}
}
}
if (shouldPreventDecay)
{
info.damageTypes.Scale(Rust.DamageType.Decay, 0f);
}
}
}
}