示例#1
0
        //public static CadFigure Clone(CadFigure src)
        //{
        //    MpFigure_v1002 mpf = MpFigure_v1002.Create(src, false);

        //    byte[] data = MessagePackSerializer.Serialize(mpf);

        //    MpFigure_v1002 mpfCopy = MessagePackSerializer.Deserialize<MpFigure_v1002>(data);

        //    CadFigure fig = mpfCopy.Restore();

        //    fig.ID = 0;

        //    return fig;
        //}

        public static CadFigure Clone(CadFigure src)
        {
            byte[] data = MpUtil.FigToBin(src, false);

            CadFigure fig = MpUtil.BinToFig(data);

            fig.ID = 0;

            return(fig);
        }
示例#2
0
        static bool Prefix(Window window)
        {
            if (Multiplayer.Client != null &&
                window.GetType() == typeof(Dialog_BeginRitual) && // Doesn't let BeginRitualProxy through
                (Multiplayer.ExecutingCmds || Multiplayer.Ticking))
            {
                var dialog = (Dialog_BeginRitual)window;
                dialog.PostOpen(); // Completes initialization

                var comp = dialog.map.MpComp();

                if (comp.ritualSession != null &&
                    (comp.ritualSession.data.ritual != dialog.ritual ||
                     comp.ritualSession.data.outcome != dialog.outcome))
                {
                    Messages.Message("MpAnotherRitualInProgress".Translate(), MessageTypeDefOf.RejectInput, false);
                    return(false);
                }

                if (comp.ritualSession == null)
                {
                    var data = new RitualData
                    {
                        ritual      = dialog.ritual,
                        target      = dialog.target,
                        obligation  = dialog.obligation,
                        outcome     = dialog.outcome,
                        extraInfos  = dialog.extraInfos,
                        action      = dialog.action,
                        ritualLabel = dialog.ritualLabel,
                        confirmText = dialog.confirmText,
                        organizer   = dialog.organizer,
                        assignments = MpUtil.ShallowCopy(dialog.assignments, new MpRitualAssignments())
                    };

                    comp.CreateRitualSession(data);
                }

                if (TickPatch.currentExecutingCmdIssuedBySelf)
                {
                    comp.ritualSession.OpenWindow();
                }

                return(false);
            }

            return(true);
        }
示例#3
0
        public override float DrawOption(Vector2 pos, float width)
        {
            var r = base.DrawOption(pos, width);

            if (Multiplayer.loadingErrors)
            {
                float b          = Text.CalcHeight(label, width);
                float num        = Mathf.Max(minHeight, b);
                Rect  rect       = new Rect(pos.x, pos.y, width, num);
                var   markerRect = new Rect(rect.xMax - 36, rect.center.y - 12, 24, 24);
                GUI.DrawTexture(markerRect, Widgets.CheckboxOffTex);
                TooltipHandler.TipRegion(markerRect, MpUtil.TranslateWithDoubleNewLines("MpLoadingError", 5));
            }

            return(r);
        }
