void IEntitySerializer.OnInitialized() { NetworkStorage storage; storage = AllocateStorage(); storage.Frame = Entity.IsOwner ? Core.Frame : -1; Frames.AddLast(storage); for (int i = 0; i < Meta.Properties.Length; ++i) { var p = Meta.Properties[i]; p.Property.OnInit(Objects[p.OffsetObjects]); } }
//public Animation AddPiece(Piece piece) //{ // Pieces.Add(piece); // return this; //} public Animation AddFrame(AnimationFrame frame) { Frames.AddLast(frame); return(this); }
void IEntitySerializer.Read(Connection connection, Packet packet, int frame) { int count = packet.ReadByte(Meta.PacketMaxPropertiesBits); var storage = default(NetworkStorage); if (Entity.HasPredictedControl) { NetAssert.True(Frames.Count == 1); storage = Frames.First; storage.Frame = Core.Frame; } else { if (Frames.First.Frame == -1) { NetAssert.True(Frames.Count == 1); storage = Frames.First; storage.Frame = frame; } else { storage = DuplicateStorage(Frames.Last); storage.Frame = frame; storage.ClearAll(); // tell the properties that need to know about this for (int i = 0; i < Meta.OnFrameCloned.Count; ++i) { // grab property info var pi = Meta.OnFrameCloned[i]; // invoke callback pi.Property.OnFrameCloned(Objects[pi.OffsetObjects], storage); } Frames.AddLast(storage); } } //fixes bug #224 //IState.SetTransforms to replace NetworkTransform.SetTransforms, //this new methods works around the issue of position snapping for //entities when their position updates are delayed. //NetworkTransform.ChangeTransform to replace the previous NetworkTransform.SetTransforms //for changing the transform target for interpolation after it's been set once. if (Entity.HasControl && !Entity.HasPredictedControl && !Entity.IsOwner) { for (int i = 0; i < Meta.Properties.Length; ++i) { var pi = Meta.Properties[i]; if (pi.Property.ToController == false) { // calculate property index int index = Objects[pi.OffsetObjects][pi.Property]; // copy value from latest frame storage.Values[index] = Frames.First.Values[index]; } } } while (--count >= 0) { var propertyIndex = packet.ReadInt(Meta.PropertyIdBits); var propertyInfo = Meta.Properties[propertyIndex]; if (!Entity.IsOwner) { EntityProxy proxy; if (Entity.Source.entityChannel.TryFindProxy(Entity, out proxy)) { proxy.PropertyPriority[propertyIndex].PropertyUpdated = frame; } } // make sure this is the correct one NetAssert.True(propertyIndex == Objects[propertyInfo.OffsetObjects].OffsetProperties + propertyInfo.Property.OffsetProperties); // read data into frame propertyInfo.Property.Read(connection, Objects[propertyInfo.OffsetObjects], storage, packet); // set changed flag storage.Set(propertyIndex); } }