2023-12-19 01:26:05 -05:00
|
|
|
using System;
|
|
|
|
|
|
|
|
using XRL.World.Effects;
|
|
|
|
|
|
|
|
namespace XRL.World.Parts
|
|
|
|
{
|
|
|
|
[Serializable]
|
|
|
|
public class CyberneticsHearingAid : IPart
|
|
|
|
{
|
|
|
|
public int Radius
|
|
|
|
{
|
|
|
|
get { return GetAvailableComputePowerEvent.GetFor(ParentObject.Implantee) + 20; }
|
|
|
|
}
|
|
|
|
public int Level
|
|
|
|
{
|
|
|
|
get { return GetAvailableComputePowerEvent.GetFor(ParentObject.Implantee) + 1; }
|
|
|
|
}
|
|
|
|
|
2024-06-16 20:57:37 -04:00
|
|
|
public static int GetRadius(int Level) => Level < 10 ? 3 + Level * 2 : 40;
|
|
|
|
|
|
|
|
public int GetRadius() => CyberneticsHearingAid.GetRadius(this.Level);
|
2023-12-19 01:26:05 -05:00
|
|
|
|
|
|
|
public override bool WantEvent(int ID, int cascade) => base.WantEvent(ID, cascade) || ID == EndTurnEvent.ID || ID == GetShortDescriptionEvent.ID;
|
|
|
|
|
|
|
|
public override bool HandleEvent(EndTurnEvent E)
|
|
|
|
{
|
|
|
|
GameObject implantee = ParentObject.Implantee;
|
|
|
|
if (implantee?.IsPlayer() == true && !IsBroken() && !IsRusted() && !IsEMPed())
|
|
|
|
{
|
|
|
|
Cell currentCell = implantee.CurrentCell;
|
|
|
|
if (currentCell?.OnWorldMap() == false)
|
|
|
|
{
|
|
|
|
foreach (var thing in currentCell.ParentZone.FastSquareSearch(currentCell.X, currentCell.Y, Radius, "Combat"))
|
|
|
|
{
|
|
|
|
if (implantee.DistanceTo(thing) <= Radius && !thing.HasEffect("CyberneticHeightenedHearingEffect"))
|
|
|
|
{
|
|
|
|
thing.ApplyEffect(new CyberneticHeightenedHearingEffect(Level, implantee, ParentObject));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return base.HandleEvent(E);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool HandleEvent(GetShortDescriptionEvent E)
|
|
|
|
{
|
|
|
|
E.Postfix.AppendRules("Compute power on the local lattice increases this item's range.");
|
|
|
|
return base.HandleEvent(E);
|
|
|
|
}
|
|
|
|
public override bool AllowStaticRegistration() => false;
|
|
|
|
}
|
|
|
|
}
|