示例#1
0
    NetworkField FindSubField(
        Type type,
        Type fieldType,
        NetworkField field,
        NetSyncSubMemberAttribute attribute
        )
    {
        var members = fieldType
                      .GetMembers()
                      .OrderBy(x => x.Name);

        foreach (var member in members)
        {
            if (!member.Name.Equals(attribute.MemberName))
            {
                continue;
            }

            var subFieldType = GetMemberType(member);

            var subFieldGenericType = typeof(NetworkField <, ,>)
                                      .MakeGenericType(type, fieldType, subFieldType);

            var subField = (NetworkField)Activator
                           .CreateInstance(subFieldGenericType, member, field, attribute);

            return(subField);
        }
        throw new MissingMemberException(attribute.MemberName);
    }
示例#2
0
 public NetworkField CreateField(string fieldName, object value = null, NetworkField.valueInitializer init = NetworkField.valueInitializer.None, bool isProximity = false, bool reliable = true)
 {
     if (FieldExists(fieldName) == false)
     {
         NetworkField newField = new NetworkField();
         newField.fieldName         = fieldName;
         newField.defaultValue      = init;
         newField.shouldBeProximity = isProximity;
         newField.reliable          = reliable;
         if (value != null)
         {
             //newField.UpdateField(value, this);
             newField.LocalFieldSet(value, false);
         }
         else
         {
             if (newField.IsInitialized() == false)
             {
                 newField.InitializeDefaultValue(this);
             }
         }
         fields.Add(newField);
         return(newField);
     }
     return(null);
 }
示例#3
0
    public NetworkFieldData(NetworkField field)
    {
        mortgage = field.isPledged();
        var owner = field.getCurrentOwner();

        ownerID    = owner is null ? -1 : field.getCurrentOwner().getPlayerID();
        courseName = field.getName();
    }
示例#4
0
        internal static void Read(ProfileLog parser)
        {
            var overheadBits = parser.readVarInt();
            var totalBits    = parser.readVarInt();
            var baselineBits = parser.readVarInt();
            var diffBits     = parser.readVarInt();

            var name = parser.readStringId();

            while (name != "class-end")
            {
                //NetworkField
                NetworkField.Read(parser);
                //if version > 3:

                name = parser.readStringId();
            }
        }
示例#5
0
    private void UpdateDataState <T>() where T : struct, IComponentData
    {
        ComponentType  componentType = ComponentType.Create <T>();
        ComponentGroup group         = GetComponentGroup(ComponentType.Create <SyncState>(), componentType, ComponentType.Create <NetworkComponentState <T> >(), ComponentType.Create <NetworktOwner>());
        ComponentDataArray <SyncState> networkSyncStateComponents = group.GetComponentDataArray <SyncState>();
        ComponentDataArray <T>         networkComponents          = group.GetComponentDataArray <T>();
        ComponentDataArray <NetworkComponentState <T> > networkComponentStates = group.GetComponentDataArray <NetworkComponentState <T> >();
        EntityArray entities = group.GetEntityArray();

        NetworkField[] networkMemberInfos = reflectionUtility.GetFields(componentType);
        for (int i = 0; i < entities.Length; i++)
        {
            NativeArray <int> values = EntityManager.GetFixedArray <int>(networkComponentStates[i].dataEntity);
            NetworkComponent  componentDataContainer = new NetworkComponent {
                TypeId = reflectionUtility.GetId(componentType),
            };
            for (int j = 0; j < networkMemberInfos.Length; j++)
            {
                NetworkField <T> networkMemberInfo = (networkMemberInfos[j] as NetworkField <T>);
                if (networkMemberInfo.syncAttribute.InitOnly)
                {
                    continue;
                }

                int newValue = networkMemberInfo.GetValue(networkComponents[i]);
                if (newValue != values[j])
                {
                    componentDataContainer.Fields.Add(new ComponentField {
                        Id    = j,
                        Value = newValue,
                    });
                }
                values[j] = newValue;
            }

            if (componentDataContainer.Fields.Count != 0)
            {
                SyncState networkSyncState = networkSyncStateComponents[i];
                ownNetworkSendMessageUtility.SetComponent(entities[i], networkSyncState.actorId, networkSyncState.networkId, componentDataContainer);
                AllNetworkSendMessageUtility.SetComponent(entities[i], networkSyncState.actorId, networkSyncState.networkId, componentDataContainer);
            }
        }
    }