Skip to content

Commit

Permalink
new SAI skill
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Feb 17, 2024
1 parent 3481776 commit 52a75c4
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Content.Server/Backmen/StationAI/Systems/AICameraSystem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using System.Numerics;
using Content.Server.Interaction;
using Content.Server.Lightning;
using Content.Server.Popups;
using Content.Server.SurveillanceCamera;
using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Backmen.StationAI;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Popups;
using Content.Shared.Traits.Assorted;
using Content.Shared.Weapons.Ranged;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.CPUJob.JobQueues.Queues;
using Robust.Shared.Prototypes;

namespace Content.Server.Backmen.StationAI.Systems;

Expand All @@ -17,6 +24,8 @@ public sealed class AICameraSystem : EntitySystem
[Dependency] private readonly InteractionSystem _interaction = default!;
[Dependency] private readonly SurveillanceCameraSystem _cameraSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly GunSystem _gun = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;


public const float CameraEyeRange = 10f;
Expand All @@ -34,6 +43,28 @@ public override void Initialize()
SubscribeLocalEvent<AIEyeComponent, MoveEvent>(OnEyeMove);
SubscribeLocalEvent<AICameraComponent, SurveillanceCameraDeactivateEvent>(OnActiveCameraDisable);
SubscribeLocalEvent<AIEyeComponent, EyeMoveToCam>(OnMoveToCam);
SubscribeLocalEvent<AIEyeComponent, AIEyeCampShootActionEvent>(OnShootCam);
}

[ValidatePrototypeId<EntityPrototype>]
private const string BulletDisabler = "BulletDisabler";

private void OnShootCam(Entity<AIEyeComponent> ent, ref AIEyeCampShootActionEvent args)
{
if (!ent.Comp.AiCore.HasValue || ent.Comp.Camera == null)
return;

var camMapPos = _transform.GetMapCoordinates(ent.Comp.Camera.Value);
var camPos = Transform(ent.Comp.Camera.Value).Coordinates;
if (args.Target.GetGridUid(EntityManager) != Transform(ent.Comp.AiCore.Value).GridUid)
return;

args.Handled = true;
var targetPos = args.Target.ToMap(EntityManager, _transform);

var ammo = Spawn(BulletDisabler, camPos);
_gun.ShootProjectile(ammo, targetPos.Position - camMapPos.Position, Vector2.One, ent.Comp.Camera.Value, args.Performer);
_audio.PlayPvs("/Audio/Weapons/Guns/Gunshots/taser2.ogg", ent.Comp.Camera.Value);
}

private void OnMoveToCam(Entity<AIEyeComponent> ent, ref EyeMoveToCam args)
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Backmen/StationAI/Systems/AIEyeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ private void OnStartup(EntityUid uid, AIEyeComponent component, ComponentStartup
_visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.AIEye);
_actions.AddAction(uid, ref component.ReturnActionUid, component.ReturnAction);
_actions.AddAction(uid, ref component.CamListUid, component.CamListAction);
_actions.AddAction(uid, ref component.CamShootUid, component.CamShootAction);



var pos = Transform(uid).GridUid;
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/Backmen/StationAI/Components/AIEyeComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public sealed partial class AIEyeComponent : Component

public EntityUid? CamListUid;
public EntProtoId CamListAction = "AIEyeCamAction";

public EntityUid? CamShootUid;
public EntProtoId CamShootAction = "AIEyeCamShootAction";
}

public sealed partial class AIEyeCampShootActionEvent : WorldTargetActionEvent
{
}

public sealed partial class AIEyeCampActionEvent : InstantActionEvent
Expand Down
16 changes: 16 additions & 0 deletions Resources/Prototypes/Backmen/Actions/ai.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
- type: entity
id: AIEyeCamShootAction
name: Cam shoot
description: выстрел из камеры
noSpawn: true
components:
- type: WorldTargetAction
icon:
sprite: Structures/Wallmounts/camera.rsi
state: camera
event: !type:AIEyeCampShootActionEvent
checkCanInteract: false
useDelay: 1
priority: 17
range: 20

- type: entity
id: AIEyeCamAction
name: AI Камеры
description: Отображение камер и телепорт к ним
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@
- CanPilot
- CannotSuicide
- type: Blindable
- type: Gun
fireRate: 2
soundGunshot:
path: /Audio/Weapons/Guns/Gunshots/taser2.ogg
- type: AIEye
# Only ghosts can see the eye
- type: Visibility
Expand Down

0 comments on commit 52a75c4

Please sign in to comment.