static AgentComponentGhostComponentSerializer()
 {
     State = new GhostComponentSerializer.State
     {
         GhostFieldsHash = 14767913548786401661,
         ExcludeFromComponentCollectionHash = 0,
         ComponentType        = ComponentType.ReadWrite <AgentComponent>(),
         ComponentSize        = UnsafeUtility.SizeOf <AgentComponent>(),
         SnapshotSize         = UnsafeUtility.SizeOf <Snapshot>(),
         ChangeMaskBits       = ChangeMaskBits,
         SendMask             = GhostComponentSerializer.SendMask.Interpolated | GhostComponentSerializer.SendMask.Predicted,
         SendForChildEntities = 1,
         CopyToSnapshot       =
             new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyToSnapshot),
         CopyFromSnapshot =
             new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyFromSnapshot),
         RestoreFromBackup =
             new PortableFunctionPointer <GhostComponentSerializer.RestoreFromBackupDelegate>(RestoreFromBackup),
         PredictDelta        = new PortableFunctionPointer <GhostComponentSerializer.PredictDeltaDelegate>(PredictDelta),
         CalculateChangeMask =
             new PortableFunctionPointer <GhostComponentSerializer.CalculateChangeMaskDelegate>(
                 CalculateChangeMask),
         Serialize   = new PortableFunctionPointer <GhostComponentSerializer.SerializeDelegate>(Serialize),
         Deserialize = new PortableFunctionPointer <GhostComponentSerializer.DeserializeDelegate>(Deserialize),
         #if UNITY_EDITOR || DEVELOPMENT_BUILD
         ReportPredictionErrors = new PortableFunctionPointer <GhostComponentSerializer.ReportPredictionErrorsDelegate>(ReportPredictionErrors),
         #endif
     };
     #if UNITY_EDITOR || DEVELOPMENT_BUILD
     State.NumPredictionErrorNames = GetPredictionErrorNames(ref State.PredictionErrorNames);
     #endif
 }
Beispiel #2
0
 static PropHuntMixedComponentsKCCVelocityGhostComponentSerializer()
 {
     State = new GhostComponentSerializer.State
     {
         GhostFieldsHash = 6104341673800988698,
         ExcludeFromComponentCollectionHash = 0,
         ComponentType        = ComponentType.ReadWrite <PropHunt.Mixed.Components.KCCVelocity>(),
         ComponentSize        = UnsafeUtility.SizeOf <PropHunt.Mixed.Components.KCCVelocity>(),
         SnapshotSize         = UnsafeUtility.SizeOf <Snapshot>(),
         ChangeMaskBits       = ChangeMaskBits,
         SendMask             = GhostComponentSerializer.SendMask.Predicted,
         SendForChildEntities = 1,
         CopyToSnapshot       =
             new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyToSnapshot),
         CopyFromSnapshot =
             new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyFromSnapshot),
         RestoreFromBackup =
             new PortableFunctionPointer <GhostComponentSerializer.RestoreFromBackupDelegate>(RestoreFromBackup),
         PredictDelta        = new PortableFunctionPointer <GhostComponentSerializer.PredictDeltaDelegate>(PredictDelta),
         CalculateChangeMask =
             new PortableFunctionPointer <GhostComponentSerializer.CalculateChangeMaskDelegate>(
                 CalculateChangeMask),
         Serialize   = new PortableFunctionPointer <GhostComponentSerializer.SerializeDelegate>(Serialize),
         Deserialize = new PortableFunctionPointer <GhostComponentSerializer.DeserializeDelegate>(Deserialize),
         #if UNITY_EDITOR || DEVELOPMENT_BUILD
         ReportPredictionErrors = new PortableFunctionPointer <GhostComponentSerializer.ReportPredictionErrorsDelegate>(ReportPredictionErrors),
         #endif
     };
     #if UNITY_EDITOR || DEVELOPMENT_BUILD
     State.NumPredictionErrorNames = GetPredictionErrorNames(ref State.PredictionErrorNames);
     #endif
 }
Beispiel #3
0
        public void AddSerializer(GhostComponentSerializer.State state)
        {
            //This is always enforced to avoid bad usage of the api
            if (m_GhostComponentCollection.IsCreated)
            {
                throw new InvalidOperationException("Cannot register new GhostComponentSerializer after the RpcSystem has started running");
            }
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            for (int i = 0; i < m_PendingGhostComponentCollection.Count; ++i)
            {
                // FIXME: this is a workaround for fast enter play mode
                if (m_PendingGhostComponentCollection[i].ComponentType == state.ComponentType)
                {
                    throw new InvalidOperationException($"GhostComponentSerializer for type {state.ComponentType.GetManagedType().Name} is already registered");
                }
            }
#endif
            //When the state is registered the serializer hash is computed once
            state.SerializerHash = state.ExcludeFromComponentCollectionHash == 0 ? HashGhostComponentSerializer(state) : 0;
            m_PendingGhostComponentCollection.Add(state);
        }
