コード例 #1
0
 public override void Notify_ItemAdded(RuneBill bill)
 {
     if (bill.runeToManipulate != null && bill.runeToManipulate.TryGetComp <RuneComp>() is RuneComp rune && !rune.CanBeSocketedInto(bill.itemToBeManipulated))
     {
         bill.runeToManipulate = null;
     }
 }
コード例 #2
0
        public override bool TryMakePreToilReservations()
        {
            RuneBill bill = Bill;

            //Log.Message("Bill: " + bill);

            if (bill != null)
            {
                bool reservedItem = false;
                bool reservedRune = false;

                if (Item != null)
                {
                    if (Item.ParentHolder is Map)
                    {
                        if (pawn.CanReserveAndReach(Item, PathEndMode.OnCell, Danger.Deadly))
                        {
                            pawn.Reserve(Item, job);
                            reservedItem = true;
                        }
                    }
                    else
                    {
                        reservedItem = true;
                    }
                }

                if (bill.recipeDef.requiresRune)
                {
                    if (RuneThing != null)
                    {
                        if (RuneThing.ParentHolder is Map)
                        {
                            if (pawn.CanReserveAndReach(RuneThing, PathEndMode.OnCell, Danger.Deadly))
                            {
                                pawn.Reserve(RuneThing, job);
                                reservedRune = true;
                            }
                        }
                        else if (RuneThing.ParentHolder is SocketComp)
                        {
                            reservedRune = true;
                        }
                    }
                }
                else
                {
                    reservedRune = true;
                }

                /*Log.Message("Bill: " + bill.recipeDef.defName);
                 * Log.Message("reservedItem: " + reservedItem);
                 * Log.Message("reservedRune: " + reservedRune);*/

                return(reservedItem && reservedRune);
            }

            return(false);
        }
コード例 #3
0
        public void RearrangeBill(RuneBill bill)
        {
            int oldIndex = bills.IndexOf(bill);

            bills.Remove(bill);
            bills.Insert(oldIndex + bill.moveBill, bill);
            bill.moveBill = 0;
        }
コード例 #4
0
        public override void FinishBill(RuneBill bill, Pawn pawn)
        {
            SocketComp socket = bill.itemToBeManipulated.TryGetComp <SocketComp>();

            if (socket != null)
            {
                socket.SocketRune(bill.runeToManipulate);
            }
        }
