Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 committed Jan 4, 2025
2 parents d622176 + b5ebcfe commit 8cbec60
Show file tree
Hide file tree
Showing 53 changed files with 1,626 additions and 38 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build-test-debug-win.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Build & Test Debug Windows

on:
push:
branches: [ master, staging, trying ]
merge_group:
pull_request:
types: [ opened, reopened, synchronize, ready_for_review ]
branches: [ master ]
# push:
# branches: [ master, staging, trying ]
# merge_group:
# pull_request:
# types: [ opened, reopened, synchronize, ready_for_review ]
# branches: [ master ]
workflow_dispatch: # ручной запуск

jobs:
Expand Down Expand Up @@ -60,4 +60,4 @@ jobs:
runs-on: windows-latest
steps:
- name: CI succeeded
run: exit 0
run: exit 0
62 changes: 62 additions & 0 deletions Content.Client/ADT/OfferItem/OfferItemIndicatorsOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System.Numerics;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Shared.Enums;
using Robust.Shared.Utility;

namespace Content.Client.ADT.OfferItem;

public sealed class OfferItemIndicatorsOverlay : Overlay
{
private readonly IInputManager _inputManager;
private readonly IEntityManager _entMan;
private readonly IEyeManager _eye;
private readonly OfferItemSystem _offer;

private readonly Texture _sight;

public override OverlaySpace Space => OverlaySpace.ScreenSpace;

private readonly Color _mainColor = Color.White.WithAlpha(0.3f);
private readonly Color _strokeColor = Color.Black.WithAlpha(0.5f);
private readonly float _scale = 0.6f; // 1 is a little big

public OfferItemIndicatorsOverlay(IInputManager input, IEntityManager entMan, IEyeManager eye, OfferItemSystem offerSys)
{
_inputManager = input;
_entMan = entMan;
_eye = eye;
_offer = offerSys;

var spriteSys = _entMan.EntitySysManager.GetEntitySystem<SpriteSystem>();
_sight = spriteSys.Frame0(new SpriteSpecifier.Rsi(new ResPath("/Textures/ADT/Misc/give_item.rsi"), "give_item"));
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
return _offer.IsInOfferMode() && base.BeforeDraw(in args);
}

protected override void Draw(in OverlayDrawArgs args)
{
var mousePosMap = _eye.PixelToMap(_inputManager.MouseScreenPosition);

if (mousePosMap.MapId != args.MapId)
return;

var limitedScale = Math.Min(1.25f, (args.ViewportControl as Control)?.UIScale ?? 1f) * _scale;

DrawSight(_sight, args.ScreenHandle, _inputManager.MouseScreenPosition.Position, limitedScale);
}

private void DrawSight(Texture sight, DrawingHandleScreen screen, Vector2 centerPos, float scale)
{
var sightSize = sight.Size * scale;
var expandedSize = sightSize + new Vector2(7);

screen.DrawTextureRect(sight, UIBox2.FromDimensions(centerPos - sightSize * 0.5f, sightSize), _strokeColor);
screen.DrawTextureRect(sight, UIBox2.FromDimensions(centerPos - expandedSize * 0.5f, expandedSize), _mainColor);
}
}
44 changes: 44 additions & 0 deletions Content.Client/ADT/OfferItem/OfferItemSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Shared.ADT.OfferItem;
using Content.Shared.ADT.CCVar;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Shared.Configuration;

namespace Content.Client.ADT.OfferItem;

public sealed class OfferItemSystem : SharedOfferItemSystem
{
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEyeManager _eye = default!;

public override void Initialize()
{
base.Initialize();
Subs.CVar(_cfg, ADTCCVars.OfferModeIndicatorsPointShow, OnShowOfferIndicatorsChanged, true);
}

public override void Shutdown()
{
_overlayManager.RemoveOverlay<OfferItemIndicatorsOverlay>();
base.Shutdown();
}

public bool IsInOfferMode()
{
var entity = _playerManager.LocalEntity;

return entity is not null && IsInOfferMode(entity.Value);
}

private void OnShowOfferIndicatorsChanged(bool isShow)
{
if (isShow)
_overlayManager.AddOverlay(new OfferItemIndicatorsOverlay(_inputManager, EntityManager, _eye, this));
else
_overlayManager.RemoveOverlay<OfferItemIndicatorsOverlay>();
}
}
57 changes: 57 additions & 0 deletions Content.Client/ADT/Salvage/MegafaunaVisualsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Content.Client.DamageState;
using Content.Client.Humanoid;
using Content.Shared.ADT.Salvage;
using Content.Shared.ADT.Salvage.Components;
using Content.Shared.Mobs.Components;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Client.ADT.Salvage;

public sealed class MegafaunaVisualsSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IPlayerManager _playerMan = default!;
[Dependency] private readonly SpriteSystem _spriteSystem = default!;
[Dependency] private readonly HumanoidAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly IEntityManager _entManager = default!;

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

SubscribeLocalEvent<MegafaunaComponent, AppearanceChangeEvent>(OnAppearanceChange);
}

