public override EntityKey Create( IEntityType entityType, IReadOnlyList<IProperty> properties, IValueReader valueReader) { var components = new object[properties.Count]; for (var i = 0; i < properties.Count; i++) { var index = properties[i].Index; if (valueReader.IsNull(index)) { return EntityKey.InvalidEntityKey; } var value = _boxedValueReaders[i].ReadValue(valueReader, index); if (Equals(value, _sentinels[i])) { return EntityKey.InvalidEntityKey; } components[i] = value; } return new CompositeEntityKey(entityType, components); }
/// <summary> /// Initializes a new instance of the <see cref="SkeletonFrame"/> class. /// </summary> /// <param name="reader">The <see cref="IValueReader"/> to read from.</param> /// <param name="contentPath">The <see cref="ContentPaths"/> to use to load from.</param> /// <exception cref="InvalidOperationException">The <see cref="Skeleton"/> failed to load.</exception> public SkeletonFrame(IValueReader reader, ContentPaths contentPath) { Read(reader, contentPath); if (Skeleton == null) throw new InvalidOperationException("Skeleton failed to load."); }
public override void ReadPayload(IValueReader reader) { this.NetworkID = reader.ReadUInt32(); this.CharacterName = reader.ReadString(); this.Action = (PlayerUpdateAction)reader.ReadByte(); }
internal ServerInfo(ISerializationContext context, IValueReader reader) { if (reader == null) throw new ArgumentNullException ("reader"); Deserialize (context, reader); }
public ChannelChangeInfo(ISerializationContext context, IValueReader reader) { if (reader == null) throw new ArgumentNullException("reader"); Deserialize (context, reader); }
private IEventCommand ReadNextEvent(IValueReader reader, ScriptCommandType commandType) { IEventCommand command = null; switch(commandType) { case ScriptCommandType.Jump: command = new JumpCommand (); break; case ScriptCommandType.Lock: command = new LockCommand (); break; case ScriptCommandType.Pause: command = new PauseCommand (); break; case ScriptCommandType.PauseEvent: command = new PauseEventCommand (); break; case ScriptCommandType.ApplyMovement: command = new ApplyMovementCommand (); break; case ScriptCommandType.Release: command = new ReleaseCommand (); break; default: break; } if(command == null) throw new ArgumentOutOfRangeException ("commandType", "The specified event was not found."); command.Deserialize (reader); return command; }
public virtual InternalEntityEntry StartTracking(IEntityType entityType, object entity, IValueReader valueReader) { // TODO: Perf: Pre-compute this for speed var keyProperties = entityType.GetPrimaryKey().Properties; var keyValue = _keyFactorySource.GetKeyFactory(keyProperties).Create(entityType, keyProperties, valueReader); if (keyValue == EntityKey.InvalidEntityKey) { throw new InvalidOperationException(Strings.InvalidPrimaryKey(entityType.DisplayName())); } var existingEntry = TryGetEntry(keyValue); if (existingEntry != null) { if (existingEntry.Entity != entity) { throw new InvalidOperationException(Strings.IdentityConflict(entityType.DisplayName())); } return existingEntry; } var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueReader)); _identityMap.Add(keyValue, newEntry); _entityReferenceMap[entity] = newEntry; newEntry.SetEntityState(EntityState.Unchanged); return newEntry; }
private NetworkEntity ReadEntity(ISerializationContext context, IValueReader reader) { var entity = new NetworkEntity (reader.ReadString (), EntityType.Client); entity.NetworkID = reader.ReadUInt16 (); UInt16 fieldCount = reader.ReadUInt16 (); for (int f = 0; f < fieldCount; f++) { string name = reader.ReadString (); ushort typeID = reader.ReadUInt16 (); Type type; context.TypeMap.TryGetType (typeID, out type); object value; if (type == typeof (Vector2)) value = reader.Read (context, Vector2Serializer.Instance); else if (type == typeof (Vector3)) value = reader.Read (context, Vector3Serializer.Instance); else value = reader.Read (context, type); entity.Fields.Add (name, new PropertyGroup (value, type)); } return entity; }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { int[] sourceIds = new int[reader.ReadInt32()]; for (int i = 0; i < sourceIds.Length; ++i) sourceIds[i] = reader.ReadInt32(); this.SourceIds = sourceIds; }
public void Read(IValueReader reader) { GrhIndex = reader.ReadGrhIndex(_grhIndexValueKey); _sourceName = reader.ReadString(_sourceValueKey); _destName = reader.ReadString(_destValueKey); Offset = reader.ReadVector2(_offsetValueKey); Origin = reader.ReadVector2(_originValueKey); }
/// <summary> /// Reads all properties for the given <paramref name="obj"/> that have the <see cref="SyncValueAttribute"/> /// attribute from the given <see cref="IValueWriter"/>. /// </summary> /// <param name="obj">The object to read the persistent values for.</param> /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param> public static void Read(object obj, IValueReader reader) { var propertySyncs = PropertySyncHelper.GetPropertySyncs(obj.GetType()); foreach (var ps in propertySyncs) { ps.ReadValue(obj, reader); } }
public override void ReadPayload(IValueReader reader) { base.ReadPayload(reader); var internalEndPointAddress = new IPAddress(reader.ReadBytes()); InternalOwnEndPoint = new IPEndPoint(internalEndPointAddress, reader.ReadInt32()); var externalEndPointAddress = new IPAddress(reader.ReadBytes()); ExternalPeerEndPoint = new IPEndPoint(externalEndPointAddress, reader.ReadInt32()); }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { AudioSource[] sourceInfos = new AudioSource[reader.ReadInt32()]; for (int i = 0; i < sourceInfos.Length; ++i) sourceInfos[i] = new AudioSource (context, reader); this.Sources = sourceInfos; }
public override void ReadPayload (ISerializationContext context, IValueReader reader) { if (reader.ReadBool()) SenderId = reader.ReadString(); GroupId = reader.ReadInt32(); Text = reader.ReadString(); }
public override EntityKey Create(IEntityType entityType, IReadOnlyList<IProperty> properties, IValueReader valueReader) { Check.NotNull(entityType, "entityType"); Check.NotNull(properties, "properties"); Check.NotNull(valueReader, "valueReader"); // TODO: Consider using strongly typed ReadValue instead of always object return Create(entityType, properties.Select(p => valueReader.ReadValue<object>(p.Index)).ToArray()); }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { int numUsers = reader.ReadInt32(); IUser[] users = new IUser[numUsers]; for (int i = 0; i < users.Length; ++i) users[i] = new User (reader.ReadInt32(), reader.ReadString()); Users = users; }
public void Deserialize(IValueReader reader) { this.NonCharacter = reader.ReadBool(); this.PlayerID = reader.ReadInt32 (); int count = reader.ReadInt32 (); for(int i = 0; i < count; i++) this.path.Add ((Directions) reader.ReadInt32 ()); }
/// <summary> /// Initializes a new instance of the <see cref="AnimatedGrhData"/> class. /// </summary> /// <param name="r">The <see cref="IValueReader"/>.</param> /// <param name="grhIndex">The <see cref="GrhIndex"/>.</param> /// <param name="cat">The <see cref="SpriteCategorization"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="cat"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="grhIndex"/> is equal to GrhIndex.Invalid.</exception> AnimatedGrhData(IValueReader r, GrhIndex grhIndex, SpriteCategorization cat) : base(grhIndex, cat) { var speed = r.ReadInt(_speedValueKey); var frames = r.ReadMany(_framesNodeName, (xreader, xname) => xreader.ReadGrhIndex(xname)); _speed = 1f / speed; _frames = CreateFrames(frames); _size = GetMaxSize(_frames); }
/// <summary> /// Reads a filter from an <see cref="IValueReader"/>. /// </summary> /// <param name="reader">The <see cref="IValueReader"/> to read from.</param> /// <returns>The name of the filter and the filter object.</returns> static KeyValuePair<string, MapDrawFilterHelper> ReadFilter(IValueReader reader) { var key = reader.ReadString(_filterKeyValueName); var valueReader = reader.ReadNode(_filterValueValueName); var value = new MapDrawFilterHelper(valueReader); return new KeyValuePair<string, MapDrawFilterHelper>(key, value); }
/// <summary> /// Initializes a new instance of the <see cref="MapGrh"/> class. /// </summary> /// <param name="reader">The reader to read the values from.</param> /// <param name="currentTime">The current time.</param> /// <exception cref="ArgumentNullException"><paramref name="reader" /> is <c>null</c>.</exception> public MapGrh(IValueReader reader, TickCount currentTime) { if (reader == null) throw new ArgumentNullException("reader"); _grh = new Grh(null, AnimType.Loop, currentTime); ReadState(reader); }
public override void ReadPayload(IValueReader reader) { int count = reader.ReadInt32 (); for(int i = 0; i < count; i++) { ScriptCommandType commandType = (ScriptCommandType) reader.ReadInt32 (); this.EventCommands.Add (this.ReadNextEvent (reader, commandType)); } }
public override void ReadPayload(IValueReader reader) { this.NetworkID = reader.ReadUInt32 (); this.X = reader.ReadInt32 (); this.Y = reader.ReadInt32 (); this.Direction = reader.ReadInt32 (); this.Animation = reader.ReadString (); }
internal NetworkServerConnection(NetworkServerConnectionProvider provider, uint nid, TcpClient tcp, IPEndPoint endPoint, IValueWriter uwriter) { this.NetworkId = nid; this.Tcp = tcp; this.ReliableStream = tcp.GetStream (); this.provider = provider; this.EndPoint = endPoint; this.UnreliableWriter = uwriter; this.ReliableReader = new StreamValueReader (ReliableStream); this.ReliableWriter = new StreamValueWriter (ReliableStream); }
private InternalEntityEntry NewInternalEntityEntry(IStateManager stateManager, IEntityType entityType, object entity, IValueReader valueReader) { if (!entityType.HasClrType()) { return new InternalShadowEntityEntry(stateManager, entityType, _metadataServices, valueReader); } return entityType.ShadowPropertyCount() > 0 ? (InternalEntityEntry)new InternalMixedEntityEntry(stateManager, entityType, _metadataServices, entity, valueReader) : new InternalClrEntityEntry(stateManager, entityType, _metadataServices, entity); }
private object[] ExtractShadowValues(IValueReader valueReader) { var shadowValues = new object[EntityType.ShadowPropertyCount()]; foreach (var property in EntityType.GetProperties().Where(property => property.IsShadowProperty)) { shadowValues[property.GetShadowIndex()] = MetadataServices.ReadValueFromReader(valueReader, property); } return shadowValues; }
/// <summary> /// Initializes a new instance of the <see cref="BodyInfo"/> class. /// </summary> /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param> public BodyInfo(IValueReader reader) { ID = reader.ReadBodyID(_idValueKey); Body = reader.ReadString(_bodyValueKey); Fall = reader.ReadString(_fallValueKey); Jump = reader.ReadString(_jumpValueKey); Punch = reader.ReadString(_punchValueKey); Stand = reader.ReadString(_standValueKey); Walk = reader.ReadString(_walkValueKey); Size = reader.ReadVector2(_sizeValueKey); }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { int entityCount = reader.ReadInt32 (); Entities = new List<SnapshotEntity>(entityCount); // Read in the entities for (int i = 0; i < entityCount; i++) { NetworkEntity entity = ReadEntity(context, reader); Entities.Add (new SnapshotEntity (entity, true)); } }
/// <summary> /// Initializes a new instance of the <see cref="BodyInfo"/> class. /// </summary> /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param> public BodyInfo(IValueReader reader) { ID = reader.ReadBodyID(_idValueKey); Body = reader.ReadString(_bodyValueKey); Fall = reader.ReadString(_fallValueKey); Jump = reader.ReadString(_jumpValueKey); Attack = reader.ReadString(_attackValueKey); Stand = reader.ReadString(_standValueKey); Walk = reader.ReadString(_walkValueKey); Size = reader.ReadVector2(_sizeValueKey); Paperdoll = reader.ReadBool(_paperdollValueKey); }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundImage"/> class. /// </summary> /// <param name="cameraProvider">The camera provider.</param> /// <param name="map">The map that this <see cref="BackgroundImage"/> is on.</param> /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param> /// <exception cref="ArgumentNullException"><paramref name="cameraProvider" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="map" /> is <c>null</c>.</exception> protected BackgroundImage(ICamera2DProvider cameraProvider, IMap map, IValueReader reader) { if (cameraProvider == null) throw new ArgumentNullException("cameraProvider"); if (map == null) throw new ArgumentNullException("map"); _cameraProvider = cameraProvider; _map = map; Read(reader); }
/// <summary> /// Initializes a new instance of the <see cref="MapGrh"/> class. /// </summary> /// <param name="reader">The reader to read the values from.</param> /// <param name="currentTime">The current time.</param> /// <exception cref="ArgumentNullException"><paramref name="reader" /> is <c>null</c>.</exception> public MapGrh(IValueReader reader, TickCount currentTime) { if (reader == null) throw new ArgumentNullException("reader"); _grh = new Grh(null, AnimType.Loop, currentTime); ReadState(reader); // Set the initial size value var grhSize = Grh.Size; Vector2.Multiply(ref _scale, ref grhSize, out _scaledGrhSizeCache); }
/// <summary> /// When overridden in the derived class, reads a value with the specified name from an IValueReader. /// </summary> /// <param name="name">Name of the value.</param> /// <param name="reader">IValueReader to read from.</param> /// <returns>Value read from the IValueReader.</returns> protected override AccountID Read(string name, IValueReader reader) { return(reader.ReadAccountID(name)); }
/// <summary> /// Initializes a new instance of the <see cref="NPCChatDialogItemBase"/> class. /// </summary> /// <param name="reader">IValueReader to read the values from.</param> protected NPCChatDialogItemBase(IValueReader reader) { Read(reader); }
/// <summary> /// When overridden in the derived class, reads all custom state values from the <paramref name="reader"/>. /// </summary> /// <param name="reader">The <see cref="IValueReader"/> to read the state values from.</param> protected override void ReadCustomValues(IValueReader reader) { ConeAngle = reader.ReadFloat(_coneAngleKeyName); Direction = reader.ReadFloat(_directionKeyName); }
public override void OnWriteValue(object obj, IValueReader valueReader) { WriteValue(obj, read(valueReader)); }
/// <summary> /// 从值读取器中读取一个值设置到指定键的值中。 /// </summary> /// <param name="key">指定键</param> /// <param name="valueReader">值读取器</param> public void OnWriteValue(TOut key, IValueReader valueReader) { dataWriter.OnWriteValue(XConvert <TIn> .Convert(key), valueReader); }
/// <summary> /// When overridden in the derived class, reads a value with the specified name from an IValueReader. /// </summary> /// <param name="name">Name of the value.</param> /// <param name="reader">IValueReader to read from.</param> /// <returns>Value read from the IValueReader.</returns> protected override Color Read(string name, IValueReader reader) { return(reader.ReadColor(name)); }
public override void OnWriteValue(object obj, IValueReader valueReader) { WriteValue(obj, valueInterface.ReadValue(valueReader)); }
/// <summary> /// Reads the state of the object from an <see cref="IValueReader"/>. /// </summary> /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param> public virtual void ReadState(IValueReader reader) { PersistableHelper.Read(this, reader); }
/// <summary> /// Initializes a new instance of the <see cref="QuestDescription"/> class. /// </summary> /// <param name="r">The <see cref="IValueReader"/>.</param> public QuestDescription(IValueReader r) { ReadState(r); }
public double ReadValue(IValueReader valueReader) { return(valueReader.ReadDouble()); }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { Comment = reader.ReadString(); }
public decimal ReadValue(IValueReader valueReader) { return(valueReader.ReadDecimal()); }
/// <summary> /// When overridden in the derived class, reads a value with the specified name from an IValueReader. /// </summary> /// <param name="name">Name of the value.</param> /// <param name="reader">IValueReader to read from.</param> /// <returns>Value read from the IValueReader.</returns> protected override CharacterTemplateID Read(string name, IValueReader reader) { return(reader.ReadCharacterTemplateID(name)); }
public void OnWriteValue(object obj, IValueReader valueReader) { Assert(CanWrite, "set"); _set(obj, ValueInterface <TValue> .ReadValue(valueReader)); }
public XAssistant ReadValue(IValueReader valueReader) => default;
/// <summary> /// When overridden in the derived class, reads a value with the specified name from an IValueReader. /// </summary> /// <param name="name">Name of the value.</param> /// <param name="reader">IValueReader to read from.</param> /// <returns>Value read from the IValueReader.</returns> protected override double Read(string name, IValueReader reader) { return(reader.ReadDouble(name)); }
/// <summary> /// When overridden in the derived class, reads a value with the specified name from an IValueReader. /// </summary> /// <param name="name">Name of the value.</param> /// <param name="reader">IValueReader to read from.</param> /// <returns>Value read from the IValueReader.</returns> protected override ItemType Read(string name, IValueReader reader) { return(reader.ReadEnum <ItemType>(name)); }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { }
public virtual void OnWriteValue(object obj, IValueReader valueReader) { Assert(canWrite, "write"); fieldRW.OnWriteValue(obj, valueReader); }
/// <summary> /// Reads the <see cref="ParticleModifier"/>'s custom values from the <see cref="reader"/>. /// </summary> /// <param name="reader"><see cref="IValueReader"/> to read the custom values from.</param> protected override void ReadCustomValues(IValueReader reader) { Position = reader.ReadVector2(_positionKeyName); Radius = reader.ReadFloat(_radiusKeyName); Strength = reader.ReadFloat(_strengthKeyName); }
public void OnWriteValue(string key, IValueReader valueReader) { name = key; DirectWrite(valueReader.DirectRead()); }
void IXFieldRW.OnWriteValue(object obj, IValueReader valueReader) { Value = ValueInterface <TValue> .ReadValue(valueReader); }
public object ReadValue(IValueReader valueReader) { return(valueReader.DirectRead()); }
public uint ReadValue(IValueReader valueReader) { return(valueReader.ReadUInt32()); }
/// <summary> /// When overridden in the derived class, reads a value with the specified name from an IValueReader. /// </summary> /// <param name="name">Name of the value.</param> /// <param name="reader">IValueReader to read from.</param> /// <returns>Value read from the IValueReader.</returns> protected override TextureAssetName Read(string name, IValueReader reader) { return(reader.ReadTextureAssetName(name)); }
public static T ReadValue(IValueReader reader, string name) { var v = (int)(reader.ReadUInt(name, _bitsRequired) + _minValue); return(FromInt(v)); }
private readonly IValueReader _valueReader; // TODO: This only works with buffering value readers public BufferedEntity(IEntityType entityType, IValueReader valueReader) { _entityType = entityType; _valueReader = valueReader; }
public virtual object GetEntity(IEntityType entityType, IValueReader valueReader) { return(GetEntity(entityType, valueReader, queryStateManager: true)); }
/// <summary> /// When overridden in the derived class, creates a NPCChatResponseBase using the given IValueReader. /// </summary> /// <param name="reader">IValueReader to read the values from.</param> /// <returns>A NPCChatResponseBase created using the given IValueReader</returns> protected abstract NPCChatResponseBase CreateResponse(IValueReader reader);
public override void ReadPayload(ISerializationContext context, IValueReader reader) { FromServer = reader.ReadBool(); UserId = reader.ReadInt32(); }