Skip to content

Commit

Permalink
Merge branch 'master' into dadadadad
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkiich authored May 7, 2024
2 parents 4a241b1 + dddedbf commit 7d5d935
Show file tree
Hide file tree
Showing 800 changed files with 37,701 additions and 24,188 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
with:
host: ${{ secrets.BUILDS_HOST }}
username: ${{ secrets.BUILDS_USERNAME }}
password: ${{ secrets.BUILD_PASSWORD }}
key: ${{ secrets.BUILDS_SSH_KEY }}
port: ${{ secrets.BUILDS_PORT }}
script: python3 ~/manifest.py --version ${{ github.sha }}

Expand Down
2 changes: 1 addition & 1 deletion ADT_STATION
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Content.Shared.BluespaceHarvester;
using JetBrains.Annotations;

namespace Content.Client.BluespaceHarvester;

[UsedImplicitly]
public sealed class BluespaceHarvesterBoundUserInterface : BoundUserInterface
{
private BluespaceHarvesterMenu? _window;

public BluespaceHarvesterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_window = new BluespaceHarvesterMenu(this);
_window.OnClose += Close;
_window?.OpenCentered();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

_window?.Dispose();
_window = null;
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not BluespaceHarvesterBoundUserInterfaceState current)
return;

_window?.UpdateState(current);
}

public void SendTargetLevel(int level)
{
SendMessage(new BluespaceHarvesterTargetLevelMessage(level));
}

public void SendBuy(Shared.BluespaceHarvester.BluespaceHarvesterCategory category)
{
SendMessage(new BluespaceHarvesterBuyMessage(category));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Control xmlns="https://spacestation14.io">
<GridContainer Margin = "2 0 0 0" Columns="2">
<Label Name="CategoryLabel" Text="Category" StyleClasses="StatusFieldTitle"></Label>
<Button Name="CategoryButton" Text="10000" StyleClasses="OpenRight" Access="Public"/>
</GridContainer>
</Control>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Content.Shared.BluespaceHarvester;

namespace Content.Client.BluespaceHarvester;

[GenerateTypedNameReferences]
public sealed partial class BluespaceHarvesterCategory : Control
{
public BluespaceHarvesterCategory(BluespaceHarvesterCategoryInfo category, bool canBuy)
{
RobustXamlLoader.Load(this);

CategoryLabel.Text = Loc.GetString($"bluespace-harvester-category-{Enum.GetName(typeof(Shared.BluespaceHarvester.BluespaceHarvesterCategory), category.Type)}");

CategoryButton.Text = $"{category.Cost}";
CategoryButton.Disabled = !canBuy;
}
}
46 changes: 46 additions & 0 deletions Content.Client/BluespaceHarvester/BluespaceHarvesterMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'bluespace-harvester-window-title'}"
MinSize="480 360">
<BoxContainer Orientation="Vertical">
<Label Text="{Loc 'bluespace-harvester-window-lable-input'}"/>
<controls:HLine Color="#404040" Thickness="2" Margin="0 5"/>
<GridContainer Margin="2 0 0 0" Columns="2">
<Label Text="{Loc 'bluespace-harvester-window-level-input'}" StyleClasses="StatusFieldTitle"/>
<LineEdit Name="InputLevelBar" PlaceHolder="0" HorizontalExpand="True" Margin ="0 4"/>
<Label Text="{Loc 'bluespace-harvester-window-level-target'}" StyleClasses="StatusFieldTitle"/>
<Label Name="TargetLevel" Text="0"/>
<Label Text="{Loc 'bluespace-harvester-window-level-current'}" StyleClasses="StatusFieldTitle"/>
<Label Name="CurrentLevel" Text="0"/>
<Label Text="{Loc 'bluespace-harvester-window-level-desired'}" StyleClasses="StatusFieldTitle"/>
<ProgressBar Name="DesiredBar"
HorizontalExpand="True"
MinValue="0"
MaxValue="1"
SetHeight="25"/>
<Label Text="{Loc 'bluespace-harvester-window-power-usage'}" StyleClasses="StatusFieldTitle"/>
<Label Name="PowerUsageLabel" Text="0w"/>
<Label Text="{Loc 'bluespace-harvester-window-power-next'}" StyleClasses="StatusFieldTitle"/>
<Label Name="PowerUsageNextLabel" Text="0w"/>
<Label Text="{Loc 'bluespace-harvester-window-power-surplus'}" StyleClasses="StatusFieldTitle"/>
<Label Name="PowerSuppliertLabel" Text="0w"/>
</GridContainer>
<Control/>
<Label Text="{Loc 'bluespace-harvester-window-lable-output'}"/>
<controls:HLine Color="#404040" Thickness="2" Margin="0 5"/>
<GridContainer Margin="2 0 10 0" Columns="2">
<BoxContainer Orientation="Vertical">
<GridContainer Margin="2 0 0 0" Columns="2">
<Label Text="{Loc 'bluespace-harvester-window-points-available'}" StyleClasses="StatusFieldTitle"/>
<Label Name="AvailablePointsLabel" Text="0"/>
<Label Text="{Loc 'bluespace-harvester-window-points-generation'}" StyleClasses="StatusFieldTitle"/>
<Label Name="GenerationPointsLabel" Text="0"/>
<Label Text="{Loc 'bluespace-harvester-window-points-total'}" StyleClasses="StatusFieldTitle"/>
<Label Name="TotalPontsLabel" Text="0"/>
</GridContainer>
</BoxContainer>
<BoxContainer Name="Categories" Orientation="Vertical">
</BoxContainer>
</GridContainer>
</BoxContainer>
</controls:FancyWindow>
60 changes: 60 additions & 0 deletions Content.Client/BluespaceHarvester/BluespaceHarvesterMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.BluespaceHarvester;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.BluespaceHarvester;

