Beispiel #1
0
        public override void OnEndSender(RealmData realmData)
        {
            // Double check to ensure it wasn't bypassed by the sender
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                pawn.Destroy();
                Messages.Message(receiver.name + " accepted your items", MessageTypeDefOf.NeutralEvent);
            }
            else if (state == TransactionResponse.DECLINED)
            {
                Messages.Message(receiver.name + " declined your items", MessageTypeDefOf.RejectInput);
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + receiver.name, MessageTypeDefOf.RejectInput);
            }
            else if (state == TransactionResponse.TOOFAST)
            {
                Messages.Message("Transaction with " + receiver.name + " was declined by the server. Are you sending colonists too quickly?", MessageTypeDefOf.RejectInput);
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        // Token: 0x0600005C RID: 92 RVA: 0x00003CE8 File Offset: 0x00001EE8
        public override void OnEndReceiver(RealmData realmData)
        {
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                var singleContainedThing = realmPawn.FromRealmPawn(realmData);
                var intVec = DropCellFinder.RandomDropSpot(Find.CurrentMap);
                DropPodUtility.MakeDropPodAt(intVec, Find.CurrentMap, new ActiveDropPodInfo
                {
                    SingleContainedThing = singleContainedThing,
                    openDelay            = 110,
                    leaveSlag            = false
                });
                Find.LetterStack.ReceiveLetter(
                    $"{Enum.GetName(typeof(TransactionType), transaction)} pod",
                    $"A {Enum.GetName(typeof(TransactionType), transaction)?.ToLower()} was sent to you by {sender.name}",
                    LetterDefOf.PositiveEvent, new GlobalTargetInfo(intVec, Find.CurrentMap));
                return;
            }

            if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name,
                                 MessageTypeDefOf.RejectInput);
                return;
            }

            var unused = state;
        }
        public override void OnEndReceiver(RealmData realmData)
        {
            // Nothing
            if (state == TransactionResponse.ACCEPTED)
            {
                Pawn pawn = realmPawn.FromRealmPawn(realmData);

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

                Find.LetterStack.ReceiveLetter(
                    "Colonist pod",
                    "A colonist was sent to you by " + sender.name,
                    LetterType.Good,
                    position
                    );
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name, MessageSound.RejectInput);
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public override void OnEndReceiver(RealmData realmData)
        {
            // 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);
            }
        }
Beispiel #7
0
        public override void OnEndSender(RealmData realmData)
        {
            // Double check to ensure it wasn't bypassed by the sender
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                foreach (KeyValuePair <List <Thing>, int> entry in things)
                {
                    int leftToDestroy = entry.Value;
                    foreach (Thing thing in entry.Key)
                    {
                        if (thing.Destroyed)
                        {
                            continue;
                        }

                        int toRemove = Math.Min(leftToDestroy, thing.stackCount);

                        if (toRemove == thing.stackCount)
                        {
                            thing.Destroy();
                        }
                        else
                        {
                            thing.stackCount -= toRemove;
                        }

                        leftToDestroy -= toRemove;
                    }

                    // This can happen if during the transaction, pawns have used some of the resources
                    // that we thought were available.
                    // This could open up cheating, but since there's no way to prevent that, we let it go.
                    if (leftToDestroy > 0)
                    {
                        Log.Warning("Trying to destroy " + entry.Key[0].LabelShort + " but couldn't destroy the " + leftToDestroy + " remaining");
                    }
                }

                Messages.Message(receiver.name + " accepted your items", MessageTypeDefOf.NeutralEvent);
            }
            else if (state == TransactionResponse.DECLINED)
            {
                Messages.Message(receiver.name + " declined your items", MessageTypeDefOf.RejectInput);
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + receiver.name, MessageTypeDefOf.RejectInput);
            }
            else if (state == TransactionResponse.TOOFAST)
            {
                Messages.Message("Transaction with " + receiver.name + " was declined by the server. Are you sending items too quickly?", MessageTypeDefOf.RejectInput);
            }
        }
