CyberneticHearingAid 1.0.0
This commit is contained in:
parent
e1fd2d30d6
commit
4e651b074c
157
CyberneticHearingAid/CyberneticHeightenedHearingEffect.cs
Executable file
157
CyberneticHearingAid/CyberneticHeightenedHearingEffect.cs
Executable file
|
@ -0,0 +1,157 @@
|
|||
using System;
|
||||
using XRL.UI;
|
||||
using XRL.World.Capabilities;
|
||||
using XRL.World.Parts;
|
||||
|
||||
// this is 95% copy/pasted from decompiled vanilla HeightenedHearingEffect
|
||||
// only thing added was a reference to the implant because it has the part rather than the implantee
|
||||
namespace XRL.World.Effects
|
||||
{
|
||||
[Serializable]
|
||||
public class CyberneticHeightenedHearingEffect : Effect
|
||||
{
|
||||
public bool bIdentified;
|
||||
public int Level = 1;
|
||||
public GameObject Listener;
|
||||
public GameObject Implant;
|
||||
public CyberneticHeightenedHearingEffect() => Duration = 1;
|
||||
|
||||
public CyberneticHeightenedHearingEffect(int Level, GameObject Listener)
|
||||
: this()
|
||||
{
|
||||
this.Level = Level;
|
||||
this.Listener = Listener;
|
||||
}
|
||||
|
||||
public CyberneticHeightenedHearingEffect(int Level, GameObject Listener, GameObject Implant)
|
||||
: this()
|
||||
{
|
||||
this.Level = Level;
|
||||
this.Listener = Listener;
|
||||
this.Implant = Implant;
|
||||
}
|
||||
|
||||
public override int GetEffectType() => 2048;
|
||||
|
||||
public override bool SameAs(Effect e) => false;
|
||||
|
||||
public override string GetDescription() => (string)null;
|
||||
|
||||
private bool BadListener()
|
||||
{
|
||||
Listener = null;
|
||||
Object.RemoveEffect(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CheckListen()
|
||||
{
|
||||
if (!GameObject.validate(ref Listener) || !Listener.IsPlayer())
|
||||
{
|
||||
return BadListener();
|
||||
}
|
||||
|
||||
if (!(Implant.GetPart("CyberneticsHearingAid") is CyberneticsHearingAid part))
|
||||
{
|
||||
return BadListener();
|
||||
}
|
||||
|
||||
int num = Object.DistanceTo(Listener);
|
||||
if (num > part.Radius)
|
||||
{
|
||||
return BadListener();
|
||||
}
|
||||
|
||||
if (bIdentified)
|
||||
{
|
||||
CheckInterruptAutoExplore();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Object.CurrentCell == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (((int)((100 + (10 * Level)) / Math.Pow(num + 9, 2.0) * 100.0)).in100())
|
||||
{
|
||||
bIdentified = true;
|
||||
CheckInterruptAutoExplore();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CheckInterruptAutoExplore()
|
||||
{
|
||||
if (!bIdentified || !GameObject.validate(ref Listener) || !Listener.IsPlayer() || !AutoAct.IsInterruptable() || AutoAct.IsGathering() || !Listener.IsRelevantHostile(Object))
|
||||
return;
|
||||
AddPlayerMessage(Listener.GenerateSpotMessage(Object, verb: "hear"));
|
||||
AutoAct.Interrupt(null, null, Object);
|
||||
}
|
||||
|
||||
public override bool Apply(GameObject Object)
|
||||
{
|
||||
if (Object.pBrain != null)
|
||||
Object.pBrain.Hibernating = false;
|
||||
CheckListen();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Register(GameObject Object)
|
||||
{
|
||||
Object.RegisterEffectEvent(this, "EndTurn");
|
||||
base.Register(Object);
|
||||
}
|
||||
|
||||
public override void Unregister(GameObject Object)
|
||||
{
|
||||
Object.UnregisterEffectEvent(this, "EndTurn");
|
||||
base.Unregister(Object);
|
||||
}
|
||||
|
||||
public bool HeardAndNotSeen(GameObject obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!obj.IsVisible())
|
||||
return true;
|
||||
Cell currentCell = obj.CurrentCell;
|
||||
return currentCell != null && (!currentCell.IsLit() || !currentCell.IsExplored());
|
||||
}
|
||||
|
||||
public override bool FinalRender(RenderEvent E, bool bAlt)
|
||||
{
|
||||
if (!HeardAndNotSeen(Object) || !Object.CanHypersensesDetect())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (bIdentified)
|
||||
{
|
||||
E.HighestLayer = 0;
|
||||
Object.Render(E);
|
||||
E.ColorString = "&K";
|
||||
E.DetailColor = "K";
|
||||
E.RenderString = Object.pRender.RenderString;
|
||||
E.Tile = !Options.UseTiles ? null : Object.pRender.Tile;
|
||||
E.CustomDraw = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
E.RenderString = "&K?";
|
||||
E.Tile = null;
|
||||
E.CustomDraw = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool FireEvent(Event E)
|
||||
{
|
||||
if (E.ID == "EndTurn" && Object != null)
|
||||
CheckListen();
|
||||
return base.FireEvent(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
CyberneticHearingAid/CyberneticsHearingAid.cs
Executable file
50
CyberneticHearingAid/CyberneticsHearingAid.cs
Executable file
|
@ -0,0 +1,50 @@
|
|||
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; }
|
||||
}
|
||||
|
||||
public override bool SameAs(IPart p) => false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
11
CyberneticHearingAid/ObjectBlueprints.xml
Executable file
11
CyberneticHearingAid/ObjectBlueprints.xml
Executable file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<objects>
|
||||
<object Name="HearingAid" Inherits="BaseCyberneticsEquipment_2point">
|
||||
<part Name="Physics" Weight="0" />
|
||||
<part Name="Description" Short="Cybernetic electroacoustic system that amplifies, compresses, and normalises environmental sound to make it more audible." />
|
||||
<part Name="Render" DisplayName="{{Y|hearing aid}}" Tile="Items/hearingaid.png" TileColor="&C" DetailColor="r" />
|
||||
<part Name="CyberneticsBaseItem" Slots="Head,Face" Cost="2" BehaviorDescription="Gain unnaturally acute hearing." />
|
||||
<part Name="CyberneticsHearingAid" />
|
||||
<tag Name="StartingCybernetic:General" />
|
||||
</object>
|
||||
</objects>
|
BIN
CyberneticHearingAid/Textures/Items/hearingaid.png
Executable file
BIN
CyberneticHearingAid/Textures/Items/hearingaid.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 726 B |
8
CyberneticHearingAid/manifest.json
Executable file
8
CyberneticHearingAid/manifest.json
Executable file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"id": "CyberneticHearingAid",
|
||||
"title": "{{cybernetic hearing aid|Cybernetic Hearing Aid}}",
|
||||
"description": "Enhanced hearing mutation but in cybernetics form.",
|
||||
"version": "1.0.0",
|
||||
"author": "{{paisley|Celediel}}",
|
||||
"previewImage": "preview.png"
|
||||
}
|
BIN
CyberneticHearingAid/preview.png
Executable file
BIN
CyberneticHearingAid/preview.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
8
CyberneticHearingAid/workshop.json
Executable file
8
CyberneticHearingAid/workshop.json
Executable file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"WorkshopId": 2721172552,
|
||||
"Title": "Cybernetic Hearing Aid",
|
||||
"Description": "Like the Enhanced Hearing mutation, but a cybernetic.",
|
||||
"Tags": "Script,Cybernetic",
|
||||
"Visibility": "0",
|
||||
"ImagePath": "preview.png"
|
||||
}
|
Loading…
Reference in a new issue