-
Notifications
You must be signed in to change notification settings - Fork 51
[Feature] ERP - core systems #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
dabf4ee
Base
MataVsn b9e235c
Rabbit
MataVsn f6f4c02
NPC organs
MataVsn 5126e70
Clothing coverage for erotic organs
MataVsn 10697be
Fix
MataVsn 6089880
NPC - organs fix
MataVsn dd36ea4
Physics fix
MataVsn 1e22ee0
New sprites. Arch fixes, standartization
MataVsn 66da585
Fix anus organ sprite — replace blank placeholder with donut_7_s
MataVsn f476503
Hardcode remove.
MataVsn b2d839e
sync fix
MataVsn 19e6f35
line
MataVsn 777f6ef
Delta Arousal event
MataVsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| using Content.Shared._Arcane.ERP; | ||
| using Content.Shared.Alert; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Server._Arcane.ERP; | ||
|
|
||
| public sealed class ArousalSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly IGameTiming _timing = default!; | ||
| [Dependency] private readonly AlertsSystem _alerts = default!; | ||
|
|
||
| private static readonly TimeSpan PhaseCheckRate = TimeSpan.FromSeconds(5); | ||
|
|
||
| private static readonly ProtoId<AlertCategoryPrototype> AlertCategory = "Arousal"; | ||
| private static readonly ProtoId<AlertPrototype> AlertAroused = "ArousalAroused"; | ||
| private static readonly ProtoId<AlertPrototype> AlertHeated = "ArousalHeated"; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<ArousalComponent, ComponentInit>(OnInit); | ||
| SubscribeLocalEvent<ArousalComponent, ErpPreferenceChangedEvent>(OnErpPreferenceChanged); | ||
| } | ||
|
|
||
| private void OnInit(Entity<ArousalComponent> ent, ref ComponentInit args) | ||
| { | ||
| SetArousal(ent, 0f); | ||
| } | ||
|
|
||
| private void OnErpPreferenceChanged(Entity<ArousalComponent> ent, ref ErpPreferenceChangedEvent args) | ||
| { | ||
| if (args.NewPreference != ErpPreference.No) | ||
| return; | ||
|
|
||
| ent.Comp.PassiveSources.Clear(); | ||
| SetArousal(ent, 0f); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns current arousal accounting for passive gain/decay since last authoritative set. | ||
| /// Passive gain is suppressed during the refractory period. | ||
| /// </summary> | ||
| public float GetArousal(ArousalComponent comp) | ||
| { | ||
| var sinceChange = _timing.CurTime - comp.LastChangeTime; | ||
| var elapsed = (float)sinceChange.TotalSeconds; | ||
| var passiveRate = IsRefractory(comp) ? 0f : comp.PassiveGainRate; | ||
| var netRate = passiveRate - comp.DecayRate; | ||
| return Math.Clamp(comp.LastValue + netRate * elapsed, 0f, comp.MaxArousal); | ||
| } | ||
|
|
||
| public bool IsRefractory(ArousalComponent comp) | ||
| { | ||
| return _timing.CurTime < comp.RefractoryUntil; | ||
| } | ||
|
|
||
| public void SetPassiveSource(EntityUid uid, string sourceId, float rate, ArousalComponent? comp = null) | ||
| { | ||
| if (!Resolve(uid, ref comp)) | ||
| return; | ||
|
|
||
| if (IsErpDisabled(uid)) | ||
| return; | ||
|
|
||
| // Snapshot current value before changing rate to prevent retroactive application. | ||
| comp.LastValue = GetArousal(comp); | ||
| comp.LastChangeTime = _timing.CurTime; | ||
| comp.PassiveSources[sourceId] = rate; | ||
| Dirty(uid, comp); | ||
| } | ||
|
|
||
| public void RemovePassiveSource(EntityUid uid, string sourceId, ArousalComponent? comp = null) | ||
| { | ||
| if (!Resolve(uid, ref comp)) | ||
| return; | ||
|
|
||
| // Snapshot current value before removing source to prevent retroactive application. | ||
| comp.LastValue = GetArousal(comp); | ||
| comp.LastChangeTime = _timing.CurTime; | ||
| comp.PassiveSources.Remove(sourceId); | ||
| Dirty(uid, comp); | ||
| } | ||
|
|
||
| public void AddArousal(EntityUid uid, float amount, ArousalComponent? comp = null) | ||
| { | ||
| if (!Resolve(uid, ref comp)) | ||
| return; | ||
|
|
||
| if (IsErpDisabled(uid)) | ||
| return; | ||
|
|
||
| if (IsRefractory(comp)) | ||
| return; | ||
|
|
||
| var before = GetArousal(comp); | ||
| var target = Math.Clamp(before + amount, 0f, comp.MaxArousal); | ||
| SetArousal((uid, comp), target); | ||
| if (target > before) | ||
| RaiseLocalEvent(uid, new ArousedEvent(before, target)); | ||
| } | ||
|
|
||
| public void ReduceArousal(EntityUid uid, float amount, ArousalComponent? comp = null) | ||
| { | ||
| if (!Resolve(uid, ref comp)) | ||
| return; | ||
|
|
||
| SetArousal((uid, comp), GetArousal(comp) - amount); | ||
| } | ||
|
|
||
| public override void Update(float frameTime) | ||
| { | ||
| base.Update(frameTime); | ||
|
|
||
| var now = _timing.CurTime; | ||
| var query = EntityQueryEnumerator<ArousalComponent>(); | ||
| while (query.MoveNext(out var uid, out var comp)) | ||
| { | ||
| if (now < comp.NextPhaseCheckAt) | ||
| continue; | ||
|
|
||
| comp.NextPhaseCheckAt = now + PhaseCheckRate; | ||
| UpdatePhase((uid, comp)); | ||
| } | ||
| } | ||
|
|
||
| private void SetArousal(Entity<ArousalComponent> entity, float value) | ||
| { | ||
| var comp = entity.Comp; | ||
| value = Math.Clamp(value, 0f, comp.MaxArousal); | ||
|
|
||
| comp.LastValue = value; | ||
| comp.LastChangeTime = _timing.CurTime; | ||
| Dirty(entity.Owner, comp); | ||
|
|
||
| UpdatePhase(entity); | ||
| } | ||
|
|
||
| private void UpdatePhase(Entity<ArousalComponent> entity) | ||
| { | ||
| var comp = entity.Comp; | ||
| var newPhase = comp.ComputePhase(GetArousal(comp)); | ||
| if (newPhase == comp.CurrentPhase) | ||
| return; | ||
|
|
||
| var previous = comp.CurrentPhase; | ||
| comp.CurrentPhase = newPhase; | ||
|
|
||
| if (newPhase == ArousalPhase.Peak) | ||
| { | ||
| // Reset arousal inline to avoid re-entering UpdatePhase via SetArousal. | ||
| // Alerts go straight to Calm — no single-tick Peak flash. | ||
| comp.LastOrgasmAt = _timing.CurTime; | ||
| comp.RefractoryUntil = _timing.CurTime + comp.RefractoryDuration; | ||
| comp.LastValue = 0f; | ||
| comp.LastChangeTime = _timing.CurTime; | ||
| comp.CurrentPhase = ArousalPhase.Calm; | ||
| Dirty(entity.Owner, comp); | ||
|
|
||
| UpdateAlerts(entity.Owner, ArousalPhase.Calm); | ||
| var orgasmEv = new ArousalOrgasmEvent(); | ||
| RaiseLocalEvent(entity.Owner, ref orgasmEv); | ||
| RaiseLocalEvent(entity.Owner, new ArousalPhaseChangedEvent(previous, ArousalPhase.Calm)); | ||
| } | ||
| else | ||
| { | ||
| Dirty(entity.Owner, comp); | ||
| UpdateAlerts(entity.Owner, newPhase); | ||
| RaiseLocalEvent(entity.Owner, new ArousalPhaseChangedEvent(previous, newPhase)); | ||
| } | ||
| } | ||
|
|
||
| private void UpdateAlerts(EntityUid uid, ArousalPhase phase) | ||
| { | ||
| switch (phase) | ||
| { | ||
| case ArousalPhase.Aroused: | ||
| _alerts.ShowAlert(uid, AlertAroused); | ||
| break; | ||
| case ArousalPhase.Heated: | ||
| _alerts.ShowAlert(uid, AlertHeated); | ||
| break; | ||
| default: | ||
| _alerts.ClearAlertCategory(uid, AlertCategory); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| private bool IsErpDisabled(EntityUid uid) | ||
| { | ||
| return TryComp<ErpStatusComponent>(uid, out var status) | ||
| && status.Preference == ErpPreference.No; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| using Content.Shared._Arcane.ERP; | ||
| using Content.Shared._Arcane.ERP.Organs; | ||
| using Content.Shared.Body.Part; | ||
| using Content.Shared.Body.Systems; | ||
| using Content.Shared.Clothing; | ||
| using Content.Shared.Clothing.Components; | ||
| using Content.Shared.Humanoid; | ||
| using Content.Shared.Inventory; | ||
| using Robust.Shared.Containers; | ||
|
|
||
| namespace Content.Server._Arcane.ERP; | ||
|
|
||
| public sealed class EroticCoverageSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly SharedBodySystem _body = default!; | ||
| [Dependency] private readonly InventorySystem _inventory = default!; | ||
| [Dependency] private readonly SharedContainerSystem _containers = default!; | ||
|
|
||
| private const SlotFlags GroinCovering = SlotFlags.INNERCLOTHING | SlotFlags.OUTERCLOTHING | SlotFlags.LEGS | SlotFlags.UNDERWEAR; | ||
| private const SlotFlags ChestCovering = SlotFlags.INNERCLOTHING | SlotFlags.OUTERCLOTHING | SlotFlags.UNDERSHIRT; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
| SubscribeLocalEvent<HumanoidAppearanceComponent, EroticOrgansSpawnedEvent>(OnOrgansSpawned); | ||
| SubscribeLocalEvent<HumanoidAppearanceComponent, ClothingDidEquippedEvent>(OnEquipped); | ||
| SubscribeLocalEvent<HumanoidAppearanceComponent, ClothingDidUnequippedEvent>(OnUnequipped); | ||
| } | ||
|
|
||
| private void OnOrgansSpawned(Entity<HumanoidAppearanceComponent> ent, ref EroticOrgansSpawnedEvent args) | ||
| { | ||
| RefreshOrganVisibility(ent); | ||
| } | ||
|
|
||
| private void OnEquipped(Entity<HumanoidAppearanceComponent> ent, ref ClothingDidEquippedEvent args) | ||
| { | ||
| RefreshOrganVisibility(ent); | ||
| } | ||
|
|
||
| private void OnUnequipped(Entity<HumanoidAppearanceComponent> ent, ref ClothingDidUnequippedEvent args) | ||
| { | ||
| RefreshOrganVisibility(ent); | ||
| } | ||
|
MataVsn marked this conversation as resolved.
|
||
|
|
||
| private void RefreshOrganVisibility(EntityUid uid) | ||
| { | ||
| var coverage = SlotFlags.NONE; | ||
| var enumerator = _inventory.GetSlotEnumerator(uid, GroinCovering | ChestCovering); | ||
| while (enumerator.NextItem(out var item)) | ||
| { | ||
| if (TryComp<ClothingComponent>(item, out var clothing)) | ||
| coverage |= clothing.Slots; | ||
| } | ||
|
|
||
| var groinCovered = (coverage & GroinCovering) != SlotFlags.NONE; | ||
| var chestCovered = (coverage & ChestCovering) != SlotFlags.NONE; | ||
|
|
||
| foreach (var organ in _body.GetBodyOrganEntityComps<EroticOrganComponent>((uid, null))) | ||
| { | ||
| if (!_containers.TryGetContainingContainer(organ.Owner, out var container)) | ||
| continue; | ||
|
|
||
| if (!TryComp<BodyPartComponent>(container.Owner, out var part)) | ||
| continue; | ||
|
|
||
| var visible = part.PartType switch | ||
| { | ||
| BodyPartType.Groin => !groinCovered, | ||
| BodyPartType.Chest => !chestCovered, | ||
| _ => true, | ||
| }; | ||
|
|
||
| if (organ.Comp1.Visible == visible) | ||
| continue; | ||
|
|
||
| organ.Comp1.Visible = visible; | ||
| Dirty(organ.Owner, organ.Comp1); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.