public void UpdateKeyFrameIdxInfoAtFrameIdx(int frameIdx, FrameIdxInfo info) { info.Idx = frameIdx; if (frameIdx >= m_FrameIdxInfos.Count) { throw new Exception("Error " + frameIdx); } List <FrameIdxInfo> frames = m_FrameIdxInfos[frameIdx]; bool updateState = false; foreach (FrameIdxInfo keyframe in frames) { if (keyframe.EqualsInfo(info)) { updateState = true; keyframe.Params = info.Params; break; } } if (!updateState) { frames.Add(info); } frames.Sort((a, b) => new System.Guid(a.EntityId).CompareTo(new System.Guid(b.EntityId))); }
public void NotifyCreateEntity(FrameIdxInfo info) { Entity entity = AddEntity(info.EntityId); if(entity != null) { m_Notifier.Send((EntityOperationEvent)int.Parse(info.Params[0]), entity,info); } }
void OnCreateBoxEntityFromThread(Notify.Notification note) { Entity entity = note.Params[0] as Entity; FrameIdxInfo frameIdxInfo = note.Params[1] as FrameIdxInfo; entity.AddComponent(new TransformComponent(float2.zero)). AddComponent(new MoveComponent(int.Parse(frameIdxInfo.Params[1]), new float2(int.Parse(frameIdxInfo.Params[2]), int.Parse(frameIdxInfo.Params[3])))). AddComponent(new BoxColliderComponent(VInt3.zero, new VInt3(50, 50, 0))). AddComponent(new IntValueComponent(1)). AddComponent(new FrameClockComponent(100, 1)); QueueCreateBoxEntity.Enqueue(entity.Id.ToString()); }
public static byte[] Write(PtKeyFrameCollection info) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInt32(info.FrameIdx); buffer.WriteInt32(info.KeyFrames.Count); for (int i = 0; i < info.KeyFrames.Count; ++i) { buffer.WriteBytes(FrameIdxInfo.Write(info.KeyFrames[i])); } return(buffer.Getbuffer()); }
public static PtKeyFrameCollection Read(byte[] bytes) { PtKeyFrameCollection info = new PtKeyFrameCollection(); info.KeyFrames = new List <FrameIdxInfo>(); ByteBuffer buffer = new ByteBuffer(bytes); info.FrameIdx = buffer.ReadInt32(); int size = buffer.ReadInt32(); for (int i = 0; i < size; ++i) { info.KeyFrames.Add(FrameIdxInfo.Read(buffer.ReadBytes())); } return(info); }
public static byte[] Write(ReplayInfo info) { using (ByteBuffer buffer = new ByteBuffer()) { buffer.WriteLong(info.OwnerId); buffer.WriteString(info.Version); int size = info.Frames.Count; buffer.WriteInt32(size); for (int i = 0; i < size; ++i) { int infoCount = info.Frames[i].Count; buffer.WriteInt32(infoCount); for (int j = 0; j < infoCount; ++j) { FrameIdxInfo fInfo = info.Frames[i][j]; buffer.WriteBytes(FrameIdxInfo.Write(fInfo)); } } return(ByteBuffer.CompressBytes(buffer.Getbuffer())); } }
public static ReplayInfo Read(byte[] bytes) { using (ByteBuffer buffer = new ByteBuffer(ByteBuffer.Decompress(bytes))) { ReplayInfo info = new ReplayInfo(); info.OwnerId = buffer.ReadLong(); info.Version = buffer.ReadString(); info.Frames = new List <List <FrameIdxInfo> >(); int size = buffer.ReadInt32(); for (int i = 0; i < size; ++i) { int infoCount = buffer.ReadInt32(); List <FrameIdxInfo> list = new List <FrameIdxInfo>(); info.Frames.Add(list); for (int j = 0; j < infoCount; ++j) { list.Add(FrameIdxInfo.Read(buffer.ReadBytes())); } } return(info); } }