Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

     private void LeftRoomCleanup()
     {
         bool wasInRoom = mRoomToGetInto != null;
         // when leaving a room, we clean up depending on that room's settings.
         bool autoCleanupSettingOfRoom = (this.mRoomToGetInto != null) ? this.mRoomToGetInto.autoCleanUp : PhotonNetwork.autoCleanUpPlayerObjects;

         this.hasSwitchedMC = false;
         this.mRoomToGetInto = null;
         this.mActors = new Dictionary();
         this.mPlayerListCopy = new PhotonPlayer[0];
         this.mOtherPlayerListCopy = new PhotonPlayer[0];
         this.mMasterClient = null;
         this.allowedReceivingGroups = new HashSet();
         this.blockSendingGroups = new HashSet();
         this.mGameList = new Dictionary();
         this.mGameListCopy = new RoomInfo[0];
         this.isFetchingFriends = false;

         this.ChangeLocalID(-1);

         // Cleanup all network objects (all spawned PhotonViews, local and remote)
         if (autoCleanupSettingOfRoom)
         {
             this.LocalCleanupAnythingInstantiated(true);
             PhotonNetwork.manuallyAllocatedViewIds = new List(); // filled and easier to replace completely
         }

         if (wasInRoom)
         {
             SendMonoMessage(PhotonNetworkingMessage.OnLeftRoom);
         }
     }