Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

robust puddle viscosity #209

Closed
wants to merge 13 commits into from
42 changes: 4 additions & 38 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
<!-- Impstation note: there's no need to read all the official contributing guidelines,
but please DON'T combine upstream changes and your own changes.
Make separate pull requests for separate changes. -->
<!-- Please read these guidelines before opening your PR: https://docs.spacestation14.io/en/getting-started/pr-guideline -->
<!-- The text between the arrows are comments - they will not be visible on your PR. -->

## About the PR
<!-- What did you change in this PR? -->

## Why / Balance
<!-- Why was it changed? Link any discussions or issues here. Please discuss how this would affect game balance. -->

## Technical details
<!-- If this is a code change, summarize at high level how your new code works. This makes it easier to review. -->

## Media
<!--
PRs which make ingame changes (adding clothing, items, new features, etc) are required to have media attached that showcase the changes.
Small fixes/refactors are exempt.
Any media may be used in SS14 progress reports, with clear credit given.

If you're unsure whether your PR will require media, ask a maintainer.
-->

## Requirements
<!--
Due to influx of PR's we require to ensure that PR's are following the correct guidelines.

Please take a moment to read these if its your first time.

Check the boxes below to confirm that you have in fact seen these (put an X in the brackets, like [X]):
-->
- [ ] I have read and I am following the [Pull Request Guidelines](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). I understand that not doing so may get my pr closed at maintainer’s discretion
- [ ] I have added screenshots/videos to this PR showcasing its changes ingame, **or** this PR does not require an ingame showcase

## Breaking changes
<!--
List any breaking changes, including namespace, public class/method/field changes, prototype renames; and provide instructions for fixing them. This will be pasted in #codebase-changes.
Impstation note: there's no need to read all the official contributing guidelines, but please DON'T combine upstream changes with your own changes. Make separate pull requests for separate changes.
-->
<!-- Please read these guidelines before opening your PR: https://docs.spacestation14.io/en/getting-started/pr-guideline -->
<!-- The text between the arrows are comments - they will not be visible on your PR. -->

**Changelog**
<!-- Impstation note: we have our own changelog now, so please DO use this section! -->
<!-- Impstation note: we have our own AUTOMATIC changelog now, so please DO use this section! -->
<!--
Make players aware of new features and changes that could affect how they play the game by adding a Changelog entry. Please read the Changelog guidelines located at: https://docs.spacestation14.io/en/getting-started/pr-guideline#changelog
-->
Expand Down
2 changes: 1 addition & 1 deletion Content.Benchmarks/MapLoadBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task Cleanup()
}

public static readonly string[] MapsSource = { "Empty", "Satlern", "Box", "Bagel", "Dev", "CentComm", "Core", "TestTeg", "Packed", "Omega", "Reach", "Origin", "Meta", "Marathon", "MeteorArena", "Fland", "Oasis", "Cog" };

[ParamsSource(nameof(MapsSource))]
public string Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override void Open()
{
stationName = gridMetaData.EntityName;
}

if (EntMan.TryGetComponent<StationMapComponent>(Owner, out var comp) && comp.ShowLocation)
_window.Set(stationName, gridUid, Owner);
else
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Stylesheets/StyleNano.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ public StyleNano(IResourceCache resCache) : base(resCache)
.Class(StyleClassItemStatusNotHeld)
.Prop("font", notoSansItalic10)
.Prop("font-color", ItemStatusNotHeldColor),

Element<RichTextLabel>()
.Class(StyleClassCrewManifestGender)
.Prop("font", notoSansItalic10)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Announcements/AnnounceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)

shell.WriteLine("Sent!");
}

