Exemplo n.º 1
0
        public override void OnStartReceiver(RealmData realmData)
        {
            // We ask for confirmation

            Dialog_GeneralChoice choiceDialog = new Dialog_GeneralChoice(new DialogChoiceConfig
            {
                text          = sender.name + " wants to send you a " + realmAnimal.FromRealmAnimal(realmData).kindDef.label,
                buttonAText   = "Accept",
                buttonAAction = () =>
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.ACCEPTED
                    });
                },
                buttonBText   = "Refuse",
                buttonBAction = () =>
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.DECLINED
                    });
                }
            });

            Find.WindowStack.Add(choiceDialog);
        }
Exemplo n.º 2
0
        public override void OnStartReceiver(RealmData realmData)
        {
            // We generate a detailed list of what the pack contains
            List <KeyValuePair <Thing, int> > things = realmThings.Select((r) => new KeyValuePair <Thing, int>(realmData.FromRealmThing(r.Key), r.Value)).ToList();

            string thingLabels = string.Join("\n", things.Select((t) => t.Value.ToString() + "x " + t.Key.LabelCapNoCount).ToArray());

            // We ask for confirmation
            Dialog_GeneralChoice choiceDialog = new Dialog_GeneralChoice(new DialogChoiceConfig
            {
                text          = sender.name + " wants to ship you:\n" + thingLabels,
                buttonAText   = "Accept",
                buttonAAction = () =>
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.ACCEPTED
                    });
                },
                buttonBText   = "Refuse",
                buttonBAction = () =>
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.DECLINED
                    });
                }
            });

            Find.WindowStack.Add(choiceDialog);
        }
Exemplo n.º 3
0
        // Token: 0x06000067 RID: 103 RVA: 0x000040D8 File Offset: 0x000022D8
        public override void OnStartReceiver(RealmData realmData)
        {
            if (!receiver.preferences.receiveItems)
            {
                realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                {
                    transaction = this,
                    response    = TransactionResponse.DECLINED
                });
                return;
            }

            var source = realmThings.Select(delegate(KeyValuePair <RealmThing, int> r)
            {
                var realmData2   = realmData;
                var keyValuePair = r;
                var key          = realmData2.FromRealmThing(keyValuePair.Key);
                keyValuePair     = r;
                return(new KeyValuePair <Thing, int>(key, keyValuePair.Value));
            }).ToList();
            var str = string.Join("\n", source.Select(delegate(KeyValuePair <Thing, int> t)
            {
                var keyValuePair = t;
                var str2         = keyValuePair.Value.ToString();
                var str3         = "x ";
                keyValuePair     = t;
                return(str2 + str3 + keyValuePair.Key.LabelCapNoCount);
            }).ToArray());
            var window = new Dialog_GeneralChoice(new DialogChoiceConfig
            {
                text          = sender.name + " wants to ship you:\n" + str,
                buttonAText   = "Accept",
                buttonAAction = delegate
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.ACCEPTED
                    });
                },
                buttonBText   = "Refuse",
                buttonBAction = delegate
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.DECLINED
                    });
                }
            });

            Find.WindowStack.Add(window);
        }
Exemplo n.º 4
0
        public override void OnStartReceiver(RealmData realmData)
        {
            // Double check to ensure it wasn't bypassed by the sender
            if (!receiver.preferences.receiveColonists)
            {
                realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                {
                    transaction = this,
                    response    = TransactionResponse.DECLINED
                });
                return;
            }

            // We ask for confirmation

            Dialog_GeneralChoice choiceDialog = new Dialog_GeneralChoice(new DialogChoiceConfig
            {
                text          = sender.name + " wants to send you a colonist",
                buttonAText   = "Accept",
                buttonAAction = () =>
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.ACCEPTED
                    });
                },
                buttonBText   = "Refuse",
                buttonBAction = () =>
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.DECLINED
                    });
                }
            });

            Find.WindowStack.Add(choiceDialog);
        }
Exemplo n.º 5
0
        // Token: 0x0600005B RID: 91 RVA: 0x00003C0C File Offset: 0x00001E0C
        public override void OnStartReceiver(RealmData realmData)
        {
            if (!receiver.preferences.receiveColonists)
            {
                realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                {
                    transaction = this,
                    response    = TransactionResponse.DECLINED
                });
                return;
            }

            var window = new Dialog_GeneralChoice(new DialogChoiceConfig
            {
                text =
                    $"{sender.name} wants to send you a {Enum.GetName(typeof(TransactionType), transaction)?.ToLower()}",
                buttonAText   = "Accept",
                buttonAAction = delegate
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.ACCEPTED
                    });
                },
                buttonBText   = "Refuse",
                buttonBAction = delegate
                {
                    realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                    {
                        transaction = this,
                        response    = TransactionResponse.DECLINED
                    });
                }
            });

            Find.WindowStack.Add(window);
        }
Exemplo n.º 6
0
        public override void OnEndReceiver(RealmData realmData)
        {
            // Double check to ensure it wasn't bypassed by the sender
            if (!receiver.preferences.receiveAnimals)
            {
                realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                {
                    transaction = this,
                    response    = TransactionResponse.DECLINED
                });
                return;
            }

            // Nothing
            if (state == TransactionResponse.ACCEPTED)
            {
                Pawn pawn = realmAnimal.FromRealmAnimal(realmData);

                // We drop it
                IntVec3 position = DropCellFinder.RandomDropSpot(Find.VisibleMap);
                DropPodUtility.MakeDropPodAt(position, Find.VisibleMap, new ActiveDropPodInfo
                {
                    SingleContainedThing = pawn,
                    openDelay            = 110,
                    leaveSlag            = false
                });

                Find.LetterStack.ReceiveLetter(
                    "Animal pod",
                    "An animal was sent to you by " + sender.name,
                    LetterDefOf.PositiveEvent,
                    new RimWorld.Planet.GlobalTargetInfo(position, Find.VisibleMap)
                    );
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name, MessageTypeDefOf.RejectInput);
            }
            else if (state == TransactionResponse.TOOFAST)
            {
                // This should never happen as the server rejects intercepted packets.
            }
        }