public override void Bind(object obj, string name) { object value = MpReflection.GetValue(obj, name); Type type = value.GetType(); SyncSerialization.WriteSyncObject(writer, value, type); }
internal static void WriteWithImpl <T>(ByteWriter data, object obj, IList <Type> impls) where T : class { if (obj == null) { data.WriteUShort(ushort.MaxValue); return; } GetImpl(obj, impls, out Type implType, out int impl); if (implType == null) { throw new SerializationException($"Unknown {typeof(T)} implementation type {obj.GetType()}"); } data.WriteUShort((ushort)impl); SyncSerialization.WriteSyncObject(data, obj, implType); }
/// <summary> /// Returns whether the original should be cancelled /// </summary> public bool DoSync(object target, object value, object index = null) { if (!(inGameLoop || Multiplayer.ShouldSync)) { return(false); } LoggingByteWriter writer = new LoggingByteWriter(); MpContext context = writer.MpContext(); writer.Log.Node(ToString()); writer.WriteInt32(syncId); int mapId = ScheduledCommand.Global; if (targetType != null) { SyncSerialization.WriteSyncObject(writer, target, targetType); if (context.map != null) { mapId = context.map.uniqueID; } } SyncSerialization.WriteSyncObject(writer, value, fieldType); if (indexType != null) { SyncSerialization.WriteSyncObject(writer, index, indexType); } writer.Log.Node($"Map id: {mapId}"); Multiplayer.WriterLog.AddCurrentNode(writer); Multiplayer.Client.SendCommand(CommandType.Sync, mapId, writer.ToArray()); return(true); }
private static void WriteData(ByteWriter data, DesignatorMode mode, Designator designator) { SyncSerialization.WriteSync(data, mode); SyncSerialization.WriteSyncObject(data, designator, designator.GetType()); // Read at MapAsyncTimeComp.SetDesignatorState // The reading side affects global state so these can't be SyncWorkers if (designator is Designator_AreaAllowed) { SyncSerialization.WriteSync(data, Designator_AreaAllowed.SelectedArea); } if (designator is Designator_Install install) { SyncSerialization.WriteSync(data, install.MiniToInstallOrBuildingToReinstall); } if (designator is Designator_Zone) { SyncSerialization.WriteSync(data, Find.Selector.SelectedZone); } }
public override void Bind <T>(ref T obj) { SyncSerialization.WriteSyncObject(writer, obj, typeof(T)); }
public void Bind <T>(ref T obj, SyncType type) { SyncSerialization.WriteSyncObject(writer, obj, type); }