Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Simplify components, step 1 #1290

Merged
merged 10 commits into from
Feb 20, 2020
Merged

Simplify components, step 1 #1290

merged 10 commits into from
Feb 20, 2020

Conversation

zeroZshadow
Copy link
Contributor

Description

First iteration of simplifications in the Component section of code generation.
Includes an improvement in the ViewDiff and MessagesToSend, reducing a double lookup for storage instances to a single lookup.

@improbable-prow-robot improbable-prow-robot added jira/no-ticket Indicates a PR has no corresponding JIRA ticket do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 17, 2020
@improbable-prow-robot improbable-prow-robot added A: core Area: Core GDK size/XL Denotes a PR that changes 300-599 lines, ignoring generated files. labels Feb 17, 2020
@zeroZshadow
Copy link
Contributor Author

Still needs test project update and a changelog.
Just made the PR to keep track of it

@zeroZshadow zeroZshadow force-pushed the feature/simplify-components branch from 696b294 to b3fc65d Compare February 18, 2020 12:25
@improbable-prow-robot improbable-prow-robot added size/XXL Denotes a PR that changes 600+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 300-599 lines, ignoring generated files. labels Feb 18, 2020
@zeroZshadow zeroZshadow force-pushed the feature/simplify-components branch from 67c8816 to 5ab60b8 Compare February 19, 2020 14:59
@zeroZshadow zeroZshadow marked this pull request as ready for review February 19, 2020 15:55
@improbable-prow-robot improbable-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 19, 2020
CHANGELOG.md Outdated Show resolved Hide resolved
@@ -9,7 +9,7 @@ namespace Improbable.Gdk.Core
/// Instances of this type should be treated as transient identifiers that will not be
/// consistent between different runs of the same simulation.
/// </remarks>
public struct EntityId : IEquatable<EntityId>
public readonly struct EntityId : IEquatable<EntityId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting this in the changelog :)

public abstract class DiffComponentStorage<TUpdate> : IDiffUpdateStorage<TUpdate>, IDiffComponentAddedStorage<TUpdate>, IDiffAuthorityStorage
where TUpdate : ISpatialComponentUpdate
{
private readonly HashSet<EntityId> entitiesUpdated = new HashSet<EntityId>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this protected since I'll need that in #1298 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 17 to 18
.Select(componentCommands => (componentCommands.Key,
componentCommands.Value.Commands.Select(m => m.SendStorage)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find splitting the tuple over two lines really hard to grok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment on lines +45 to +54
private readonly Dictionary<uint, (int firstIndex, int count)> componentIdStorageRange =
new Dictionary<uint, (int firstIndex, int count)>();

private readonly Dictionary<(uint componentId, uint commandId), IComponentCommandDiffStorage> componentCommandToStorage =
new Dictionary<(uint componentId, uint commandId), IComponentCommandDiffStorage>();

private readonly Dictionary<Type, ICommandDiffStorage> typeToCommandStorage =
new Dictionary<Type, ICommandDiffStorage>();

private readonly List<ICommandDiffStorage> commandStorageList = new List<ICommandDiffStorage>();
private readonly List<IComponentCommandDiffStorage> commandStorageList = new List<IComponentCommandDiffStorage>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small explanation on this in comments would go a long way :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A IComponentCommandDiffStorage implements ICommandDiffStorage
All instances in this list were the former, except for the world command storage that we manually added.
Instead, I now store the generated diff storages only, and the world storage is called manually. (This is only done for clearing afterwards)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring more to the range dictionary :)

Comment on lines 17 to 18
.Select(componentCommands => (componentCommands.Key,
componentCommands.Value.Commands.Select(m => m.SendStorage)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated
- Running forced code generation now deletes the `ImprobableCodegen.marker` file. [#1294](https://github.com/spatialos/gdk-for-unity/pull/1294)
- Added tests coverage for the interaction between unlinking a GameObject and Reader/Writer/CommandSender/CommandReceiver state. [#1295](https://github.com/spatialos/gdk-for-unity/pull/1295)
- Reduce complexity in ViewDiff and MessagesToSend classes. [#1290](https://github.com/spatialos/gdk-for-unity/pull/1290)
- De-duplicate code for generated ComponentDiffStorage instances. [#1290](https://github.com/spatialos/gdk-for-unity/pull/1290)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- De-duplicate code for generated ComponentDiffStorage instances. [#1290](https://github.com/spatialos/gdk-for-unity/pull/1290)
- De-duplicate code for generated `ComponentDiffStorage` instances. [#1290](https://github.com/spatialos/gdk-for-unity/pull/1290)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you push this :P

CHANGELOG.md Outdated Show resolved Hide resolved
Co-Authored-By: Paul Balaji <[email protected]>
CHANGELOG.md Outdated Show resolved Hide resolved
@zeroZshadow zeroZshadow merged commit 95e4233 into develop Feb 20, 2020
@zeroZshadow zeroZshadow deleted the feature/simplify-components branch February 20, 2020 11:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A: core Area: Core GDK jira/no-ticket Indicates a PR has no corresponding JIRA ticket size/XXL Denotes a PR that changes 600+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants