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

Commit

Permalink
opt-in reactive providers (#1113)
Browse files Browse the repository at this point in the history
* We missed some reactive bits in the ifdef pass

* Test project generated code

* Changelog
  • Loading branch information
zeroZshadow authored Aug 14, 2019
1 parent 3aa596c commit 359e8c8
Show file tree
Hide file tree
Showing 14 changed files with 571 additions and 574 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
### Changed

- Schema compilation error messages are now concatenated within the `GenerateCode` class before shown in the Console, creating only one error message instead of several. [#1107](https://github.com/spatialos/gdk-for-unity/pull/1107)
- Changed some reactive components for events and commands that were not correctly encapsulated with the `USE_LEGACY_REACTIVE_COMPONENTS` symbol. [#1113](https://github.com/spatialos/gdk-for-unity/pull/1113)

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,38 @@ public partial class DependentComponent
{
internal static class ReferenceTypeProviders
{
#if USE_LEGACY_REACTIVE_COMPONENTS
public static class UpdatesProvider
public static class AProvider
{
private static readonly Dictionary<uint, List<global::Improbable.DependentSchema.DependentComponent.Update>> Storage = new Dictionary<uint, List<global::Improbable.DependentSchema.DependentComponent.Update>>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, Unity.Entities.World>();
private static readonly Dictionary<uint, global::Improbable.TestSchema.ExhaustiveRepeatedData> Storage = new Dictionary<uint, global::Improbable.TestSchema.ExhaustiveRepeatedData>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, global::Unity.Entities.World>();

private static uint nextHandle = 0;

public static uint Allocate(global::Unity.Entities.World world)
{
var handle = GetNextHandle();

Storage.Add(handle, default(List<global::Improbable.DependentSchema.DependentComponent.Update>));
Storage.Add(handle, default(global::Improbable.TestSchema.ExhaustiveRepeatedData));
WorldMapping.Add(handle, world);

return handle;
}

public static List<global::Improbable.DependentSchema.DependentComponent.Update> Get(uint handle)
public static global::Improbable.TestSchema.ExhaustiveRepeatedData Get(uint handle)
{
if (!Storage.TryGetValue(handle, out var value))
{
throw new ArgumentException($"UpdatesProvider does not contain handle {handle}");
throw new ArgumentException($"AProvider does not contain handle {handle}");
}

return value;
}

public static void Set(uint handle, List<global::Improbable.DependentSchema.DependentComponent.Update> value)
public static void Set(uint handle, global::Improbable.TestSchema.ExhaustiveRepeatedData value)
{
if (!Storage.ContainsKey(handle))
{
throw new ArgumentException($"UpdatesProvider does not contain handle {handle}");
throw new ArgumentException($"AProvider does not contain handle {handle}");
}

Storage[handle] = value;
Expand Down Expand Up @@ -80,40 +79,39 @@ private static uint GetNextHandle()
}
}

#endif

public static class AProvider
public static class CProvider
{
private static readonly Dictionary<uint, global::Improbable.TestSchema.ExhaustiveRepeatedData> Storage = new Dictionary<uint, global::Improbable.TestSchema.ExhaustiveRepeatedData>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, Unity.Entities.World>();
private static readonly Dictionary<uint, global::Improbable.TestSchema.SomeEnum?> Storage = new Dictionary<uint, global::Improbable.TestSchema.SomeEnum?>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, global::Unity.Entities.World>();

private static uint nextHandle = 0;

public static uint Allocate(global::Unity.Entities.World world)
{
var handle = GetNextHandle();

Storage.Add(handle, default(global::Improbable.TestSchema.ExhaustiveRepeatedData));
Storage.Add(handle, default(global::Improbable.TestSchema.SomeEnum?));
WorldMapping.Add(handle, world);

return handle;
}

public static global::Improbable.TestSchema.ExhaustiveRepeatedData Get(uint handle)
public static global::Improbable.TestSchema.SomeEnum? Get(uint handle)
{
if (!Storage.TryGetValue(handle, out var value))
{
throw new ArgumentException($"AProvider does not contain handle {handle}");
throw new ArgumentException($"CProvider does not contain handle {handle}");
}

return value;
}

public static void Set(uint handle, global::Improbable.TestSchema.ExhaustiveRepeatedData value)
public static void Set(uint handle, global::Improbable.TestSchema.SomeEnum? value)
{
if (!Storage.ContainsKey(handle))
{
throw new ArgumentException($"AProvider does not contain handle {handle}");
throw new ArgumentException($"CProvider does not contain handle {handle}");
}

Storage[handle] = value;
Expand Down Expand Up @@ -149,38 +147,38 @@ private static uint GetNextHandle()
}


public static class CProvider
public static class DProvider
{
private static readonly Dictionary<uint, global::Improbable.TestSchema.SomeEnum?> Storage = new Dictionary<uint, global::Improbable.TestSchema.SomeEnum?>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, Unity.Entities.World>();
private static readonly Dictionary<uint, global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType>> Storage = new Dictionary<uint, global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType>>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, global::Unity.Entities.World>();

private static uint nextHandle = 0;

public static uint Allocate(global::Unity.Entities.World world)
{
var handle = GetNextHandle();

Storage.Add(handle, default(global::Improbable.TestSchema.SomeEnum?));
Storage.Add(handle, default(global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType>));
WorldMapping.Add(handle, world);

return handle;
}

public static global::Improbable.TestSchema.SomeEnum? Get(uint handle)
public static global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType> Get(uint handle)
{
if (!Storage.TryGetValue(handle, out var value))
{
throw new ArgumentException($"CProvider does not contain handle {handle}");
throw new ArgumentException($"DProvider does not contain handle {handle}");
}

return value;
}

public static void Set(uint handle, global::Improbable.TestSchema.SomeEnum? value)
public static void Set(uint handle, global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType> value)
{
if (!Storage.ContainsKey(handle))
{
throw new ArgumentException($"CProvider does not contain handle {handle}");
throw new ArgumentException($"DProvider does not contain handle {handle}");
}

Storage[handle] = value;
Expand Down Expand Up @@ -216,38 +214,38 @@ private static uint GetNextHandle()
}


public static class DProvider
public static class EProvider
{
private static readonly Dictionary<uint, global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType>> Storage = new Dictionary<uint, global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType>>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, Unity.Entities.World>();
private static readonly Dictionary<uint, global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType>> Storage = new Dictionary<uint, global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType>>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, global::Unity.Entities.World>();

private static uint nextHandle = 0;

public static uint Allocate(global::Unity.Entities.World world)
{
var handle = GetNextHandle();

Storage.Add(handle, default(global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType>));
Storage.Add(handle, default(global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType>));
WorldMapping.Add(handle, world);

return handle;
}

public static global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType> Get(uint handle)
public static global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType> Get(uint handle)
{
if (!Storage.TryGetValue(handle, out var value))
{
throw new ArgumentException($"DProvider does not contain handle {handle}");
throw new ArgumentException($"EProvider does not contain handle {handle}");
}

return value;
}

public static void Set(uint handle, global::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType> value)
public static void Set(uint handle, global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType> value)
{
if (!Storage.ContainsKey(handle))
{
throw new ArgumentException($"DProvider does not contain handle {handle}");
throw new ArgumentException($"EProvider does not contain handle {handle}");
}

Storage[handle] = value;
Expand Down Expand Up @@ -283,38 +281,39 @@ private static uint GetNextHandle()
}


public static class EProvider
#if USE_LEGACY_REACTIVE_COMPONENTS
public static class UpdatesProvider
{
private static readonly Dictionary<uint, global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType>> Storage = new Dictionary<uint, global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType>>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, Unity.Entities.World>();
private static readonly Dictionary<uint, List<global::Improbable.DependentSchema.DependentComponent.Update>> Storage = new Dictionary<uint, List<global::Improbable.DependentSchema.DependentComponent.Update>>();
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, global::Unity.Entities.World>();

private static uint nextHandle = 0;

public static uint Allocate(global::Unity.Entities.World world)
{
var handle = GetNextHandle();

Storage.Add(handle, default(global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType>));
Storage.Add(handle, default(List<global::Improbable.DependentSchema.DependentComponent.Update>));
WorldMapping.Add(handle, world);

return handle;
}

public static global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType> Get(uint handle)
public static List<global::Improbable.DependentSchema.DependentComponent.Update> Get(uint handle)
{
if (!Storage.TryGetValue(handle, out var value))
{
throw new ArgumentException($"EProvider does not contain handle {handle}");
throw new ArgumentException($"UpdatesProvider does not contain handle {handle}");
}

return value;
}

public static void Set(uint handle, global::System.Collections.Generic.Dictionary<global::Improbable.TestSchema.SomeEnum,global::Improbable.TestSchema.SomeType> value)
public static void Set(uint handle, List<global::Improbable.DependentSchema.DependentComponent.Update> value)
{
if (!Storage.ContainsKey(handle))
{
throw new ArgumentException($"EProvider does not contain handle {handle}");
throw new ArgumentException($"UpdatesProvider does not contain handle {handle}");
}

Storage[handle] = value;
Expand Down Expand Up @@ -349,7 +348,7 @@ private static uint GetNextHandle()
}
}


#endif
}
}
}
Loading

0 comments on commit 359e8c8

Please sign in to comment.