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

Port event/viewstorage/provider generators #1249

Merged
merged 3 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,270 +17,265 @@ public static class AProvider
{
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(global::Improbable.TestSchema.ExhaustiveRepeatedData));
WorldMapping.Add(handle, world);

return handle;
}

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

return value;
}

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

Storage[handle] = value;
}

public static void Free(uint handle)
{
Storage.Remove(handle);
WorldMapping.Remove(handle);
}

public static void CleanDataInWorld(global::Unity.Entities.World world)
{
var handles = WorldMapping.Where(pair => pair.Value == world).Select(pair => pair.Key).ToList();

foreach (var handle in handles)
{
Free(handle);
}
}

private static uint GetNextHandle()
{
nextHandle++;

while (Storage.ContainsKey(nextHandle))
{
nextHandle++;
}

return nextHandle;
}
}


public static class CProvider
{
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.SomeEnum?));
WorldMapping.Add(handle, world);

return handle;
}

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

return value;
}

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

Storage[handle] = value;
}

public static void Free(uint handle)
{
Storage.Remove(handle);
WorldMapping.Remove(handle);
}

public static void CleanDataInWorld(global::Unity.Entities.World world)
{
var handles = WorldMapping.Where(pair => pair.Value == world).Select(pair => pair.Key).ToList();

foreach (var handle in handles)
{
Free(handle);
}
}

private static uint GetNextHandle()
{
nextHandle++;

while (Storage.ContainsKey(nextHandle))
{
nextHandle++;
}

return nextHandle;
}
}


public static class DProvider
{
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::System.Collections.Generic.List<global::Improbable.TestSchema.SomeType>));
WorldMapping.Add(handle, world);

return 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($"DProvider does not contain handle {handle}");
}

return value;
}

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

Storage[handle] = value;
}

public static void Free(uint handle)
{
Storage.Remove(handle);
WorldMapping.Remove(handle);
}

public static void CleanDataInWorld(global::Unity.Entities.World world)
{
var handles = WorldMapping.Where(pair => pair.Value == world).Select(pair => pair.Key).ToList();

foreach (var handle in handles)
{
Free(handle);
}
}

private static uint GetNextHandle()
{
nextHandle++;

while (Storage.ContainsKey(nextHandle))
{
nextHandle++;
}

return nextHandle;
}
}


public static class EProvider
{
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.Dictionary<global::Improbable.TestSchema.SomeEnum, global::Improbable.TestSchema.SomeType>));
WorldMapping.Add(handle, world);

return 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($"EProvider 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)
{
if (!Storage.ContainsKey(handle))
{
throw new ArgumentException($"EProvider does not contain handle {handle}");
}

Storage[handle] = value;
}

public static void Free(uint handle)
{
Storage.Remove(handle);
WorldMapping.Remove(handle);
}

public static void CleanDataInWorld(global::Unity.Entities.World world)
{
var handles = WorldMapping.Where(pair => pair.Value == world).Select(pair => pair.Key).ToList();

foreach (var handle in handles)
{
Free(handle);
}
}

private static uint GetNextHandle()
{
nextHandle++;

while (Storage.ContainsKey(nextHandle))
{
nextHandle++;
}

return nextHandle;
}
}


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Improbable.DependentSchema
{
public partial class DependentComponent
{
public class DependentComponentViewStorage : IViewStorage, IViewComponentStorage<Snapshot>,
IViewComponentUpdater<Update>
public class DependentComponentViewStorage : IViewStorage, IViewComponentStorage<Snapshot>, IViewComponentUpdater<Update>
{
private readonly Dictionary<long, Authority> authorityStates = new Dictionary<long, Authority>();
private readonly Dictionary<long, Snapshot> componentData = new Dictionary<long, Snapshot>();
Expand Down Expand Up @@ -95,7 +94,6 @@ public void ApplyUpdate(long entityId, in Update update)
return;
}


if (update.A.HasValue)
{
data.A = update.A.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ public Event(global::Improbable.TestSchema.SomeType payload)
}
}
}

}
}
Loading