r2mods/ilspy_dump/ror2_csproj/RoR2.Items/NearbyDamageBonusBodyBehavi...

50 lines
1.0 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
namespace RoR2.Items;
public class NearbyDamageBonusBodyBehavior : BaseItemBodyBehavior
{
private GameObject nearbyDamageBonusIndicator;
private bool indicatorEnabled
{
get
{
return nearbyDamageBonusIndicator;
}
set
{
if (indicatorEnabled != value)
{
if (value)
{
GameObject original = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/NearbyDamageBonusIndicator");
nearbyDamageBonusIndicator = Object.Instantiate(original, base.body.corePosition, Quaternion.identity);
nearbyDamageBonusIndicator.GetComponent<NetworkedBodyAttachment>().AttachToGameObjectAndSpawn(base.gameObject);
}
else
{
Object.Destroy(nearbyDamageBonusIndicator);
nearbyDamageBonusIndicator = null;
}
}
}
}
[ItemDefAssociation(useOnServer = true, useOnClient = false)]
private static ItemDef GetItemDef()
{
return RoR2Content.Items.NearbyDamageBonus;
}
private void OnEnable()
{
indicatorEnabled = true;
}
private void OnDisable()
{
indicatorEnabled = false;
}
}