Skip to content

Commit

Permalink
Sai v2 (#448)
Browse files Browse the repository at this point in the history
* new SAIShip

* miss maps

* upd

* fix

* fix

* Update bargevsship.yml

---------

Co-authored-by: Kirillcas <[email protected]>
  • Loading branch information
Rxup and Kirillcas authored Feb 4, 2024
1 parent 0a5a968 commit e75d4ae
Show file tree
Hide file tree
Showing 35 changed files with 43,082 additions and 26 deletions.
12 changes: 12 additions & 0 deletions Content.Client/Backmen/Shipyard/UI/ShipyardConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public sealed partial class ShipyardConsoleMenu : FancyWindow
private readonly List<string> _categoryStrings = new();
private string? _category;

private List<string> _allowedGroup = new();

public ShipyardConsoleMenu(ShipyardConsoleBoundUserInterface owner)
{
RobustXamlLoader.Load(this);
Expand Down Expand Up @@ -63,6 +65,14 @@ public void PopulateProducts()
var search = SearchBar.Text.Trim().ToLowerInvariant();
foreach (var prototype in vessels)
{
if (_allowedGroup.Count != 0 && !_allowedGroup.Contains(prototype.Group))
{
continue;
}
if (_allowedGroup.Count == 0 && prototype.Private)
{
continue;
}
// if no search or category
// else if search
// else if category and not search
Expand Down Expand Up @@ -113,5 +123,7 @@ public void PopulateCategories()
public void UpdateState(ShipyardConsoleInterfaceState state)
{
BankAccountLabel.Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", state.Balance.ToString()));
_allowedGroup = state.AllowedGroup;
PopulateProducts();
}
}
2 changes: 1 addition & 1 deletion Content.Client/LateJoin/LateJoinGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public LateJoinGui()
{
var (station, jobId) = x;
Logger.InfoS("latejoin", $"Late joining as ID: {jobId}");
_consoleHost.ExecuteCommand($"joingame {CommandParsing.Escape(jobId)} {station}");
_consoleHost.ExecuteCommand($"notice {CommandParsing.Escape(jobId)} {station}");
Close();
};

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Margin="3 3 3 3" />
<controls:StripeBack>
<BoxContainer Orientation="Horizontal" SeparationOverride="6" Margin="3 3 3 3">
<cc:UICommandButton Command="observe" Name="ObserveButton" Access="Public"
<cc:UICommandButton Command="backmen" Name="ObserveButton" Access="Public"
Text="{Loc 'ui-lobby-observe-button'}"
StyleClasses="ButtonBig"
WindowType="{x:Type lobbyUi:ObserveWarningWindow}" />
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Lobby/UI/ObserveWarningWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<BoxContainer Orientation="Horizontal" >
<Button Name="NevermindButton" Text="{Loc 'observe-nevermind'}" SizeFlagsStretchRatio="1"/>
<Control HorizontalExpand="True" SizeFlagsStretchRatio="2" />
<cc:CommandButton Command="observe" Name="ObserveButton" StyleClasses="Caution" Text="{Loc 'observe-confirm'}" SizeFlagsStretchRatio="1"/>
<cc:CommandButton Command="backmen" Name="ObserveButton" StyleClasses="Caution" Text="{Loc 'observe-confirm'}" SizeFlagsStretchRatio="1"/>
</BoxContainer>
</BoxContainer>
</DefaultWindow>
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public sealed class PostMapInitTest
"TheHive",
"Cogmap",
"Shoukou",
"BargeVsShip",
//end-backmen
"Reach"
};
Expand Down
24 changes: 24 additions & 0 deletions Content.Server/Backmen/Arrivals/AutoRespawnSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Server.GameTicking;
using Content.Server.Ghost.Roles;
using Content.Server.Ghost.Roles.Components;
using Robust.Shared.Console;

namespace Content.Server.Backmen.Arrivals;

public sealed class AutoRespawnSystem : EntitySystem
{
[Dependency] private readonly GameTicker _ticker = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BkmRespawnerComponent, TakeGhostRoleEvent>(OnRequestRespawn, before: new []{ typeof(GhostRoleSystem) });
}

private void OnRequestRespawn(Entity<BkmRespawnerComponent> ent, ref TakeGhostRoleEvent args)
{
args.TookRole = true;
_ticker.Respawn(args.Player);
}
}
7 changes: 7 additions & 0 deletions Content.Server/Backmen/Arrivals/BkmRespawnerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server.Backmen.Arrivals;

[RegisterComponent]
public sealed partial class BkmRespawnerComponent : Component
{

}
22 changes: 19 additions & 3 deletions Content.Server/Backmen/Shipyard/Systems/ShipyardSystem.Consoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Access.Systems;
using Content.Shared.Backmen.Shipyard.Components;
using Content.Shared.Backmen.Shipyard;
using Content.Shared.Backmen.StationAI;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
using Content.Shared.Radio;
Expand Down Expand Up @@ -56,7 +57,7 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component
return;
}

if (!_access.IsAllowed(player, uid))
if (!HasComp<StationAIComponent>(player) && !_access.IsAllowed(player, uid))
{
ConsolePopup(args.Session, Loc.GetString("comms-console-permission-denied"));
PlayDenySound(uid, component);
Expand All @@ -72,6 +73,19 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component
return;
}

