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: public bool OpJoinRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby, bool createIfNotExists)
{
bool onGameServer = this.server == ServerConnection.GameServer;
if (!onGameServer)
{
// roomOptions and typedLobby will be null, unless createIfNotExists is true
this.mRoomOptionsForCreate = roomOptions;
this.mRoomToGetInto = new Room(roomName, roomOptions);
this.mRoomToEnterLobby = null;
if (createIfNotExists)
{
this.mRoomToEnterLobby = typedLobby ?? ((this.insideLobby) ? this.lobby : null); // use given lobby, or active lobby (if any active) or none
}
}
this.mLastJoinType = (createIfNotExists) ? JoinType.JoinOrCreateOnDemand : JoinType.JoinGame;
return base.OpJoinRoom(roomName, roomOptions, this.mRoomToEnterLobby, createIfNotExists, this.GetLocalActorProperties(), onGameServer);
}
{
bool onGameServer = this.server == ServerConnection.GameServer;
if (!onGameServer)
{
// roomOptions and typedLobby will be null, unless createIfNotExists is true
this.mRoomOptionsForCreate = roomOptions;
this.mRoomToGetInto = new Room(roomName, roomOptions);
this.mRoomToEnterLobby = null;
if (createIfNotExists)
{
this.mRoomToEnterLobby = typedLobby ?? ((this.insideLobby) ? this.lobby : null); // use given lobby, or active lobby (if any active) or none
}
}
this.mLastJoinType = (createIfNotExists) ? JoinType.JoinOrCreateOnDemand : JoinType.JoinGame;
return base.OpJoinRoom(roomName, roomOptions, this.mRoomToEnterLobby, createIfNotExists, this.GetLocalActorProperties(), onGameServer);
}