Skip to content

Commit

Permalink
Merge pull request #739 from Roudenn/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Sep 9, 2024
2 parents 362a40d + f561bec commit 2df460b
Show file tree
Hide file tree
Showing 205 changed files with 41,617 additions and 24,727 deletions.
18 changes: 15 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<!-- ЭТО ШАБЛОН ВАШЕГО PULL REQUEST. Текст между стрелками - это комментарии - они не будут видны в PR. -->
<!-- Руководство по созданиям PR'ов: https://docs.spacestation14.io/en/getting-started/pr-guideline -->

## Описание PR
<!-- Ниже опишите ваш Pull Request. Что он изменяет? На что еще это может повлиять? Постарайтесь описать все внесённые вами изменения! -->

**Медиа**
## Зачем / Баланс
<!-- Discuss how this would affect game balance or explain why it was changed. Link any relevant discussions or issues. -->
<!-- Обсудите как это может повлиять на игровой баланс или почему это было изменено. Оставьте ссылки на любые дискуссии или Issue связанные с вашим PR. -->

## Медиа
<!-- Если приемлемо, добавьте скриншоты для демонстрации вашего PR. Если ваш PR представляет собой визуальное изменение, добавьте
скриншоты, иначе он может быть закрыт. -->

Expand All @@ -13,24 +18,31 @@
- [ ] Я внимательно просмотрел все свои изменения и багов в них не нашёл.
- [ ] Я запускал локальный сервер со своими изменениями и всё протестировал.
- [ ] Я добавил скриншот/видео демонстрации PR в игре, **или** этот PR этого не требует.
- [ ] Я прочёл и следую [Руководству по изменениям и созданию Pull Request](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html).

## Важные изменения
<!-- Опишите весь список изменений в коде, включая namespace'ы, изменения в публичных классах/методах/полях, переименование прототипов. -->

**Изменения**
## Изменения
<!--
Здесь вы можете написать список изменений, который будет автоматически добавлен в игру, когда ваш PR будет принят.
В журнал изменений следует помещать только то, что действительно важно игрокам.
В списке изменений тип значка не является часть предложения, поэтому явно указывайте - Добавлен, Удалён, Изменён.
В списке изменений тип значка не является частью предложения, поэтому явно указывайте - Добавлен, Удалён, Изменён.
плохо: - add: Новый инструмент для инженеров
хорошо: - add: Добавлен новый инструмент для инженеров
Вы можете указать своё имя после символа :cl: именно оно будет отображаться в журнале изменений (иначе будет использоваться ваше имя на GitHub)
Например: :cl: Ian
Ниже есть закоментированный фрагмент-заготовка, можете убрать стрелочки и использовать его как основу.
-->

<!--
:cl:
- add: Добавлено веселье!
- remove: Убрано веселье!
- tweak: Изменено веселье!
- fix: Исправлено веселье!
-->
96 changes: 96 additions & 0 deletions Content.Client/Mining/MiningOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System.Numerics;
using Content.Shared.Mining.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.Mining;

public sealed class MiningOverlay : Overlay
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPlayerManager _player = default!;
private readonly EntityLookupSystem _lookup;
private readonly SpriteSystem _sprite;
private readonly TransformSystem _xform;

private readonly EntityQuery<SpriteComponent> _spriteQuery;
private readonly EntityQuery<TransformComponent> _xformQuery;

public override OverlaySpace Space => OverlaySpace.WorldSpace;
public override bool RequestScreenTexture => false;

private readonly HashSet<Entity<MiningScannerViewableComponent>> _viewableEnts = new();

public MiningOverlay()
{
IoCManager.InjectDependencies(this);

_lookup = _entityManager.System<EntityLookupSystem>();
_sprite = _entityManager.System<SpriteSystem>();
_xform = _entityManager.System<TransformSystem>();

_spriteQuery = _entityManager.GetEntityQuery<SpriteComponent>();
_xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
}

