-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Redo Changeling Identity Networking + New Objective #43673
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
slarticodefast
merged 13 commits into
space-wizards:master
from
ScarKy0:changeling-identity-data-+-objective
Apr 26, 2026
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3e2bbd8
i dont know whether this works or not
ScarKy0 d156f75
holy shit
ScarKy0 42d9fcf
imports, API cleanup
ScarKy0 5b377be
event
ScarKy0 a5d041e
objective
ScarKy0 2c71679
partial review
ScarKy0 76513fb
Update ChangelingIdentitySystem.cs
ScarKy0 7b49124
yippee!!
ScarKy0 9362026
events
ScarKy0 11f91e5
fuck
ScarKy0 f7316a2
another one
ScarKy0 f90e79c
small fix
slarticodefast 7f5d5e9
Merge remote-tracking branch 'upstream/master' into changeling-identi…
ScarKy0 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
35 changes: 34 additions & 1 deletion
35
Content.Server/Changeling/Systems/ChangelingIdentitySystem.cs
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 |
|---|---|---|
| @@ -1,5 +1,38 @@ | ||
| using Content.Shared.Changeling.Components; | ||
| using Content.Shared.Changeling.Systems; | ||
| using Robust.Shared.GameStates; | ||
|
|
||
| namespace Content.Server.Changeling.Systems; | ||
|
|
||
| public sealed class ChangelingIdentitySystem : SharedChangelingIdentitySystem; | ||
| public sealed class ChangelingIdentitySystem : SharedChangelingIdentitySystem | ||
| { | ||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<ChangelingIdentityComponent, ComponentGetState>(OnGetState); | ||
| } | ||
|
|
||
| private void OnGetState(Entity<ChangelingIdentityComponent> entity, ref ComponentGetState args) | ||
| { | ||
| List<ChangelingNetworkedIdentityData> sentIdentities = new(); | ||
|
|
||
| foreach (var identity in entity.Comp.ConsumedIdentities) | ||
| { | ||
| ChangelingNetworkedIdentityData netData = new(); | ||
|
|
||
| netData.Identity = GetNetEntity(identity.Identity); | ||
| netData.Original = GetNetEntity(identity.Original); | ||
| netData.Starting = identity.Starting; | ||
| netData.OriginalJob = identity.OriginalJob; | ||
|
ScarKy0 marked this conversation as resolved.
Outdated
|
||
|
|
||
| sentIdentities.Add(netData); | ||
| } | ||
|
|
||
| var current = entity.Comp.CurrentIdentity; | ||
|
|
||
| var netCurrent = GetNetEntity(current); | ||
|
|
||
| args.State = new ChangelingIdentityComponentState(sentIdentities, netCurrent, entity.Comp.IdentityCloningSettings); | ||
| } | ||
| } | ||
17 changes: 17 additions & 0 deletions
17
Content.Server/Objectives/Components/ChangelingUniqueIdentityConditionComponent.cs
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,17 @@ | ||
| using Content.Server.Objectives.Systems; | ||
|
|
||
| namespace Content.Server.Objectives.Components; | ||
|
|
||
| /// <summary> | ||
| /// Requires that a changeling has obtained X unique identities. | ||
| /// Depends on <see cref="NumberObjectiveComponent"/> to function. | ||
| /// </summary> | ||
| [RegisterComponent, Access(typeof(ChangelingObjectiveSystem))] | ||
| public sealed partial class ChangelingUniqueIdentityConditionComponent : Component | ||
| { | ||
| /// <summary> | ||
| /// Whether the target must be dead | ||
|
ScarKy0 marked this conversation as resolved.
Outdated
|
||
| /// </summary> | ||
| [DataField, ViewVariables(VVAccess.ReadWrite)] | ||
|
ScarKy0 marked this conversation as resolved.
Outdated
|
||
| public int UniqueIdentities; | ||
| } | ||
48 changes: 48 additions & 0 deletions
48
Content.Server/Objectives/Systems/ChangelingObjectiveSystem.cs
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,48 @@ | ||
| using Content.Server.Objectives.Components; | ||
| using Content.Shared.Changeling.Components; | ||
| using Content.Shared.Mind; | ||
| using Content.Shared.Objectives.Components; | ||
|
|
||
| namespace Content.Server.Objectives.Systems; | ||
|
|
||
| public sealed class ChangelingObjectiveSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly NumberObjectiveSystem _number = default!; | ||
| [Dependency] private readonly SharedMindSystem _mind = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<ChangelingUniqueIdentityConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress); | ||
| SubscribeLocalEvent<ChangelingDevouredEntityEvent>(OnChangelingDevoured); | ||
| } | ||
|
|
||
| private void OnChangelingDevoured(ref ChangelingDevouredEntityEvent args) | ||
| { | ||
| if (!args.Unique) | ||
| return; | ||
|
|
||
| if (!_mind.TryGetObjectiveComp<ChangelingUniqueIdentityConditionComponent>(args.Changeling, out var obj)) | ||
| return; | ||
|
|
||
| obj.UniqueIdentities++; | ||
| } | ||
|
|
||
| private void OnGetProgress(Entity<ChangelingUniqueIdentityConditionComponent> ent, ref ObjectiveGetProgressEvent args) | ||
| { | ||
| args.Progress = GetProgress(ent.Comp, _number.GetTarget(ent)); | ||
| } | ||
|
|
||
| private float GetProgress(ChangelingUniqueIdentityConditionComponent comp, int target) | ||
| { | ||
| // prevent divide-by-zero | ||
| if (target == 0) | ||
| return 1f; | ||
|
|
||
| if (comp.UniqueIdentities >= target) | ||
| return 1f; | ||
|
|
||
| return (float) comp.UniqueIdentities / (float) target; | ||
|
ScarKy0 marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
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
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.