-
Notifications
You must be signed in to change notification settings - Fork 376
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
Add sourcegenned field deltas #5155
Open
metalgearsloth
wants to merge
16
commits into
space-wizards:master
Choose a base branch
from
metalgearsloth:2024-05-20-field-deltas
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4460248
Remove full "delta" states
ElectroJr 9a02362
Update MapGridComponentState
ElectroJr c5eeb49
abstract ComponentState
ElectroJr f8efb34
Release notes
ElectroJr 893694b
Fix tests
ElectroJr 5ace3e6
Fix nullable errors
ElectroJr 61d34f5
A
ElectroJr 76e781c
Sourcegen component deltas
metalgearsloth 844badc
Audio deltas + methids
metalgearsloth fa54c35
Also eye
metalgearsloth 05483bf
Optimise out the dictionary
metalgearsloth 8143629
Merge remote-tracking branch 'upstream/master' into 2024-05-20-field-…
metalgearsloth 833201b
Minor fixes
metalgearsloth c3a3691
Physics deltas
metalgearsloth fb73dbc
Merge remote-tracking branch 'upstream/master' into 2024-05-20-field-…
metalgearsloth efe7b4a
Also this
metalgearsloth 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 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 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 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
357 changes: 335 additions & 22 deletions
357
Robust.Shared.CompNetworkGenerator/ComponentNetworkGenerator.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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: 10 additions & 25 deletions
35
Robust.Shared/GameObjects/Components/CollisionWakeComponent.cs
This file contains 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,30 +1,15 @@ | ||
using System; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Serialization; | ||
using Robust.Shared.Serialization.Manager.Attributes; | ||
|
||
namespace Robust.Shared.GameObjects | ||
{ | ||
/// <summary> | ||
/// An optimisation component for stuff that should be set as collidable when it's awake and non-collidable when asleep. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent()] | ||
[Access(typeof(CollisionWakeSystem))] | ||
public sealed partial class CollisionWakeComponent : Component | ||
{ | ||
[DataField("enabled")] | ||
public bool Enabled = true; | ||
|
||
[Serializable, NetSerializable] | ||
public sealed class CollisionWakeState : ComponentState | ||
{ | ||
public bool Enabled { get; } | ||
namespace Robust.Shared.GameObjects; | ||
|
||
public CollisionWakeState(bool enabled) | ||
{ | ||
Enabled = enabled; | ||
} | ||
} | ||
} | ||
/// <summary> | ||
/// An optimisation component for stuff that should be set as collidable when it's awake and non-collidable when asleep. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
[Access(typeof(CollisionWakeSystem))] | ||
public sealed partial class CollisionWakeComponent : Component | ||
{ | ||
[DataField, AutoNetworkedField] | ||
public bool Enabled = true; | ||
} |
This file contains 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
61 changes: 61 additions & 0 deletions
61
Robust.Shared/GameObjects/EntityManager.ComponentDeltas.cs
This file contains 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,61 @@ | ||
using Robust.Shared.Timing; | ||
|
||
namespace Robust.Shared.GameObjects; | ||
|
||
public abstract partial class EntityManager | ||
{ | ||
public void DirtyField(EntityUid uid, IComponentDelta delta, string fieldName, MetaDataComponent? metadata = null) | ||
{ | ||
// Much more likely for this to accidentally not be implemented than vice versa. | ||
if (delta is not IComponent component) | ||
{ | ||
_sawmill.Error($"Tried to dirty component field for {delta.GetType()} which does not implement {nameof(IComponent)}"); | ||
return; | ||
} | ||
|
||
var compReg = ComponentFactory.GetRegistration(component); | ||
InternalDirty(uid, component, delta, compReg, fieldName, metadata); | ||
} | ||
|
||
public void DirtyField<T>(EntityUid uid, T component, string fieldName, MetaDataComponent? metadata = null) where T : IComponent, IComponentDelta | ||
{ | ||
var delta = (IComponentDelta)component; | ||
var compReg = ComponentFactory.GetRegistration(CompIdx.Index<T>()); | ||
InternalDirty(uid, component, delta, compReg, fieldName, metadata); | ||
} | ||
|
||
private void InternalDirty(EntityUid uid, IComponent comp, IComponentDelta delta, ComponentRegistration compReg, string fieldName, MetaDataComponent? metadata = null) | ||
{ | ||
if (!compReg.NetworkedFieldLookup.TryGetValue(fieldName, out var idx)) | ||
{ | ||
_sawmill.Error($"Tried to dirty delta field {fieldName} on {ToPrettyString(uid)} that isn't implemented."); | ||
return; | ||
} | ||
|
||
var curTick = _gameTiming.CurTick; | ||
delta.LastFieldUpdate = curTick; | ||
delta.LastModifiedFields[idx] = curTick; | ||
Dirty(uid, comp, metadata); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Indicates this component supports delta states. | ||
/// </summary> | ||
public interface IComponentDelta | ||
{ | ||
// TODO: This isn't entirely robust but not sure how else to handle this? | ||
/// <summary> | ||
/// Track last time a field was dirtied. if the full component dirty exceeds this then we send a full state update. | ||
/// </summary> | ||
public GameTick LastFieldUpdate { get; set; } | ||
|
||
/// <summary> | ||
/// Stores the last modified tick for fields. | ||
/// </summary> | ||
public GameTick[] LastModifiedFields | ||
{ | ||
get; | ||
set; | ||
} | ||
} |
This file contains 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor spelling mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review the other pr you absolute fool