protected override void Draw(in OverlayDrawArgs args)
{
var handle = args.WorldHandle;

if (_player.LocalEntity is not { } localEntity ||
!_entityManager.TryGetComponent<MiningScannerViewerComponent>(localEntity, out var viewerComp))
return;

if (viewerComp.LastPingLocation == null)
return;

var scaleMatrix = Matrix3Helpers.CreateScale(Vector2.One);

_viewableEnts.Clear();
_lookup.GetEntitiesInRange(viewerComp.LastPingLocation.Value, viewerComp.ViewRange, _viewableEnts);
foreach (var ore in _viewableEnts)
{
if (!_xformQuery.TryComp(ore, out var xform) ||
!_spriteQuery.TryComp(ore, out var sprite))
continue;

if (xform.MapID != args.MapId || !sprite.Visible)
continue;

if (!sprite.LayerMapTryGet(MiningScannerVisualLayers.Overlay, out var idx))
continue;
var layer = sprite[idx];

if (layer.ActualRsi?.Path == null || layer.RsiState.Name == null)
continue;

var gridRot = xform.GridUid == null ? 0 : _xformQuery.CompOrNull(xform.GridUid.Value)?.LocalRotation ?? 0;
var rotationMatrix = Matrix3Helpers.CreateRotation(gridRot);

var worldMatrix = Matrix3Helpers.CreateTranslation(_xform.GetWorldPosition(xform));
var scaledWorld = Matrix3x2.Multiply(scaleMatrix, worldMatrix);
var matty = Matrix3x2.Multiply(rotationMatrix, scaledWorld);
handle.SetTransform(matty);

var spriteSpec = new SpriteSpecifier.Rsi(layer.ActualRsi.Path, layer.RsiState.Name);
var texture = _sprite.GetFrame(spriteSpec, TimeSpan.FromSeconds(layer.AnimationTime));

var animTime = (viewerComp.NextPingTime - _timing.CurTime).TotalSeconds;


var alpha = animTime < viewerComp.AnimationDuration
? 0
: (float) Math.Clamp((animTime - viewerComp.AnimationDuration) / viewerComp.AnimationDuration, 0f, 1f);
var color = Color.White.WithAlpha(alpha);

handle.DrawTexture(texture, -(Vector2) texture.Size / 2f / EyeManager.PixelsPerMeter, layer.Rotation, modulate: color);

}
handle.SetTransform(Matrix3x2.Identity);
}
}
54 changes: 54 additions & 0 deletions Content.Client/Mining/MiningOverlaySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Content.Shared.Mining.Components;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;

namespace Content.Client.Mining;

/// <summary>
/// This handles the lifetime of the <see cref="MiningOverlay"/> for a given entity.
/// </summary>
public sealed class MiningOverlaySystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;

private MiningOverlay _overlay = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<MiningScannerViewerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<MiningScannerViewerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<MiningScannerViewerComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<MiningScannerViewerComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

_overlay = new();
}

private void OnPlayerAttached(Entity<MiningScannerViewerComponent> ent, ref LocalPlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(Entity<MiningScannerViewerComponent> ent, ref LocalPlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
}

private void OnInit(Entity<MiningScannerViewerComponent> ent, ref ComponentInit args)
{
if (_player.LocalEntity == ent)
{
_overlayMan.AddOverlay(_overlay);
}
}

private void OnShutdown(Entity<MiningScannerViewerComponent> ent, ref ComponentShutdown args)
{
if (_player.LocalEntity == ent)
{
_overlayMan.RemoveOverlay(_overlay);
}
}
}
6 changes: 0 additions & 6 deletions Content.Client/Mining/OreVeinVisualsComponent.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Robust.Client.GameObjects;
using Robust.Shared.Utility;

namespace Content.Client.Nutrition.EntitySystems;