Beispiel #8
0
        public override void Apply(User user, RealmData realmData)
        {
            realmData.transactions.Add(transaction);
            user.lastTransactionId = transaction.id;

            realmData.NotifyPacket(transaction.receiver, new ReceiveTransactionPacket {
                transaction = transaction
            });
        }
Beispiel #9
0
        internal void OnDeserializedCallback(StreamingContext c)
        {
            RealmContext realmContext = (RealmContext)c.Context;
            RealmData    realmData    = realmContext.realmData;

            if (realmData != null)
            {
                sender   = ID.Find(realmData.users, senderId);
                receiver = ID.Find(realmData.users, receiverId);
            }
        }
Beispiel #10
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);
        }
 public override void Apply(User user, RealmData realmData)
 {
     transaction.state = response;
     if (user == transaction.sender && toSender)
     {
         transaction.OnEndSender(realmData);
     }
     else if (user == transaction.receiver && !toSender)
     {
         transaction.OnEndReceiver(realmData);
     }
 }
Beispiel #12
0
        // Token: 0x0600006A RID: 106 RVA: 0x00004534 File Offset: 0x00002734
        public override void Apply(User user, RealmData realmData)
        {
            if (realmData.TryFindTransaction(transaction.id, transaction.sender.id) == null)
            {
                realmData.transactions.Add(transaction);
            }

            if (user == transaction.receiver)
            {
                transaction.OnStartReceiver(realmData);
            }
        }
        public override void Apply(User user, RealmData realmData)
        {
            // If the transaction is with itself, the transaction may already be there
            if (realmData.TryFindTransaction(transaction.id, transaction.sender.id) == null)
            {
                realmData.transactions.Add(transaction);
            }

            if (user == transaction.receiver)
            {
                transaction.OnStartReceiver(realmData);
            }
        }
Beispiel #14
0
        public void Start(IPAddress ipAddress, int port)
        {
            this.server = new Server(ipAddress, port);
            this.server.Start();
            Console.WriteLine("Launching server for " + ipAddress + " on port " + port);

            this.server.Connection    += this.ConnectionCallback;
            this.server.Message       += this.MessageCallback;
            this.server.Disconnection += this.DisconnectionCallback;

            this.realmData = new RealmData();
            this.realmData.PacketToClient += this.RealmPacketCallback;
        }
Beispiel #15
0
        public override void OnEndReceiver(RealmData realmData)
        {
            // Double check to ensure it wasn't bypassed by the sender
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                // We spawn the new items !
                List <Thing> thingsToSpawn = new List <Thing>();
                foreach (KeyValuePair <RealmThing, int> entry in realmThings)
                {
                    RealmThing realmThing  = entry.Key;
                    Thing      thing       = realmData.FromRealmThing(realmThing);
                    int        leftToSpawn = entry.Value;
                    // We make new things until we create everything
                    // For example, if 180 granites blocks are sent (can be stacked by 75), we
                    // will create 3 Thing (2 full and 1 semi-full)
                    while (leftToSpawn > 0)
                    {
                        realmThing.stackCount = Math.Min(leftToSpawn, thing.def.stackLimit);

                        thingsToSpawn.Add(realmData.FromRealmThing(realmThing));

                        leftToSpawn -= realmThing.stackCount;
                    }
                }

                // We spawn the said item
                IntVec3 position = DropCellFinder.RandomDropSpot(Find.VisibleMap);
                DropPodUtility.DropThingsNear(position, Find.VisibleMap, thingsToSpawn);

                Find.LetterStack.ReceiveLetter(
                    "Ship pod",
                    "A pod was sent from " + sender.name + " containing items",
                    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
            }
        }
Beispiel #16
0
 public override void OnEndSender(RealmData realmData)
 {
     if (state == TransactionResponse.ACCEPTED)
     {
         pawn.Destroy();
         Messages.Message(receiver.name + " accepted your items", MessageTypeDefOf.NeutralEvent);
     }
     else if (state == TransactionResponse.DECLINED)
     {
         Messages.Message(receiver.name + " declined your items", MessageTypeDefOf.RejectInput);
     }
     else if (state == TransactionResponse.INTERRUPTED)
     {
         Messages.Message("Unexpected interruption during item transaction with " + receiver.name, MessageTypeDefOf.RejectInput);
     }
 }
