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

Commit

Permalink
Generated Code
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroZshadow committed Jan 31, 2020
1 parent 0744294 commit f540d7c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,125 +2,18 @@
// DO NOT EDIT - this file is automatically regenerated.
// =====================================================

using System;
using System.Collections.Generic;
using Improbable.Gdk.Core;
using Unity.Entities;
using Improbable.Gdk.Core.Commands;

namespace Improbable.DependentSchema
{
public partial class DependentDataComponent
{
public class DiffBarCommandCommandStorage : IComponentCommandDiffStorage
, IDiffCommandRequestStorage<BarCommand.ReceivedRequest>
, IDiffCommandResponseStorage<BarCommand.ReceivedResponse>
public class DiffBarCommandCommandStorage
: DiffSpawnCubeCommandStorage<BarCommand.ReceivedRequest, BarCommand.ReceivedResponse>
{
private readonly MessageList<BarCommand.ReceivedRequest> requestStorage =
new MessageList<BarCommand.ReceivedRequest>();

private readonly MessageList<BarCommand.ReceivedResponse> responseStorage =
new MessageList<BarCommand.ReceivedResponse>();

private readonly RequestComparer requestComparer = new RequestComparer();
private readonly ResponseComparer responseComparer = new ResponseComparer();

private bool requestsSorted;
private bool responsesSorted;

public uint GetComponentId()
{
return ComponentId;
}

public uint GetCommandId()
{
return 1;
}

public Type GetRequestType()
{
return typeof(BarCommand.ReceivedRequest);
}

public Type GetResponseType()
{
return typeof(BarCommand.ReceivedResponse);
}

public void Clear()
{
requestStorage.Clear();
responseStorage.Clear();
requestsSorted = false;
responsesSorted = false;
}

public void RemoveRequests(long entityId)
{
requestStorage.RemoveAll(request => request.EntityId.Id == entityId);
}

public void AddRequest(BarCommand.ReceivedRequest request)
{
requestStorage.Add(request);
}

public void AddResponse(BarCommand.ReceivedResponse response)
{
responseStorage.Add(response);
}

public MessagesSpan<BarCommand.ReceivedRequest> GetRequests()
{
return requestStorage.Slice();
}

public MessagesSpan<BarCommand.ReceivedRequest> GetRequests(EntityId targetEntityId)
{
if (!requestsSorted)
{
requestStorage.Sort(requestComparer);
requestsSorted = true;
}

var (firstIndex, count) = requestStorage.GetEntityRange(targetEntityId);
return requestStorage.Slice(firstIndex, count);
}

public MessagesSpan<BarCommand.ReceivedResponse> GetResponses()
{
return responseStorage.Slice();
}

public MessagesSpan<BarCommand.ReceivedResponse> GetResponse(long requestId)
{
if (!responsesSorted)
{
responseStorage.Sort(responseComparer);
responsesSorted = true;
}

var responseIndex = responseStorage.GetResponseIndex(requestId);
return responseIndex.HasValue
? responseStorage.Slice(responseIndex.Value, 1)
: MessagesSpan<BarCommand.ReceivedResponse>.Empty();
}

private class RequestComparer : IComparer<BarCommand.ReceivedRequest>
{
public int Compare(BarCommand.ReceivedRequest x, BarCommand.ReceivedRequest y)
{
return x.EntityId.Id.CompareTo(y.EntityId.Id);
}
}

private class ResponseComparer : IComparer<BarCommand.ReceivedResponse>
{
public int Compare(BarCommand.ReceivedResponse x, BarCommand.ReceivedResponse y)
{
return x.RequestId.CompareTo(y.RequestId);
}
}
public override uint ComponentId => ComponentId;
public override uint CommandId => 1;
}

public class BarCommandCommandsToSendStorage :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,9 @@ public struct Request : ICommandRequest
Payload = request;
}

long IReceivedCommandRequest.GetRequestId()
{
return RequestId;
}
long IReceivedCommandRequest.RequestId => RequestId;

EntityId IReceivedEntityMessage.GetEntityId()
{
return EntityId;
}
EntityId IReceivedEntityMessage.EntityId => EntityId;
}

/// <summary>
Expand Down Expand Up @@ -126,10 +120,7 @@ public Response(long requestId, string failureMessage)
RequestId = requestId;
}

long IReceivedCommandResponse.GetRequestId()
{
return RequestId;
}
long IReceivedCommandResponse.RequestId => RequestId;
}

public readonly struct RawReceivedResponse : IRawReceivedCommandResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Type[] GetEventTypes()
{
return new Type[]
{
typeof(FooEvent.Event),
typeof(FooEvent.Event)
};
}

Expand Down

0 comments on commit f540d7c

Please sign in to comment.