public static void WriteContext(SyncHandler handler, ByteWriter data) { if (handler.context == SyncContext.None) { return; } if (handler.context.HasFlag(SyncContext.CurrentMap)) { data.MpContext().map = Find.CurrentMap; } if (handler.context.HasFlag(SyncContext.MapMouseCell)) { data.MpContext().map = Find.CurrentMap; SyncSerialization.WriteSync(data, UI.MouseCell()); } if (handler.context.HasFlag(SyncContext.MapSelected)) { SyncSerialization.WriteSync(data, Find.Selector.selected.Cast <ISelectable>().ToList()); } if (handler.context.HasFlag(SyncContext.WorldSelected)) { SyncSerialization.WriteSync(data, Find.WorldSelector.selected.Cast <ISelectable>().ToList()); } if (handler.context.HasFlag(SyncContext.QueueOrder_Down)) { data.WriteBool(KeyBindingDefOf.QueueOrder.IsDownEvent); } }
public static bool DesignateMultiCell(Designator __instance, IEnumerable <IntVec3> __0) { if (!Multiplayer.ShouldSync) { return(true); } // No cells implies Finalize(false), which currently doesn't cause side effects if (__0.Count() == 0) { return(true); } Designator designator = __instance; Map map = Find.CurrentMap; LoggingByteWriter writer = new LoggingByteWriter(); writer.Log.Node("Designate multi cell: " + designator.GetType()); IntVec3[] cellArray = __0.ToArray(); WriteData(writer, DesignatorMode.MultiCell, designator); SyncSerialization.WriteSync(writer, cellArray); Multiplayer.Client.SendCommand(CommandType.Designator, map.uniqueID, writer.ToArray()); Multiplayer.WriterLog.AddCurrentNode(writer); return(false); }
public static bool DesignateSingleCell(Designator __instance, IntVec3 __0) { if (!Multiplayer.ShouldSync) { return(true); } Designator designator = __instance; Map map = Find.CurrentMap; LoggingByteWriter writer = new LoggingByteWriter(); writer.Log.Node("Designate single cell: " + designator.GetType()); WriteData(writer, DesignatorMode.SingleCell, designator); SyncSerialization.WriteSync(writer, __0); Multiplayer.Client.SendCommand(CommandType.Designator, map.uniqueID, writer.ToArray()); Multiplayer.WriterLog.AddCurrentNode(writer); return(false); }
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); } }
private void ActualSync(A target, B arg0, C arg1, Action original) { LoggingByteWriter writer = new LoggingByteWriter(); MpContext context = writer.MpContext(); writer.Log.Node("Sync action"); writer.WriteInt32(syncId); SyncSerialization.WriteSync(writer, target); SyncSerialization.WriteSync(writer, arg0); SyncSerialization.WriteSync(writer, arg1); writer.WriteInt32(GenText.StableStringHash(original.Method.MethodDesc())); Log.Message(original.Method.MethodDesc()); int mapId = writer.MpContext().map?.uniqueID ?? -1; writer.Log.Node("Map id: " + mapId); Multiplayer.WriterLog.AddCurrentNode(writer); Multiplayer.Client.SendCommand(CommandType.Sync, mapId, writer.ToArray()); }
public static bool DesignateThing(Designator __instance, Thing __0) { if (!Multiplayer.ShouldSync) { return(true); } Designator designator = __instance; Map map = Find.CurrentMap; LoggingByteWriter writer = new LoggingByteWriter(); writer.Log.Node("Designate thing: " + __0 + " " + designator.GetType()); WriteData(writer, DesignatorMode.Thing, designator); SyncSerialization.WriteSync(writer, __0); Multiplayer.Client.SendCommand(CommandType.Designator, map.uniqueID, writer.ToArray()); Multiplayer.WriterLog.AddCurrentNode(writer); FleckMaker.ThrowMetaPuffs(__0); return(false); }