Skip to content

Commit

Permalink
fix height label and default species heights
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Feb 5, 2024
1 parent 5dcb908 commit 08494f3
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 11 deletions.
3 changes: 0 additions & 3 deletions Content.Client/Humanoid/HumanoidAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
using Robust.Client.GameObjects;
using Robust.Client.Console;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

Expand All @@ -14,8 +13,6 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly MarkingManager _markingManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;

public override void Initialize()
{
Expand Down
7 changes: 5 additions & 2 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt
prototype = _speciesList.Find(x => x.ID == Profile.Species) ?? _speciesList.First(); // Just in case

var value = Math.Clamp(args.Value, prototype.MinHeight, prototype.MaxHeight);
CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", Profile.Height.ToString().Remove(4)));
var height = value.ToString(CultureInfo.InvariantCulture);
CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", height.Length > 4 ? height[..4] : height));
SetProfileHeight(value);
};

Expand Down Expand Up @@ -1059,7 +1060,9 @@ private void UpdateHeightControls()
_heightSlider.MinValue = species.MinHeight;
_heightSlider.Value = Profile.Height;
_heightSlider.MaxValue = species.MaxHeight;
CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", Profile.Height.ToString().Remove(4)));

var height = Profile.Height.ToString(CultureInfo.InvariantCulture);
CHeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", height.Length > 4 ? height[..4] : height));
}
// Parkstation-HeightSlider End

Expand Down
25 changes: 21 additions & 4 deletions Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,26 @@ public void SetSex(EntityUid uid, Sex sex, bool sync = true, HumanoidAppearanceC
}
}

// Parkstation-HeightSlider Start
/// <summary>
/// Set a humanoid mob's sex. This will not change their gender.
/// </summary>
/// <param name="uid">The humanoid mob's UID.</param>
/// <param name="height">The height to set the mob to.</param>
/// <param name="sync">Whether to immediately synchronize this to the humanoid mob, or not.</param>
/// <param name="humanoid">Humanoid component of the entity</param>
public void SetHeight(EntityUid uid, float height, bool sync = true, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid) || Math.Abs(humanoid.Height - height) < 0.01f)
return;

humanoid.Height = height;

if (sync)
Dirty(humanoid);
}
// Parkstation-HeightSlider End

/// <summary>
/// Loads a humanoid character profile directly onto this humanoid mob.
/// </summary>
Expand Down Expand Up @@ -330,10 +350,7 @@ public virtual void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile,
}

humanoid.Age = profile.Age;
// Parkstation-HeightSlider Start
humanoid.Height = profile.Height;
_heightAdjust.SetScale(uid, profile.Height);
// Parkstation-HeightSlider End
_heightAdjust.SetScale(uid, profile.Height); // Parkstation-HeightSlider

Dirty(humanoid);
}
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public static HumanoidCharacterProfile RandomWithSpecies(string species = Shared

public string Name { get; private set; }
public string FlavorText { get; private set; }
[DataField("species")] // Parkstation-HeightSlider // :)
public string Species { get; private set; }

[DataField("height")]
Expand Down
15 changes: 13 additions & 2 deletions Content.Shared/SimpleStation14/HeightAdjust/HeightAdjustSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Humanoid;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Robust.Shared.Physics;
Expand All @@ -9,14 +10,15 @@ public sealed class HeightAdjustSystem : EntitySystem
{
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedContentEyeSystem _eye = default!;
[Dependency] private readonly SharedHumanoidAppearanceSystem _appearance = default!;


/// <summary>
/// Changes the density of fixtures and zoom of eyes based on a provided float scale
/// </summary>
/// <param name="uid">The entity to modify values for</param>
/// <param name="scale">The scale to multiply values by</param>
/// <returns>True if both operations succeeded</returns>
/// <returns>True if all operations succeeded</returns>
public bool SetScale(EntityUid uid, float scale)
{
var succeeded = true;
Expand All @@ -26,9 +28,18 @@ public bool SetScale(EntityUid uid, float scale)
succeeded = false;

if (EntityManager.TryGetComponent<FixturesComponent>(uid, out var fixtures))
{
foreach (var fixture in fixtures.Fixtures)
// _physics.SetDensity(uid, fixture.Key, fixture.Value, fixture.Value.Density * scale); // If you want to do the same thing without changing size
{
// _physics.SetDensity(uid, fixture.Key, fixture.Value, fixture.Value.Density * scale); // This does the same thing as below, just without modifying the fixture size
_physics.SetRadius(uid, fixture.Key, fixture.Value, fixture.Value.Shape, fixture.Value.Shape.Radius * scale);
}
}
else
succeeded = false;

if (EntityManager.HasComponent<HumanoidAppearanceComponent>(uid))
_appearance.SetHeight(uid, scale);
else
succeeded = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
components:
- type: HumanoidAppearance
species: Felinid
initial: Felinid
- type: Fixtures
fixtures: # TODO: This needs a second fixture just for mob collisions.
fix1:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- type: humanoidProfile
id: Felinid
profile:
species: Felinid
height: 0.8

0 comments on commit 08494f3

Please sign in to comment.