The gamemode system decides what objectives are given to player and which of them are antagonists.
Gamemodes are what allow a round to begin and end, they set up the objectives that need to be completed by either antagonists or crew members, when these objectives are met the round ends, or alternatively, the shuttle can be called to end it.
They are separated into 2 features, Modes and Objectives.
Modes are what decide how the round is gonna end, how many traitors the round will have and what objectives there will be.
Objectives are things antagonists or crew members must achieve during the round, they are given either to individual players or groups of players, with the objectives being shared or not between them, meaning either an objective can be completed by one player and it's completed by everyone, or it can be solely completed by a single player, making other players fail the objective.
This page describes how to add a new objective that can then be added to a game mode.
To add a new gameobject you have to first create a new script in Assets > Scripts > SS3D > Systems > Gamemodes > Objectives.
You may copy another objective that is already done to make your life easier, but the rules an objective has to follow are:
It has to be a child of the GamemodeObjective class.
It has to call the Succeed method to be completeable.
It has to have a CreateAssetMenu property above the class.
It has to be in the SS3D.Systems.Gamemodes.Objectives namespace.
Let's say you wanted to create an objective to picking up a BikeHorn
First you would create a new script that inherits GamemodeObjective, let's call it PickupBikehornObjective.
You would then have to set up the CreateAssetMenu property since the GamemodeObjective class is an ScriptableObject. you should also put it under the SS3D.Systems.Gamemodes.Objectives namespace.
You would then end up with this:
We now add the pickedUpItemId and pickedUpPlayerCkey private properties so we can hook them to the ItemPickedUpEvent and check if the picked up item was a bikehorn.
We now have to add an event listener to the ItemPickedUpEvent, we do that in the AddEventListeners method, we will then hook it to a HandleItemPickedUpEvent method.
We usually call the FinalizeObjective to conclude an objective, but you could call either Succeed or Fail from any method, but following our practices we will do the check inside FinalizeObjective anyway.
Now you just have to create the ScriptableObject, for that we go to the Assets > Content > Data > Gamemode > Objectives folder, right-click and go Create > Gamemode > Objectives > GetBikeHorn.
Now you just have to set up the properties for the objective as follows:
Title: What is the title of the objective that will appear in the UI.
Collaboration Type: if the objective is assigned to a single individual, multiple or if it's a competitve objective, meaning a single players can complete it.
Alignment Requirement: If Traitors, Crew members, or both can get this objective.
Min Assignees: Minimun number of players that will be assigned this objective.
Max Assignees: Maximum number of players that can be assigned this objective.
Done, now you have succesfully added a new objective to the game!
This page describes how to add a new game mode with it's set of objectives
Creating a new game mode is generally simpler than adding an objective, you just have to create a new class inheriting the Gamemode class with a CreateAssetMenu property and... that's it! you don't even have to add any code to it unless you want to change something about the internal working of gamemodes, which is beyond the scope of this guide.
Let's recreate the Nuke gamemode as an example, first go to Assets > Scripts > SS3D > Systems > Gamemodes > Modes and create the new class there, we'll call it NukeGamemode.
Now we just have to create the ScriptableObjects for the game mode, for that we go to Assets > Content > Data > Gamemode, we'll need multiple scriptable objects for each game mode so it might be a good idea to make a new folder for each game mode, so we'll create a Nuke folder for ours.
First we need to create a GamemodeObjectiveCollectionEntry, which is used to control how the objectives will be distributed to players, to create one we right-click and go Create > Gamemode > GamemodeObjectiveCollectionEntry, we then have to set it's properties, we do it as follows:
Gamemode Objective: the actual objective's ScriptableObject.
Assignment Probability: the probability of the objective being assigned to a player.
Remaining Assignments: how many objectives of this type can be assigned.
After that we need to create a GammodeObjectiveCollection which is a collection of objective entries that a game mode can assign to players, to create one we right-click and go Create > Gamemode > GamemodeObjectiveCollection, we then just have to put all of the objective entries into the collection's list.
We now have everything set up to create our actual gamemode's ScriptableObject, for that we right-click and go Create > Gamemode > Modes > NukeGamemode (the name of your gamemode), we then just have to set up it's name and it's GamemodeObjectiveCollection.
Done, the game mode is completed, to test it we just have to go to the GamemodeSystem game object in the Lobby screen and set the round's game mode to ours.