コード例 #5
0
 public TargetingParameters GetTargetingParametersForItem(RuneBill bill)
 {
     return(new TargetingParameters
     {
         canTargetPawns = false,
         canTargetBuildings = false,
         canTargetItems = true,
         mapObjectTargetsMustBeAutoAttackable = false,
         validator = ((TargetInfo x) => x.Thing != null && x.Thing.TryGetComp <SocketComp>() is SocketComp socketable)
     });
コード例 #6
0
        public override void FinishBill(RuneBill bill, Pawn pawn)
        {
            SocketComp socket = bill.itemToBeManipulated.TryGetComp <SocketComp>();

            if (socket != null)
            {
                Thing rune = socket.RemoveRune(bill.runeToManipulate);

                if (rune != null)
                {
                    //Try to spawn it nearby.
                    GenPlace.TryPlaceThing(rune, pawn.Position, pawn.Map, ThingPlaceMode.Near);
                }
            }
        }
コード例 #7
0
 /// <summary>
 /// Extra conditions for a pawn doing this recipe.
 /// </summary>
 /// <param name="pawn">Prospecting pawn doing this recipe.</param>
 /// <param name="recipe">Recipe to do it on.</param>
 /// <returns>True if all criterias are met.</returns>
 public abstract bool ExtraPawnCriterias(Pawn pawn, RuneBill bill);
コード例 #8
0
 public override bool RuneTargetingCondition(Thing thing, RuneBill bill)
 {
     return(false);
 }
コード例 #9
0
 /// <summary>
 /// Does the GUI for the Bill.
 /// </summary>
 /// <param name="inRect">Space to work with.</param>
 /// <param name="bill">The Bill to do it on.</param>
 public abstract void DoWorkerGUI(Rect inRect, RuneBill bill);
コード例 #10
0
 public virtual void Notify_ItemAdded(RuneBill bill)
 {
 }
コード例 #11
0
 public override bool CanStartBill(RuneBill bill)
 {
     return(bill.itemToBeManipulated != null && !bill.itemToBeManipulated.Destroyed);
 }
コード例 #12
0
 public abstract bool ItemTargetingCondition(SocketComp socketable, RuneBill bill);
コード例 #13
0
 public virtual void Notify_ItemRemoved(RuneBill bill)
 {
 }
コード例 #14
0
 public override bool ItemTargetingCondition(SocketComp socketable, RuneBill bill)
 {
     return(socketable.CanBeSocketed && socketable.SocketedRunes.Count() > 0);
 }
コード例 #15
0
 public override bool RuneTargetingCondition(Thing thing, RuneBill bill)
 {
     return(thing.TryGetComp <RuneComp>() is RuneComp rune && rune.CanBeSocketedInto(bill.itemToBeManipulated));
 }
コード例 #16
0
 /// <summary>
 /// Can this Bill be started?
 /// </summary>
 /// <param name="bill">The Bill to check.</param>
 /// <returns>True if it can.</returns>
 public abstract bool CanStartBill(RuneBill bill);
コード例 #17
0
 public override void Notify_ItemRemoved(RuneBill bill)
 {
     bill.runeToManipulate = null;
 }
コード例 #18
0
        protected override void FillTab()
        {
            Rect  mainRect = new Rect(0f, 0f, WinSize.x, WinSize.y);
            float rowY     = mainRect.y;

            //Title
            Text.Anchor = TextAnchor.UpperCenter;
            Text.Font   = GameFont.Medium;
            Rect titleRect = new Rect(mainRect);

            titleRect.y     += Text.LineHeight;
            titleRect.height = Text.LineHeight;
            Widgets.Label(titleRect, "RunesRuneBills".Translate());
            //rowY = Text.LineHeight + 2f;
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;

            //Bills & Add Bill
            Rect outerBillsRect = new Rect(mainRect);

            outerBillsRect.y      = titleRect.yMax + 2f;
            outerBillsRect.height = mainRect.height - outerBillsRect.y - 4f;
            outerBillsRect.x     += 4f;
            outerBillsRect.width -= 8f;

            Widgets.DrawWindowBackground(outerBillsRect);

            Rect  innerBillsRect = new Rect(outerBillsRect);
            float billHeightSize = outerBillsRect.height / 2.5f;

            innerBillsRect.height = billHeightSize * (1 + SelTable.billStack.bills.Count);

            Widgets.BeginScrollView(outerBillsRect, ref billsScrollPosition, innerBillsRect);

            rowY = outerBillsRect.y;

            //Do Bills
            int      index      = 0;
            RuneBill billToMove = null;
            RuneBill deleteBill = null;

            foreach (RuneBill bill in SelTable.billStack.bills)
            {
                Rect billRect = new Rect(innerBillsRect);
                billRect.y      = rowY;
                billRect.height = billHeightSize;

                if (index % 2 == 0)
                {
                    Widgets.DrawAltRect(billRect);
                }

                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;

                Rect billTitleRect = new Rect(billRect);
                billTitleRect.x     += 26f;
                billTitleRect.width -= 26f;
                Widgets.Label(billTitleRect, bill.recipeDef.label);

                if (bill.assignedPawn != null)
                {
                    Text.Anchor = TextAnchor.LowerLeft;
                    Text.Font   = GameFont.Tiny;
                    Widgets.Label(billRect, "RunesBillAuthor".Translate(bill.assignedPawn.Name.ToString()));
                    Text.Anchor = TextAnchor.UpperLeft;
                    Text.Font   = GameFont.Small;
                }

                //bill.recipeDef.Worker.DoWorkerGUI(billRect, bill);
                bill.DoGUI(billRect);

                if (bill.moveBill != 0)
                {
                    billToMove = bill;
                }

                if (bill.deleted)
                {
                    deleteBill = bill;
                }

                rowY += billHeightSize;
                index++;
            }

            //Do Add Bill
            Rect addBillRect = new Rect(innerBillsRect);

            addBillRect.y      = rowY;
            addBillRect.height = billHeightSize;

            if (index % 2 == 0)
            {
                Widgets.DrawAltRect(addBillRect);
            }

            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;

            Widgets.Label(addBillRect, "RunesAddRuneBill".Translate());

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            Widgets.DrawHighlightIfMouseover(addBillRect);
            if (Widgets.ButtonInvisible(addBillRect))
            {
                FloatMenuUtility.MakeMenu <RuneRecipeDef>(
                    DefDatabase <RuneRecipeDef> .AllDefs,
                    (recipeDef) => recipeDef.label,
                    (RuneRecipeDef recipeDef) => delegate()
                {
                    RuneBill bill  = new RuneBill();
                    bill.recipeDef = recipeDef;

                    SelTable.billStack.AddBill(bill);
                });
            }

            Widgets.EndScrollView();

            //Manipulate
            if (billToMove != null)
            {
                //SelTable.billStack.bills

                /*int oldIndex = SelTable.billStack.bills.IndexOf(billToMove);
                 *
                 * SelTable.billStack.bills.Remove(billToMove);
                 * SelTable.billStack.bills.Insert(oldIndex + billToMove.moveBill, billToMove);
                 * billToMove.moveBill = 0;*/
                SelTable.billStack.RearrangeBill(billToMove);
            }

            //Delete
            if (deleteBill != null)
            {
                SelTable.billStack.RemoveBill(deleteBill);
            }
        }
コード例 #19
0
 public void AddBill(RuneBill bill)
 {
     bill.billstack = this;
     bills.Add(bill);
 }
コード例 #20
0
 public void RemoveBill(RuneBill bill)
 {
     bill.Notify_Removed();
     bills.Remove(bill);
 }
コード例 #21
0
 /// <summary>
 /// Finishes the Bill. Doing the resulting action.
 /// </summary>
 /// <param name="bill">The Bill being finished.</param>
 /// <param name="pawn">Pawn doing the finishing touch.</param>
 public abstract void FinishBill(RuneBill bill, Pawn pawn);
コード例 #22
0
 public override bool ItemTargetingCondition(SocketComp socketable, RuneBill bill)
 {
     return(socketable.CanBeSocketed && socketable.FreeSlots > 0);
 }