public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
switch (args.Length)
Expand Down
2 changes: 0 additions & 2 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,5 +515,3 @@ public record struct AntagSelectLocationEvent(ICommonSession? Session, Entity<An
/// </summary>
[ByRefEvent]
public readonly record struct AfterAntagEntitySelectedEvent(ICommonSession? Session, EntityUid EntityUid, Entity<AntagSelectionComponent> GameRule, AntagSelectionDefinition Def);


60 changes: 28 additions & 32 deletions Content.Server/Fluids/EntitySystems/PuddleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContai

_deletionQueue.Remove(entity);
UpdateSlip(entity, entity.Comp, args.Solution);
UpdateSlow(entity, args.Solution);
UpdateSlow(entity, entity.Comp, args.Solution);
UpdateEvaporation(entity, args.Solution);
UpdateAppearance(entity, entity.Comp);
}
Expand Down Expand Up @@ -421,41 +421,37 @@ private void UpdateSlip(EntityUid entityUid, PuddleComponent component, Solution
}
}

private void UpdateSlow(EntityUid uid, Solution solution)
private void UpdateSlow(EntityUid uid, PuddleComponent component, Solution solution)
{
/// declare a maximum viscosity variable
var maxViscosity = 0f;
/// declare a minimum viscosity variable
var minViscosity = 0f;
/// declare a total viscosity variable
var totalViscosity = 0f;

/// for each reagent in the puddle, grab the reagent's information in the reagentProto variable.
var totalViscosity = 0f;
var totalQuantity = 0f;
var fullPuddleAmount = FixedPoint2.New(component.OverflowVolume.Float() * LowThreshold);

foreach (var (reagent, _) in solution.Contents)
{
var reagentQuant = solution.GetReagentQuantity(reagent).Float();
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
/// set maximum viscosity to whichever is higher (zero on the left, the reagent's viscosity on the right)
maxViscosity = Math.Max(maxViscosity, reagentProto.Viscosity);
/// do the opposite to minimum viscosity.
minViscosity = Math.Min(minViscosity, reagentProto.Viscosity);
}

/// total viscosity is the average of all viscosities in the solution
totalViscosity = maxViscosity + minViscosity;

/// if totalviscosity is not zero, ensure that the uid has the speedmodifiercontactcomponent, and then modify its speed by the total viscosity
if (totalViscosity != 0)
{
var comp = EnsureComp<SpeedModifierContactsComponent>(uid);
var speed = 1 - totalViscosity;
_speedModContacts.ChangeModifiers(uid, speed, comp);
}

/// if totalviscosity *is* zero, remove the speedmodifiercontactcomponent, because it's not doing anything
else
{
RemComp<SpeedModifierContactsComponent>(uid);
}

totalViscosity += reagentQuant * reagentProto.Viscosity;
totalQuantity += reagentQuant;
}

totalViscosity /= totalQuantity;

if (totalQuantity < fullPuddleAmount)
totalViscosity /= 2;

if (totalViscosity != 0)
{
var comp = EnsureComp<SpeedModifierContactsComponent>(uid);
var speed = 1 - totalViscosity;
_speedModContacts.ChangeModifiers(uid, speed, comp);
}

else
{
RemComp<SpeedModifierContactsComponent>(uid);
}
}

