示例#1
0
 void addOrUpdateEntry(playerEntry entry)
 {
     foreach (playerEntry e in entries)
     {
         if (e.Name == entry.Name)
         {
             e.update(entry);
             return;
         }
     }
     entries.Add(entry);
 }
示例#2
0
 private void Multiplayer_ModMessageReceived(object sender, ModMessageReceivedEventArgs e)
 {
     if (e.FromModID == ModManifest.UniqueID)
     {
         playerEntry receivedEntry = e.ReadAs <playerEntry>();
         if (Game1.IsMasterGame)
         {
             // master: received entry request from slave
             if (e.Type == "TCDentryRequest")
             {
                 Helper.Multiplayer.SendMessage(getEntryWithName(receivedEntry.Name), "TCDentry", new[] { ModManifest.UniqueID });
             }
             // master: received rules request from slave
             if (e.Type == "TCDruleRequest")
             {
                 Helper.Multiplayer.SendMessage(rules, "TCDrules", new[] { ModManifest.UniqueID });
             }
             // master: received entry set request from slave
             if (e.Type == "TCDentrySet")
             {
                 addOrUpdateEntry(receivedEntry);
             }
         }
         else
         {
             // slave: received entry from master
             if (e.Type == "TCDentry" && receivedEntry.Name == Game1.player.Name)
             {
                 currentEntry  = receivedEntry;
                 entryReceived = true;
                 if (currentEntry.emptyPos)
                 {
                     currentEntry.customPos = null;
                 }
                 if (waitingToWarp)
                 {
                     waitingToWarp = false;
                 }
                 Warp();
             }
             // slave: received rules from master
             if (e.Type == "TCDrules")
             {
                 rules = e.ReadAs <TCDRules>();
             }
         }
     }
 }
示例#3
0
 private void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e)
 {
     if (Game1.IsMasterGame)
     {
         entries = Helper.Data.ReadSaveData <List <playerEntry> >("TCDplayerEntries");
         if (entries == null)
         {
             entries = new List <playerEntry>();
         }
         currentEntry = getEntryWithName(Game1.player.Name);
     }
     else
     {
         entryReceived = false;
         requestRules();
     }
 }
示例#4
0
 public void update(playerEntry updateFrom)
 {
     customPos = updateFrom.customPos;
     emptyPos  = updateFrom.emptyPos;
 }