private void OnAppearanceChange(EntityUid uid, MegafaunaComponent comp, ref AppearanceChangeEvent args)
{
if (!TryComp<SpriteComponent>(uid, out var sprite))
return;
if (!TryComp<DamageStateVisualsComponent>(uid, out var state))
return;
if (!TryComp<MobStateComponent>(uid, out var mob))
return;
if (!state.States.TryGetValue(mob.CurrentState, out var layers))
return;

if (_appearance.TryGetData<bool>(uid, AshdrakeVisuals.Swoop, out var swoop))
{
if (!sprite.LayerMapTryGet("drake_swoop", out var index))
index = sprite.LayerMapReserveBlank("drake_swoop");
sprite.LayerSetState(index, "swoop");
sprite.LayerSetVisible(index, swoop);

foreach (var (key, _) in layers)
{
if (!sprite.LayerMapTryGet(key, out var layer)) continue;
sprite.LayerSetVisible(layer, !swoop);
}
}
}
}
2 changes: 2 additions & 0 deletions Content.Client/Input/ContentContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public static void SetupContexts(IInputContextContainer contexts)
human.AddFunction(ContentKeyFunctions.Arcade1);
human.AddFunction(ContentKeyFunctions.Arcade2);
human.AddFunction(ContentKeyFunctions.ToggleCrawling);///ADT crawling
human.AddFunction(ContentKeyFunctions.OfferItem); // ADT-Tweak

// actions should be common (for ghosts, mobs, etc)
common.AddFunction(ContentKeyFunctions.OpenActionsMenu);

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.Butto
AddButton(ContentKeyFunctions.MoveStoredItem);
AddButton(ContentKeyFunctions.RotateStoredItem);
AddButton(ContentKeyFunctions.SaveItemLocation);

AddButton(ContentKeyFunctions.OfferItem); // ADT-Tweak
AddHeader("ui-options-header-interaction-adv");
AddButton(ContentKeyFunctions.SmartEquipBackpack);
AddButton(ContentKeyFunctions.SmartEquipBelt);
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
StyleClasses="LabelKeyText"/>
<CheckBox Name="ShowHeldItemCheckBox" Text="{Loc 'ui-options-show-held-item'}" />
<CheckBox Name="ShowCombatModeIndicatorsCheckBox" Text="{Loc 'ui-options-show-combat-mode-indicators'}" />
<CheckBox Name="ShowOfferModeIndicatorsCheckBox" Text="{Loc 'ui-options-show-offer-mode-indicators'}" /> <!-- ADT-Tweak -->
<Label Text="{Loc 'ui-options-general-storage'}"
StyleClasses="LabelKeyText"/>
<CheckBox Name="OpaqueStorageWindowCheckBox" Text="{Loc 'ui-options-opaque-storage-window'}" />
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Client.UserInterface.Screens;
using Content.Shared.ADT.CCVar; // ADT-Tweak
using Content.Shared.CCVar;
using Content.Shared.HUD;
using Robust.Client.AutoGenerated;
Expand Down Expand Up @@ -52,7 +53,7 @@ public MiscTab()
Control.AddOptionCheckBox(CCVars.ChatEnableFancyBubbles, FancySpeechBubblesCheckBox);
Control.AddOptionCheckBox(CCVars.ChatFancyNameBackground, FancyNameBackgroundsCheckBox);
Control.AddOptionCheckBox(CCVars.StaticStorageUI, StaticStorageUI);

Control.AddOptionCheckBox(ADTCCVars.OfferModeIndicatorsPointShow, ShowOfferModeIndicatorsCheckBox); // ADT-Tweak
Control.Initialize();
}
}
57 changes: 57 additions & 0 deletions Content.Server/ADT/OfferItemSystem/OfferItemSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Content.Shared.Alert;
using Content.Shared.ADT.OfferItem;
using Content.Shared.Mobs.Systems;
using Content.Shared.Hands.Components;

namespace Content.Server.ADT.OfferItem;

public sealed class OfferItemSystem : SharedOfferItemSystem
{
[Dependency] private readonly AlertsSystem _alertsSystem = default!;

[Dependency] private readonly MobStateSystem _mobStateSystem = default!;

private float _offerAcc = 0;
private const float OfferAccMax = 3f;

public override void Update(float frameTime)
{
_offerAcc += frameTime;

if (_offerAcc >= OfferAccMax)
_offerAcc -= OfferAccMax;
else
return;

var query = EntityQueryEnumerator<OfferItemComponent, HandsComponent>();
while (query.MoveNext(out var uid, out var offerItem, out var hands))
{
if (hands.ActiveHand is null)
continue;

if (offerItem.Hand is not null && hands.Hands[offerItem.Hand].HeldEntity is null)
if (offerItem.Target is not null)
{
UnReceive(offerItem.Target.Value, offerItem: offerItem);
offerItem.IsInOfferMode = false;
Dirty(uid, offerItem);
}
else
UnOffer(uid, offerItem);

if (!offerItem.IsInReceiveMode)
{
_alertsSystem.ClearAlert(uid, OfferAlert);
continue;
}

if (_mobStateSystem.IsCritical(uid) || _mobStateSystem.IsDead(uid))
{
_alertsSystem.ClearAlert(uid, OfferAlert);
continue;
}

_alertsSystem.ShowAlert(uid, OfferAlert);
}
}
}
Loading

0 comments on commit 8cbec60

Please sign in to comment.