示例#4
0
        static void ShowDebugInfo(Gizmo gizmo, Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
        {
            var info = gizmo.GetType().ToString();

            if (gizmo is Command_Action action)
            {
                info += $"\n\n{MpUtil.DelegateMethodInfo(action.action?.Method)}";
            }

            if (gizmo is Command_Toggle toggle)
            {
                info += $"\n\n{MpUtil.DelegateMethodInfo(toggle.toggleAction?.Method)}";
            }

            TooltipHandler.TipRegion(
                new Rect(topLeft, new Vector2(gizmo.GetWidth(maxWidth), 75f)),
                info
                );
        }
示例#5
0
        static bool Prefix(ref Window window)
        {
            if (Multiplayer.Client == null || window is not Dialog_StylingStation dialog)
            {
                return(true);
            }

            // In vanilla, the styling dialog mutates the pawn directly
            // A dummy pawn taking on the mutations is needed for multiplayer
            var pawn = new StylingDialog_DummyPawn();

            pawn.origPawn        = dialog.pawn;
            pawn.def             = dialog.pawn.def;
            pawn.gender          = dialog.pawn.gender;
            pawn.mapIndexOrState = dialog.pawn.mapIndexOrState;
            pawn.Name            = dialog.pawn.Name;

            pawn.story      = MpUtil.ShallowCopy(dialog.pawn.story, new Pawn_StoryTracker(pawn));
            pawn.story.pawn = pawn;

            pawn.style      = MpUtil.ShallowCopy(dialog.pawn.style, new Pawn_StyleTracker(pawn));
            pawn.style.pawn = pawn;

            pawn.apparel                       = MpUtil.ShallowCopy(dialog.pawn.apparel, new Pawn_ApparelTracker(pawn));
            pawn.apparel.pawn                  = pawn;
            pawn.apparel.lockedApparel         = pawn.apparel.lockedApparel.ToList();
            pawn.apparel.wornApparel           = MpUtil.ShallowCopy(dialog.pawn.apparel.wornApparel, new ThingOwner <Apparel>());
            pawn.apparel.wornApparel.innerList = pawn.apparel.wornApparel.innerList.ToList();

            pawn.health    = new Pawn_HealthTracker(pawn);
            pawn.stances   = new Pawn_StanceTracker(pawn);
            pawn.pather    = new Pawn_PathFollower(pawn);
            pawn.roping    = new Pawn_RopeTracker(pawn);
            pawn.mindState = new Pawn_MindState(pawn);

            window = new Dialog_StylingStation(pawn, dialog.stylingStation);

            return(Multiplayer.ExecutingCmds && TickPatch.currentExecutingCmdIssuedBySelf ||
                   dialog.pawn.CurJob.loadID == SyncMethods.stylingStationJobStartedByMe);
        }
示例#6
0
        public static Dialog_StylingStation CreateStylingDialog(Pawn dialogPawn, Thing stylingStation)
        {
            // In vanilla, the styling dialog mutates the pawn directly
            // A dummy pawn taking on the mutations is needed for multiplayer
            var pawn = new StylingDialog_DummyPawn
            {
                origPawn        = dialogPawn,
                def             = dialogPawn.def,
                gender          = dialogPawn.gender,
                mapIndexOrState = dialogPawn.mapIndexOrState,
                nameInt         = dialogPawn.Name
            };

            pawn.story      = MpUtil.ShallowCopy(dialogPawn.story, new Pawn_StoryTracker(pawn));
            pawn.story.pawn = pawn;

            pawn.style      = MpUtil.ShallowCopy(dialogPawn.style, new Pawn_StyleTracker(pawn));
            pawn.style.pawn = pawn;

            pawn.apparel                       = MpUtil.ShallowCopy(dialogPawn.apparel, new Pawn_ApparelTracker(pawn));
            pawn.apparel.pawn                  = pawn;
            pawn.apparel.lockedApparel         = pawn.apparel.lockedApparel.ToList();
            pawn.apparel.wornApparel           = MpUtil.ShallowCopy(dialogPawn.apparel.wornApparel, new ThingOwner <Apparel>());
            pawn.apparel.wornApparel.innerList = pawn.apparel.wornApparel.innerList.ToList();

            pawn.health    = new Pawn_HealthTracker(pawn);
            pawn.stances   = new Pawn_StanceTracker(pawn);
            pawn.pather    = new Pawn_PathFollower(pawn);
            pawn.roping    = new Pawn_RopeTracker(pawn);
            pawn.mindState = new Pawn_MindState(pawn);
            pawn.ideo      = new Pawn_IdeoTracker(pawn)
            {
                ideo = dialogPawn.ideo.ideo
            };

            return(new Dialog_StylingStation(pawn, stylingStation));
        }
示例#7
0
 public override void Redo(CadObjectDB db)
 {
     MpUtil.Lz4BinRestoreFig(After, db);
 }
示例#8
0
 public override void Undo(CadObjectDB db)
 {
     MpUtil.Lz4BinRestoreFig(Before, db);
 }
示例#9
0
 public void StoreAfter(CadFigure fig)
 {
     After = MpUtil.FigToLz4Bin(fig);
 }
示例#10
0
 public void StoreBefore(CadFigure fig)
 {
     Before   = MpUtil.FigToLz4Bin(fig);
     FigureID = fig.ID;
 }
示例#11
0
 private static List <CadFigure> BinToFigList(byte[] bin)
 {
     return(MpUtil.BinToFigList(bin));
 }
示例#12
0
 private static byte[] FigListToBin(List <CadFigure> figList)
 {
     return(MpUtil.FigListToBin(figList));
 }
示例#13
0
 static void Postfix(FloatMenuOption __instance, Rect rect)
 {
     TooltipHandler.TipRegion(rect, MpUtil.DelegateMethodInfo(__instance.action?.Method));
 }