[GenerateTypedNameReferences]
public sealed partial class BluespaceHarvesterMenu : FancyWindow
{
private readonly BluespaceHarvesterBoundUserInterface _owner;

public BluespaceHarvesterMenu(BluespaceHarvesterBoundUserInterface owner)
{
RobustXamlLoader.Load(this);

_owner = owner;

InputLevelBar.OnTextEntered += (args) =>
{
if (!int.TryParse(args.Text, out var level) || level < 0 || level > 20)
{
InputLevelBar.Text = "0";
return;
}

_owner.SendTargetLevel(level);
};

// EntityView.SetEntity(_owner.Owner);
}

public void UpdateState(BluespaceHarvesterBoundUserInterfaceState state)
{
TargetLevel.Text = $"{state.TargetLevel}";
CurrentLevel.Text = $"{state.CurrentLevel}";
DesiredBar.Value = ((float)state.CurrentLevel) / ((float)state.MaxLevel);

PowerUsageLabel.Text = Loc.GetString("power-monitoring-window-value", ("value", state.PowerUsage));
PowerUsageNextLabel.Text = Loc.GetString("power-monitoring-window-value", ("value", state.PowerUsageNext));
PowerSuppliertLabel.Text = Loc.GetString("power-monitoring-window-value", ("value", state.PowerSuppliert));

AvailablePointsLabel.Text = $"{state.Points}";
TotalPontsLabel.Text = $"{state.TotalPoints}";
GenerationPointsLabel.Text = $"{state.PointsGen}";

Categories.RemoveAllChildren();
foreach (var category in state.Categories)
{
var child = new BluespaceHarvesterCategory(category, state.Points >= category.Cost);

child.CategoryButton.OnButtonDown += (args) =>
{
_owner.SendBuy(category.Type);
};

Categories.AddChild(child);
}
}
}
5 changes: 5 additions & 0 deletions Content.Client/Input/ContentContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public static void SetupContexts(IInputContextContainer contexts)
common.AddFunction(boundKey);
}

foreach (var boundKey in ContentKeyFunctions.GetLoadoutBoundKeys())
{
common.AddFunction(boundKey);
}

var aghost = contexts.New("aghost", "common");
aghost.AddFunction(EngineKeyFunctions.MoveUp);
aghost.AddFunction(EngineKeyFunctions.MoveDown);
Expand Down
144 changes: 144 additions & 0 deletions Content.Client/Movement/Systems/ClientWaddleAnimationSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Content.Client.Buckle;
using Content.Client.Gravity;
using Content.Shared.ActionBlocker;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;

namespace Content.Client.Movement.Systems;