if (component.AllowedGroup.Count != 0 && !component.AllowedGroup.Contains(vessel.Group))
{
ConsolePopup(args.Session, Loc.GetString("shipyard-console-invalid-vessel", ("vessel", args.Vessel)));
PlayDenySound(uid, component);
return;
}
else if (component.AllowedGroup.Count == 0 && vessel.Private)
{
ConsolePopup(args.Session, Loc.GetString("shipyard-console-invalid-vessel", ("vessel", args.Vessel)));
PlayDenySound(uid, component);
return;
}

if (vessel.Price <= 0)
return;

Expand Down Expand Up @@ -101,7 +115,8 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component

var newState = new ShipyardConsoleInterfaceState(
bank.Balance,
true);
true,
component.AllowedGroup);

_ui.TrySetUiState(uid, ShipyardConsoleUiKey.Shipyard, newState);
}
Expand All @@ -119,7 +134,8 @@ private void OnConsoleUIOpened(EntityUid uid, ShipyardConsoleComponent component

var newState = new ShipyardConsoleInterfaceState(
bank.Balance,
true);
true,
component.AllowedGroup);

_ui.TrySetUiState(uid, ShipyardConsoleUiKey.Shipyard, newState);
}
Expand Down
78 changes: 78 additions & 0 deletions Content.Server/Backmen/StationAI/AiEyeMover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System.Threading;
using System.Threading.Tasks;
using Content.Server.Backmen.StationAI.Systems;
using Content.Server.SurveillanceCamera;
using Content.Shared.Backmen.StationAI;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.Map;
using Robust.Shared.Timing;

namespace Content.Server.Backmen.StationAI;

public sealed class AiEyeMover : Job<object>
{
private readonly AICameraSystem _cameraSystem;
private readonly EntityLookupSystem _lookup;
private readonly SharedTransformSystem _transform;
private readonly EntityManager _entityManager;

public AiEyeMover(EntityManager entityManager, AICameraSystem cameraSystem, EntityLookupSystem lookup, SharedTransformSystem transform, double maxTime, CancellationToken cancellation = default) : base(maxTime, cancellation)
{
_cameraSystem = cameraSystem;
_lookup = lookup;
_transform = transform;
_entityManager = entityManager;
}

public AiEyeMover(EntityManager entityManager, AICameraSystem cameraSystem, EntityLookupSystem lookup, SharedTransformSystem transform, double maxTime, IStopwatch stopwatch, CancellationToken cancellation = default) : base(maxTime, stopwatch, cancellation)
{
_cameraSystem = cameraSystem;
_lookup = lookup;
_transform = transform;
_entityManager = entityManager;
}

public Entity<AIEyeComponent> Eye { get; set; }
public EntityCoordinates NewPosition { get; set; }


private readonly HashSet<Entity<SurveillanceCameraComponent>> _cameraComponents = new();

protected override async Task<object?> Process()
{
try
{
if (!Eye.Comp.AiCore.HasValue)
{
_entityManager.QueueDeleteEntity(Eye);
return null;
}

var core = Eye.Comp.AiCore.Value;

var gridUid = NewPosition.GetGridUid(_entityManager);

if (gridUid == null || _transform.GetMoverCoordinates(core).GetGridUid(_entityManager) != gridUid)
{
_entityManager.QueueDeleteEntity(Eye);
return null;
}

// cache
if (_cameraSystem.IsCameraActive(Eye))
return null;

var mapPos = NewPosition.ToMap(_entityManager, _transform);

await WaitAsyncTask(Task.Run(() =>
_lookup.GetEntitiesInRange(mapPos, AICameraSystem.CameraEyeRange, _cameraComponents, LookupFlags.Sensors)));

_cameraSystem.HandleMove(Eye, _cameraComponents);
}
finally
{
Eye.Comp.IsProcessingMoveEvent = false;
}
return null;
}
}
17 changes: 16 additions & 1 deletion Content.Server/Backmen/StationAI/InnateItemSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Actions;
using Content.Shared.Backmen.StationAI;
using Content.Shared.Backmen.StationAI.Events;
using Content.Shared.Interaction;
using Content.Shared.Mind.Components;
Expand Down Expand Up @@ -71,10 +72,24 @@ private void StartAfterInteract(EntityUid uid, InnateItemComponent component, In

private void StartBeforeInteract(EntityUid uid, InnateItemComponent component, InnateBeforeInteractActionEvent args)
{
var tarPos = Transform(args.Target);

if (TryComp<AIEyeComponent>(uid, out var aiEyeComponent))
{
if (!aiEyeComponent.AiCore.HasValue || !TerminatingOrDeleted(aiEyeComponent.AiCore.Value))
{
return;
}
if (Transform(aiEyeComponent.AiCore.Value).GridUid != tarPos.GridUid)
{
return;
}
}

EnsureItem(uid, component, args.Item);
if (!component.Items.ContainsKey(args.Item))
return;
var ev = new BeforeRangedInteractEvent(args.Performer, component.Items[args.Item], args.Target, Transform(args.Target).Coordinates, true);
var ev = new BeforeRangedInteractEvent(args.Performer, component.Items[args.Item], args.Target, tarPos.Coordinates, true);
RaiseLocalEvent(component.Items[args.Item], ev, false);
}

Expand Down
Loading

0 comments on commit e75d4ae

Please sign in to comment.