예제 #1
0
        static List <FloatMenuOption> GetBlockingWindowOptions(ColonistBar.Entry entry, ITickable tickable)
        {
            List <FloatMenuOption> options = new List <FloatMenuOption>();
            var split = Multiplayer.WorldComp.splitSession;

            if (split != null && split.Caravan.pawns.Contains(entry.pawn))
            {
                options.Add(new FloatMenuOption("MpCaravanSplittingSession".Translate(), () =>
                {
                    SwitchMap(entry.map);
                    CameraJumper.TryJumpAndSelect(entry.pawn);
                    Multiplayer.WorldComp.splitSession.OpenWindow();
                }));
            }

            if (Multiplayer.WorldComp.trading.FirstOrDefault(t => t.playerNegotiator?.Map == entry.map) is MpTradeSession trade)
            {
                options.Add(new FloatMenuOption("MpTradingSession".Translate(), () =>
                {
                    SwitchMap(entry.map);
                    CameraJumper.TryJumpAndSelect(trade.playerNegotiator);
                    Find.WindowStack.Add(new TradingWindow()
                    {
                        selectedTab = Multiplayer.WorldComp.trading.IndexOf(trade)
                    });
                }));
            }

            if (entry.map?.MpComp().transporterLoading != null)
            {
                options.Add(new FloatMenuOption("MpTransportLoadingSession".Translate(), () =>
                {
                    SwitchMap(entry.map);
                    entry.map.MpComp().transporterLoading.OpenWindow();
                }));
            }

            if (entry.map?.MpComp().caravanForming != null)
            {
                options.Add(new FloatMenuOption("MpCaravanFormingSession".Translate(), () =>
                {
                    SwitchMap(entry.map);
                    entry.map.MpComp().caravanForming.OpenWindow();
                }));
            }

            if (entry.map?.MpComp().ritualSession != null)
            {
                options.Add(new FloatMenuOption("MpRitualSession".Translate(), () =>
                {
                    SwitchMap(entry.map);
                    entry.map.MpComp().ritualSession.OpenWindow();
                }));
            }

            return(options);
        }
예제 #2
0
        /// <summary>
        /// Gets the reorderable group for the <see cref="ColonistBar"/>.
        /// </summary>
        /// <param name="entry">The entry to reorder.</param>
        /// <param name="entries">The colonist bar entries.</param>
        /// <returns>The new group to reorder to.</returns>
        private static int GetReorderableGroup(ColonistBar.Entry entry, List <ColonistBar.Entry> entries)
        {
            int group = entry.group;

            return(ReorderableWidget.NewGroup(delegate(int from, int to)
            {
                ColonistBarUtility.Reorder(from, to, group, entries);
            },
                                              ReorderableDirection.Horizontal,
                                              Find.ColonistBar.SpaceBetweenColonistsHorizontal,
                                              delegate(int index, Vector2 dragStartPos)
            {
                ColonistBarUtility.DrawColonistMouseAttachment(
                    index, dragStartPos, group, entries);
            }));
        }
예제 #3
0
 /// <summary>
 /// Handles the repainting of the <see cref="ColonistBar"/> for a given <see cref="ColonistBar.Entry"/>.
 /// </summary>
 /// <param name="entry">The <see cref="ColonistBar"/> entry to repaint.</param>
 /// <param name="rect">The <see cref="Rect"/> to draw when drawing the entry pawn.</param>
 /// <param name="isDifferentGroup">Whether the <see cref="ColonistBar.Entry"/> belongs to a different group compared to the previous entry.</param>
 /// <param name="reordering">Whether the <see cref="ColonistBar"/> entry is part of a reordering.</param>
 /// <param name="colonistsToHighlight">Pawns that have to be highlighted on the <see cref="ColonistBar"/>.</param>
 private static void HandleRepaint(ColonistBar.Entry entry, Rect rect, bool isDifferentGroup, bool reordering, List <Pawn> colonistsToHighlight)
 {
     if (Event.current.type == EventType.Repaint)
     {
         if (isDifferentGroup && ColonistBarUtility.ShowGroupFrames)
         {
             Find.ColonistBar.drawer.DrawGroupFrame(entry.group);
         }
         if (entry.pawn != null)
         {
             bool highlight = colonistsToHighlight.Contains(entry.pawn);
             Find.ColonistBar.drawer.DrawColonist(
                 rect, entry.pawn, entry.map, highlight, reordering);
         }
     }
 }
        /// <summary>
        /// Tries to get the colonist bar entry at the given position. Original public method: <see cref="ColonistBar.TryGetEntryAt(Vector2, out ColonistBar.Entry)"/>.
        /// </summary>
        /// <param name="pos">The target position.</param>
        /// <param name="entry">The result of the search.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public static bool TryGetEntryAt(Vector2 pos, out ColonistBar.Entry entry)
        {
            List <Vector2> drawLocs = Find.ColonistBar.DrawLocs;
            var            entries  = ColonistBarUtility.GetVisibleEntries();
            Vector2        size     = Find.ColonistBar.Size;

            for (int i = 0; i < drawLocs.Count; i++)
            {
                Rect rect = new Rect(drawLocs[i].x, drawLocs[i].y, size.x, size.y);
                if (rect.Contains(pos))
                {
                    entry = entries[i];
                    return(true);
                }
            }
            entry = default(ColonistBar.Entry);
            return(false);
        }
예제 #5
0
            public static void Listener(ColonistBar __instance, ref List <ColonistBar.Entry> ___cachedEntries, ref ColonistBarDrawLocsFinder ___drawLocsFinder, ref List <Vector2> ___cachedDrawLocs, ref float ___cachedScale)
            {
                try
                {
                    if (!Settings.hideInactiveSurrogates)
                    {
                        return;
                    }

                    List <ColonistBar.Entry> toDel = null;
                    //Suppresssion de la barre du haut des surrogates non actifs
                    for (int i = 0; i < ___cachedEntries.Count; i++)
                    {
                        ColonistBar.Entry e = ___cachedEntries[i];
                        if (e.pawn.IsSurrogateAndroid(false, true))
                        {
                            if (toDel == null)
                            {
                                toDel = new List <ColonistBar.Entry>();
                            }

                            toDel.Add(e);
                        }
                    }
                    if (toDel != null)
                    {
                        for (int i = 0; i < toDel.Count; i++)
                        {
                            ColonistBar.Entry e = toDel[i];
                            ___cachedEntries.Remove(e);
                        }

                        __instance.drawer.Notify_RecachedEntries();

                        ___drawLocsFinder.CalculateDrawLocs(___cachedDrawLocs, out ___cachedScale);
                    }
                }
                catch (Exception e)
                {
                    Log.Message("[ATPP] Colonistbar.CheckRecacheEntries " + e.Message + " " + e.StackTrace);
                }
            }
 private static bool Prefix(ref bool __result, Vector2 pos, ref ColonistBar.Entry entry)
 {
     __result = ColonistBarUtility.TryGetEntryAt(pos, out entry);
     return(false);
 }
 /// <summary>
 /// Checks if the given colonist bar entry is hidden.
 /// </summary>
 /// <param name="entry">The colonist bar entry to check.</param>
 /// <returns>True if the entry is marked as hidden, false otherwise.</returns>
 public static bool IsHidden(ColonistBar.Entry entry)
 {
     return(IsHidden(entry.pawn));
 }