private void OnAnchorChanged(Entity<PuddleComponent> entity, ref AnchorStateChangedEvent args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected override void Added(EntityUid uid, BluespaceArtifactRuleComponent comp
return;

base.Added(uid, component, gameRule, args);

_announcer.SendAnnouncement(
_announcer.GetAnnouncementId(args.RuleId),
Filter.Broadcast(),
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/StationEvents/Events/RandomSentienceRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

protected override void Started(EntityUid uid, RandomSentienceRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
if (!TryGetRandomStation(out var station))
Expand Down Expand Up @@ -71,7 +71,7 @@ protected override void Started(EntityUid uid, RandomSentienceRuleComponent comp
var kind1 = groupList.Count > 0 ? groupList[0] : "???";
var kind2 = groupList.Count > 1 ? groupList[1] : "???";
var kind3 = groupList.Count > 2 ? groupList[2] : "???";

_announcer.SendAnnouncement(
_announcer.GetAnnouncementId(args.RuleId),
Filter.Broadcast(),
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/StationEvents/Events/VentClogRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed class VentClogRule : StationEventSystem<VentClogRuleComponent>
{
[Dependency] private readonly SmokeSystem _smoke = default!;
[Dependency] private readonly AnnouncerSystem _announcer = default!;

protected override void Added(EntityUid uid, VentClogRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
{
base.Added(uid, component, gameRule, args);
Expand Down
8 changes: 4 additions & 4 deletions Content.Shared/Excretion/ExcretionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ public sealed partial class ExcretionComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public ThirstThreshold MinThirstThreshold = ThirstThreshold.Okay;

/// <summary>
/// The amount of slowdown applied to snails.
/// </summary>
[DataField("snailSlowdownModifier"), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float SnailSlowdownModifier = 0.5f;

/// The reagent to be spilled.
[DataField("excretedReagent")]
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public string ExcretedReagent = "Mucin";

/// <summary>
/// The amount of reagent to be spilled.
/// </summary>
[DataField("excretedVolume"), ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public float ExcretedVolume = 15f;

}
5 changes: 2 additions & 3 deletions Content.Shared/Excretion/ExcretionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void OnExcretionDoAfter(EntityUid uid, ExcretionComponent comp, Excretio
{
/*
/// if there aren't values for the desired reagent and its volume, don't do anything.
if ((comp.ExcretedReagent != "") &&
if ((comp.ExcretedReagent != "") &&
(comp.ExcretedVolume !<= 0))
{
*/
Expand All @@ -121,7 +121,7 @@ private void OnExcretionDoAfter(EntityUid uid, ExcretionComponent comp, Excretio

args.Repeat = false;
}

}

/// <summary>
Expand All @@ -134,4 +134,3 @@ public sealed partial class ExcretionActionEvent : InstantActionEvent { }
/// </summary>
[Serializable, NetSerializable]
public sealed partial class ExcretionDoAfterEvent : SimpleDoAfterEvent { }

4 changes: 2 additions & 2 deletions Content.Shared/Nutrition/EntitySystems/ThirstSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ private void UpdateEffects(EntityUid uid, ThirstComponent component)
throw new ArgumentOutOfRangeException($"No thirst threshold found for {component.CurrentThirstThreshold}");
}
}

/// a check that returns if the entity is below a thirst threshold (used in Excretion system)
public bool IsThirstBelowState(EntityUid uid, ThirstThreshold threshold, float? drink = null, ThirstComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return false; // If entity does not have the ability to be thirsty, don't check it.

return GetThirstThreshold (comp) < threshold;
}

Expand Down
8 changes: 4 additions & 4 deletions Content.Shared/SnailSpeed/SnailSpeedSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ public override void Initialize()
SubscribeLocalEvent<SnailSpeedComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<SnailSpeedComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
}

private void OnMapInit(EntityUid uid, SnailSpeedComponent comp, MapInitEvent args)
{
_movementSpeedModifier.RefreshMovementSpeedModifiers(uid);
}

/// apply constant movespeed modifier as long as entity is not flying
private void OnRefreshMovespeed(EntityUid uid, SnailSpeedComponent component, RefreshMovementSpeedModifiersEvent args)
{
if (_jetpack.IsUserFlying(uid))
return;


args.ModifySpeed(component.SnailSlowdownModifier, component.SnailSlowdownModifier);
}

Expand Down
8 changes: 4 additions & 4 deletions Resources/Audio/Effects/Footsteps/attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
license: "CC-BY-SA-4.0"
copyright: "Made by JustInvoke freesound.org"
source: "https://freesound.org/people/JustInvoke/sounds/446100/"

- files:
- jesterstep1.ogg
- jesterstep2.ogg
Expand Down Expand Up @@ -63,7 +63,7 @@
license: "CC-BY-SA-3.0"
copyright: "Taken from https://github.com/tgstation/tgstation"
source: "https://github.com/tgstation/tgstation/blob/34d5ab2e46e3fb4dd9d7475f587d33441df9651c/sound/effects"

- files:
- spurs1.ogg
- spurs2.ogg
Expand All @@ -82,5 +82,5 @@
- files:
- snailstep.ogg
license: "CC-BY-SA-3.0"
copyright: "by widgetbeck"
source: "by widgetbeck"
copyright: "Widgetbeck"
source: "https://github.com/impstation/imp-station-14/pull/184"
Loading
Loading