Beispiel #4
0
 static GhostComponentSerializer.State GetState()
 {
     // This needs to be lazy initialized because otherwise there is a depenency on the static initialization order which breaks il2cpp builds due to TYpeManager not being initialized yet
     if (!s_StateInitialized)
     {
         s_State = new GhostComponentSerializer.State
         {
             GhostFieldsHash = 11266163746584454747,
             ExcludeFromComponentCollectionHash = 0,
             ComponentType        = ComponentType.ReadWrite <LookRotationComponent>(),
             ComponentSize        = UnsafeUtility.SizeOf <LookRotationComponent>(),
             SnapshotSize         = UnsafeUtility.SizeOf <Snapshot>(),
             ChangeMaskBits       = ChangeMaskBits,
             SendMask             = GhostComponentSerializer.SendMask.Interpolated | GhostComponentSerializer.SendMask.Predicted,
             SendToOwner          = SendToOwnerType.All,
             SendForChildEntities = 1,
             VariantHash          = 0,
             CopyToSnapshot       =
                 new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyToSnapshot),
             CopyFromSnapshot =
                 new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyFromSnapshot),
             RestoreFromBackup =
                 new PortableFunctionPointer <GhostComponentSerializer.RestoreFromBackupDelegate>(RestoreFromBackup),
             PredictDelta        = new PortableFunctionPointer <GhostComponentSerializer.PredictDeltaDelegate>(PredictDelta),
             CalculateChangeMask =
                 new PortableFunctionPointer <GhostComponentSerializer.CalculateChangeMaskDelegate>(
                     CalculateChangeMask),
             Serialize   = new PortableFunctionPointer <GhostComponentSerializer.SerializeDelegate>(Serialize),
             Deserialize = new PortableFunctionPointer <GhostComponentSerializer.DeserializeDelegate>(Deserialize),
             #if UNITY_EDITOR || DEVELOPMENT_BUILD
             ReportPredictionErrors = new PortableFunctionPointer <GhostComponentSerializer.ReportPredictionErrorsDelegate>(ReportPredictionErrors),
             #endif
         };
         #if UNITY_EDITOR || DEVELOPMENT_BUILD
         s_State.NumPredictionErrorNames = GetPredictionErrorNames(ref s_State.PredictionErrorNames);
         #endif
         s_StateInitialized = true;
     }
     return(s_State);
 }
Beispiel #5
0
 static GhostComponentSerializer.State GetState()
 {
     // This needs to be lazy initialized because otherwise there is a depenency on the static initialization order which breaks il2cpp builds due to TYpeManager not being initialized yet
     if (!s_StateInitialized)
     {
         s_State = new GhostComponentSerializer.State
         {
             GhostFieldsHash = __GHOST_FIELD_HASH__,
             ExcludeFromComponentCollectionHash = __GHOST_COMPONENT_EXCLUDE_FROM_COLLECTION_HASH__,
             ComponentType        = ComponentType.ReadWrite <__GHOST_COMPONENT_TYPE__>(),
             ComponentSize        = UnsafeUtility.SizeOf <__GHOST_COMPONENT_TYPE__>(),
             SnapshotSize         = UnsafeUtility.SizeOf <Snapshot>(),
             ChangeMaskBits       = ChangeMaskBits,
             SendMask             = __GHOST_SEND_MASK__,
             SendToOwner          = __GHOST_SEND_OWNER__,
             SendForChildEntities = __GHOST_SEND_CHILD_ENTITY__,
             VariantHash          = __GHOST_VARIANT_HASH__,
             CopyToSnapshot       =
                 new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyToSnapshot),
             CopyFromSnapshot =
                 new PortableFunctionPointer <GhostComponentSerializer.CopyToFromSnapshotDelegate>(CopyFromSnapshot),
             RestoreFromBackup =
                 new PortableFunctionPointer <GhostComponentSerializer.RestoreFromBackupDelegate>(RestoreFromBackup),
             PredictDelta        = new PortableFunctionPointer <GhostComponentSerializer.PredictDeltaDelegate>(PredictDelta),
             CalculateChangeMask =
                 new PortableFunctionPointer <GhostComponentSerializer.CalculateChangeMaskDelegate>(
                     CalculateChangeMask),
             Serialize   = new PortableFunctionPointer <GhostComponentSerializer.SerializeDelegate>(Serialize),
             Deserialize = new PortableFunctionPointer <GhostComponentSerializer.DeserializeDelegate>(Deserialize),
             #if UNITY_EDITOR || DEVELOPMENT_BUILD
             ReportPredictionErrors = new PortableFunctionPointer <GhostComponentSerializer.ReportPredictionErrorsDelegate>(ReportPredictionErrors),
             #endif
         };
         #if UNITY_EDITOR || DEVELOPMENT_BUILD
         s_State.NumPredictionErrorNames = GetPredictionErrorNames(ref s_State.PredictionErrorNames);
         #endif
         s_StateInitialized = true;
     }
     return(s_State);
 }