Beispiel #17
0
        public override void Apply(User user, RealmData realmData)
        {
            if (transaction.state != TransactionResponse.WAITING)
            {
                return;
            }
            transaction.state = response;

            // We signal to the 2 users that the transaction is now confirmed
            realmData.NotifyPacket(transaction.sender, new ConfirmTransactionPacket {
                transaction = transaction, response = response, toSender = true
            });
            realmData.NotifyPacket(transaction.receiver, new ConfirmTransactionPacket {
                transaction = transaction, response = response
            });
        }
Beispiel #18
0
        public void Start(IPAddress ipAddress, int port, LogLevel logLevel)
        {
            this.logLevel = logLevel;

            this.server = new Server(ipAddress, port);
            this.server.Start();
            Log(LogLevel.INFO, string.Format("Server launched on port {0}", port));

            this.server.Connection    += this.ConnectionCallback;
            this.server.Message       += this.MessageCallback;
            this.server.Disconnection += this.DisconnectionCallback;

            this.realmData = new RealmData();
            this.realmData.PacketToClient += this.RealmPacketCallback;
            this.realmData.Log            += Log;
        }
Beispiel #19
0
        public void Start(IPAddress ipAddress, int port, LogLevel logLevel)
        {
            this.logLevel = logLevel;

            server = new Server(ipAddress, port);
            server.Start();
            Log(LogLevel.INFO, $"Server launched on port {port}");

            server.Connection    += ConnectionCallback;
            server.Message       += MessageCallback;
            server.Disconnection += DisconnectionCallback;

            realmData = new RealmData();
            realmData.PacketToClient += RealmPacketCallback;
            realmData.Log            += Log;
        }
Beispiel #20
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.
            }
        }
        // Token: 0x0600005E RID: 94 RVA: 0x00003EF8 File Offset: 0x000020F8
        public override void Apply(User user, RealmData realmData)
        {
            if (transaction.receiver != user || transaction.state != TransactionResponse.WAITING)
            {
                return;
            }

            transaction.state = response;
            realmData.NotifyPacket(transaction.sender, new ConfirmTransactionPacket
            {
                transaction = transaction,
                response    = response,
                toSender    = true
            });
            realmData.NotifyPacket(transaction.receiver, new ConfirmTransactionPacket
            {
                transaction = transaction,
                response    = response
            });
        }
Beispiel #22
0
        public override void OnEndReceiver(RealmData realmData)
        {
            if (state == TransactionResponse.ACCEPTED)
            {
                // We spawn the new items !
                List <Thing> thingsToSpawn = new List <Thing>();
                foreach (KeyValuePair <RealmThing, int> entry in realmThings)
                {
                    RealmThing realmThing  = entry.Key;
                    Thing      thing       = realmData.FromRealmThing(realmThing);
                    int        leftToSpawn = entry.Value;
                    // We make new things until we create everything
                    // For example, if 180 granites blocks are sent (can be stacked by 75), we
                    // will create 3 Thing (2 full and 1 semi-full)
                    while (leftToSpawn > 0)
                    {
                        realmThing.stackCount = Math.Min(leftToSpawn, thing.def.stackLimit);

                        thingsToSpawn.Add(realmData.FromRealmThing(realmThing));

                        leftToSpawn -= realmThing.stackCount;
                    }
                }

                // We spawn the said item
                IntVec3 position = DropCellFinder.RandomDropSpot();
                DropPodUtility.DropThingsNear(position, thingsToSpawn);

                Find.LetterStack.ReceiveLetter(
                    "Ship pod",
                    "A pod was sent from " + sender.name + " containing items",
                    LetterType.Good,
                    position
                    );
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name, MessageSound.RejectInput);
            }
        }
Beispiel #23
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);
        }
