forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change laser turrets AI * delete needless usings
- Loading branch information
Showing
6 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Content.Server/SS220/NPC/TargetInLOSIgnoreWindowsPrecondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
using Content.Server.Interaction; | ||
using Content.Server.NPC; | ||
using Content.Server.NPC.HTN.Preconditions; | ||
using Content.Shared.Physics; | ||
|
||
namespace Content.Server.SS220.NPC; | ||
|
||
public sealed partial class TargetInLOSOpaqueCollisionPrecondition : HTNPrecondition | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
private InteractionSystem _interaction = default!; | ||
|
||
[DataField("targetKey")] | ||
public string TargetKey = "Target"; | ||
|
||
[DataField("rangeKey")] | ||
public string RangeKey = "RangeKey"; | ||
|
||
public override void Initialize(IEntitySystemManager sysManager) | ||
{ | ||
base.Initialize(sysManager); | ||
_interaction = sysManager.GetEntitySystem<InteractionSystem>(); | ||
} | ||
|
||
public override bool IsMet(NPCBlackboard blackboard) | ||
{ | ||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner); | ||
|
||
if (!blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager)) | ||
return false; | ||
|
||
var range = blackboard.GetValueOrDefault<float>(RangeKey, _entManager); | ||
|
||
return _interaction.InRangeUnobstructed(owner, target, range, CollisionGroup.Opaque); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
- type: htnCompound | ||
id: LaserTurretCompound | ||
branches: | ||
- tasks: | ||
- !type:HTNPrimitiveTask | ||
operator: !type:UtilityOperator | ||
proto: NearbyGunTargets | ||
|
||
- !type:HTNPrimitiveTask | ||
preconditions: | ||
- !type:KeyExistsPrecondition | ||
key: Target | ||
- !type:TargetInRangePrecondition | ||
targetKey: Target | ||
# TODO: Non-scuffed | ||
rangeKey: RangedRange | ||
- !type:TargetInLOSOpaqueCollisionPrecondition | ||
targetKey: Target | ||
rangeKey: RangedRange | ||
operator: !type:GunOperator | ||
targetKey: Target | ||
requireLOS: true | ||
services: | ||
- !type:UtilityService | ||
id: RangedService | ||
proto: NearbyGunTargets | ||
key: Target | ||
|
||
- tasks: | ||
- !type:HTNCompoundTask | ||
task: IdleSpinCompound |