Expand Down Expand Up @@ -50,6 +49,7 @@ private void UpdateFoodVisuals(Entity<FoodSequenceStartPointComponent> start, Sp
sprite.AddBlankLayer(index);
sprite.LayerMapSet(keyCode, index);
sprite.LayerSetSprite(index, state.Sprite);
sprite.LayerSetScale(index, state.Scale);

//Offset the layer
var layerPos = start.Comp.StartPosition;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Power/APC/ApcBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public ApcBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
protected override void Open()
{
base.Open();

_menu = this.CreateWindow<ApcMenu>();
_menu.SetEntity(Owner);
_menu.OnBreaker += BreakerPressed;
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void SetFireStacks(EntityUid uid, float stacks, FlammableComponent? flamm
}
else
{
flammable.OnFire = ignite;
flammable.OnFire |= ignite;
UpdateAppearance(uid, flammable);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Discord/DiscordWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ private string GetUrl(WebhookIdentifier identifier)
{
return await _http.GetFromJsonAsync<WebhookData>(url);
}
catch
catch (Exception e)
{
_sawmill.Error($"Error getting discord webhook data. Stack trace:\n{Environment.StackTrace}");
_sawmill.Error($"Error getting discord webhook data.\n{e}");
return null;
}
}
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Content.Server.IoC;
using Content.Server.Maps;
using Content.Server.NodeContainer.NodeGroups;
using Content.Server.Objectives;
using Content.Server.Players;
using Content.Server.Players.JobWhitelist;
using Content.Server.Players.PlayTimeTracking;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/IoC/ServerContentIoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Content.Server.Maps;
using Content.Server.MoMMI;
using Content.Server.NodeContainer.NodeGroups;
using Content.Server.Objectives;
using Content.Server.Players;
using Content.Server.Players.JobWhitelist;
using Content.Server.Players.PlayTimeTracking;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Materials;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;

namespace Content.Server.Materials.Components;

/// <summary>
/// This is used for a machine that turns produce into a specified material.
/// </summary>
[RegisterComponent, Access(typeof(ProduceMaterialExtractorSystem))]
public sealed partial class ProduceMaterialExtractorComponent : Component
{
/// <summary>
/// The material that produce is converted into
/// </summary>
[DataField]
public ProtoId<MaterialPrototype> ExtractedMaterial = "Biomass";

/// <summary>
/// List of reagents that determines how much material is yielded from a produce.
/// </summary>
[DataField]
public List<ProtoId<ReagentPrototype>> ExtractionReagents = new()
{
"Nutriment"
};

[DataField]
public SoundSpecifier? ExtractSound = new SoundPathSpecifier("/Audio/Effects/waterswirl.ogg");
}
17 changes: 15 additions & 2 deletions Content.Server/Materials/MaterialReclaimerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,22 @@ private void SpawnChemicalsFromComposition(EntityUid reclaimer,
}

// if the item we inserted has reagents, add it in.
if (_solutionContainer.TryGetDrainableSolution(item, out _, out var drainableSolution))

if (reclaimerComponent.OnlyReclaimDrainable)
{
// Are we a recycler? Only use drainable solution.
if (_solutionContainer.TryGetDrainableSolution(item, out _, out var drainableSolution))
{
totalChemicals.AddSolution(drainableSolution, _prototype);
}
}
else
{
totalChemicals.AddSolution(drainableSolution, _prototype);
// Are we an industrial reagent grinder? Use extractable solution.
if (_solutionContainer.TryGetExtractableSolution(item, out _, out var extractableSolution))
{
totalChemicals.AddSolution(extractableSolution, _prototype);
}
}

if (!_solutionContainer.TryGetSolution(reclaimer, reclaimerComponent.SolutionContainerId, out var outputSolution) ||
Expand Down
48 changes: 48 additions & 0 deletions Content.Server/Materials/ProduceMaterialExtractorSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Linq;
using Content.Server.Botany.Components;
using Content.Server.Materials.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Interaction;
using Robust.Server.Audio;

namespace Content.Server.Materials;

public sealed class ProduceMaterialExtractorSystem : EntitySystem
{
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<ProduceMaterialExtractorComponent, AfterInteractUsingEvent>(OnInteractUsing);
}

private void OnInteractUsing(Entity<ProduceMaterialExtractorComponent> ent, ref AfterInteractUsingEvent args)
{
if (args.Handled)
return;

if (!this.IsPowered(ent, EntityManager))
return;

if (!TryComp<ProduceComponent>(args.Used, out var produce))
return;

if (!_solutionContainer.TryGetSolution(args.Used, produce.SolutionName, out var solution))
return;

// Can produce even have fractional amounts? Does it matter if they do?
// Questions man was never meant to answer.
var matAmount = solution.Value.Comp.Solution.Contents
.Where(r => ent.Comp.ExtractionReagents.Contains(r.Reagent.Prototype))
.Sum(r => r.Quantity.Float());
_materialStorage.TryChangeMaterialAmount(ent, ent.Comp.ExtractedMaterial, (int) matAmount);

_audio.PlayPvs(ent.Comp.ExtractSound, ent);
QueueDel(args.Used);
args.Handled = true;
}
}
2 changes: 1 addition & 1 deletion Content.Server/Mining/MiningSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Content.Server.Mining.Components;
using Content.Shared.Destructible;
using Content.Shared.Mining;
using Content.Shared.Mining.Components;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Robust.Shared.Prototypes;
Expand Down
Loading

0 comments on commit 2df460b

Please sign in to comment.