Beispiel #24
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);
        }
Beispiel #25
0
        // Token: 0x06000068 RID: 104 RVA: 0x000041E8 File Offset: 0x000023E8
        public override void OnEndReceiver(RealmData realmData)
        {
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                var list = new List <Thing>();
                foreach (var keyValuePair in realmThings)
                {
                    var key   = keyValuePair.Key;
                    var thing = realmData.FromRealmThing(key);
                    for (var i = keyValuePair.Value; i > 0; i -= key.stackCount)
                    {
                        key.stackCount = Math.Min(i, thing.def.stackLimit);
                        list.Add(realmData.FromRealmThing(key));
                    }
                }

                var intVec = DropCellFinder.RandomDropSpot(Find.CurrentMap);
                DropPodUtility.DropThingsNear(intVec, Find.CurrentMap, list);
                Find.LetterStack.ReceiveLetter("Ship pod", "A pod was sent from " + sender.name + " containing items",
                                               LetterDefOf.PositiveEvent, new GlobalTargetInfo(intVec, Find.CurrentMap));
                return;
            }

            if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name,
                                 MessageTypeDefOf.RejectInput);
                return;
            }

            var unused = state;
        }
Beispiel #26
0
        // Token: 0x0600005D RID: 93 RVA: 0x00003E08 File Offset: 0x00002008
        public override void OnEndSender(RealmData realmData)
        {
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                pawn.DeSpawn();
                Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.KeepForever);
                Messages.Message(receiver.name + " accepted your items", MessageTypeDefOf.NeutralEvent);
                return;
            }

            if (state == TransactionResponse.DECLINED)
            {
                Messages.Message(receiver.name + " declined your items", MessageTypeDefOf.RejectInput);
                return;
            }

            if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + receiver.name,
                                 MessageTypeDefOf.RejectInput);
                return;
            }

            if (state == TransactionResponse.TOOFAST)
            {
                Messages.Message(
                    "Transaction with " + receiver.name +
                    " was declined by the server. Are you sending colonists too quickly?",
                    MessageTypeDefOf.RejectInput);
            }
        }
Beispiel #27
0
 // Token: 0x0600006F RID: 111
 public abstract void OnStartReceiver(RealmData realmData);
Beispiel #28
0
 // Token: 0x06000070 RID: 112
 public abstract void OnEndReceiver(RealmData realmData);
Beispiel #29
0
        // Token: 0x06000069 RID: 105 RVA: 0x00004348 File Offset: 0x00002548
        public override void OnEndSender(RealmData realmData)
        {
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                foreach (var keyValuePair in things)
                {
                    var num = keyValuePair.Value;
                    foreach (var thing in keyValuePair.Key)
                    {
                        if (thing.Destroyed)
                        {
                            continue;
                        }

                        var num2 = Math.Min(num, thing.stackCount);
                        if (num2 == thing.stackCount)
                        {
                            thing.Destroy();
                        }
                        else
                        {
                            thing.stackCount -= num2;
                        }

                        num -= num2;
                    }

                    if (num > 0)
                    {
                        Log.Warning(
                            string.Concat("Trying to destroy ", keyValuePair.Key[0].LabelShort,
                                          " but couldn't destroy the ", num, " remaining"));
                    }
                }

                Messages.Message(receiver.name + " accepted your items", MessageTypeDefOf.NeutralEvent);
                return;
            }

            if (state == TransactionResponse.DECLINED)
            {
                Messages.Message(receiver.name + " declined your items", MessageTypeDefOf.RejectInput);
                return;
            }

            if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + receiver.name,
                                 MessageTypeDefOf.RejectInput);
                return;
            }

            if (state == TransactionResponse.TOOFAST)
            {
                Messages.Message(
                    "Transaction with " + receiver.name +
                    " was declined by the server. Are you sending items too quickly?", MessageTypeDefOf.RejectInput);
            }
        }
Beispiel #30
0
 // Token: 0x06000071 RID: 113
 public abstract void OnEndSender(RealmData realmData);