public sealed class ClientWaddleAnimationSystem : SharedWaddleAnimationSystem
{
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
[Dependency] private readonly GravitySystem _gravity = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly BuckleSystem _buckle = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;

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

// Start waddling
SubscribeAllEvent<StartedWaddlingEvent>((msg, args) => StartWaddling(args.SenderSession.AttachedEntity));

// Handle concluding animations
SubscribeLocalEvent<WaddleAnimationComponent, AnimationCompletedEvent>(OnAnimationCompleted);

// Stop waddling
SubscribeAllEvent<StoppedWaddlingEvent>((msg, args) => StopWaddling(args.SenderSession.AttachedEntity));
}

private void StartWaddling(EntityUid? uid)
{
if (
!EntityIsValid(uid, out var entity, out var component) ||
_animation.HasRunningAnimation(entity.Value, component.KeyName) ||
_gravity.IsWeightless(entity.Value) ||
_buckle.IsBuckled(entity.Value) ||
_mobState.IsIncapacitated(entity.Value) ||
!TryComp<InputMoverComponent>(entity, out var mover) ||
!_actionBlocker.CanMove(entity.Value, mover)
)
return;

PlayWaddleAnimationUsing(entity.Value, component, CalculateAnimationLength(component, mover), CalculateTumbleIntensity(component));
}

private static float CalculateTumbleIntensity(WaddleAnimationComponent component)
{
return component.LastStep ? 360 - component.TumbleIntensity : component.TumbleIntensity;
}

private static float CalculateAnimationLength(WaddleAnimationComponent component, InputMoverComponent mover)
{
return mover.Sprinting ? component.AnimationLength * component.RunAnimationLengthMultiplier : component.AnimationLength;
}

private void OnAnimationCompleted(EntityUid uid, WaddleAnimationComponent component, AnimationCompletedEvent args)
{
if (args.Key != component.KeyName)
return;

if (!TryComp<InputMoverComponent>(uid, out var mover))
return;

PlayWaddleAnimationUsing(uid, component, CalculateAnimationLength(component, mover), CalculateTumbleIntensity(component));
}

private void StopWaddling(EntityUid? uid)
{
if (
!EntityIsValid(uid, out var entity, out var component) ||
!_animation.HasRunningAnimation(entity.Value, component.KeyName)
)
return;

_animation.Stop(entity.Value, component.KeyName);

if (!TryComp<SpriteComponent>(entity.Value, out var sprite))
return;

// Note that this is a hard-write to this sprite, not some layer-based operation. If this is called whilst a sprite
// is lying down, it will make the sprite stand up, which usually looks wrong.
sprite.Offset = new Vector2();
sprite.Rotation = Angle.FromDegrees(0);
}

private bool EntityIsValid(EntityUid? uid, [NotNullWhen(true)] out EntityUid? entity, [NotNullWhen(true)] out WaddleAnimationComponent? component)
{
entity = null;
component = null;

if (!uid.HasValue)
return false;

entity = uid.Value;

return TryComp(entity, out component);
}

private void PlayWaddleAnimationUsing(EntityUid uid, WaddleAnimationComponent component, float len, float tumbleIntensity)
{
component.LastStep = !component.LastStep;

var anim = new Animation()
{
Length = TimeSpan.FromSeconds(len),
AnimationTracks =
{
new AnimationTrackComponentProperty()
{
ComponentType = typeof(SpriteComponent),
Property = nameof(SpriteComponent.Rotation),
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), 0),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(tumbleIntensity), len/2),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), len/2),
}
},
new AnimationTrackComponentProperty()
{
ComponentType = typeof(SpriteComponent),
Property = nameof(SpriteComponent.Offset),
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(new Vector2(), 0),
new AnimationTrackProperty.KeyFrame(component.HopIntensity, len/2),
new AnimationTrackProperty.KeyFrame(new Vector2(), len/2),
}
}
}
};

_animation.Play(uid, anim, component.KeyName);
}
}
4 changes: 4 additions & 0 deletions Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.Butto
{
AddButton(boundKey);
}
foreach (var boundKey in ContentKeyFunctions.GetLoadoutBoundKeys())
{
AddButton(boundKey);
}

AddHeader("ui-options-header-shuttle");
AddButton(ContentKeyFunctions.ShuttleStrafeUp);
Expand Down
Loading

0 comments on commit 7d5d935

Please sign in to comment.