Space Plunder
Loading...
Searching...
No Matches
MultiplayerGameMode.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "GameFramework/GameMode.h"
8#include "GameMode/OnlineGameMode.h"
11#include "MultiplayerGameMode.generated.h"
12
13class APlayerStart;
14
15UCLASS()
16class CUSTOMALS_API AMultiplayerGameMode : public AOnlineGameMode//, public IMultiplayerGM
17{
18 GENERATED_BODY()
19
20public:
21
23
24 virtual void BeginPlay() override;
25
26 // - When Player Connects //
27 // virtual void PostLogin(APlayerController* NewPlayer) override;
28 // //- When Player Disconnects //
29 // virtual void Logout(AController* Exiting) override;
30 // //- Connects from one controller to another (eg. from one level to another) //
31 // virtual void SwapPlayerControllers(APlayerController* OldPC, APlayerController* NewPC) override;
32
33 // virtual void RegisterPlayer(APlayerController* NewPlayer);
34
35 //- All Player Controllers //
36 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Players")
37 // TArray<APlayerController*> AllPlayerControllers;
38 //@TODO for multiple teams
39 // TMap<int32, TArray<APlayerController*>> TeamPlayerControllers;
40 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Players")
41 // TArray<AActor*> PlayerStarts;
42
43 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Players")
44 // TArray<AActor*> AIPlayerStarts;
45 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Game State")
46 // int32 NumberOfPlayersToStart = 4;
47 // UFUNCTION(BlueprintPure, Category="Players")
48 // int32 GetTotalNumberOfControllers() const;
49
50
51 //- Runs at the start of each Match to get all player starts //
52 // void GetAllPlayerStarts();
53 // UFUNCTION(BlueprintPure, BlueprintCallable, Category="Space GameMode")
54 // FTransform FindRandomPlayerStart() const;
55 // UFUNCTION(BlueprintPure, BlueprintCallable, Category="Space GameMode")
56 // FTransform FindRandomAIPlayerStart() const;
57 // UFUNCTION(BlueprintPure, BlueprintCallable, Category="Space GameMode")
58 // FTransform FindTeamPlayerStart(int32 TeamID);
59
60 //- Maps a team ID to a list of their player starts
61 TMap<int32, TArray<APlayerStart*>> TeamStarts;
62
63
64 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Players")
65 // TMap<int32, int32> LastUsedPlayerStart;
66
68 // UFUNCTION(BlueprintCallable, Category="Space GameMode")
69 // virtual void SpawnPlayer(APlayerController* PlayerController) override;
70 // UFUNCTION(BlueprintCallable, Category="Online GM")
71 // virtual EMultiplayerMode GetMultiplayerGameMode() const override {return MultiplayerMode;};
72 UFUNCTION(BlueprintCallable, Category="Online GM")
73 virtual int32 GetCurrentRound() const {return Round;};
74
75
76 // UFUNCTION(BlueprintCallable, Category="Space GameMode")
77 // virtual void AddPlayerToTeam(APlayerController* PlayerController);
78
79 virtual void SpawnedPlayerDeath(FPlayerDeath& PlayerDeath, APawn* PawnThatDied) override;
80 virtual void SpawnedAIDeath(FPlayerDeath& PlayerDeath, APawn* PawnThatDied) override;
81
82 //- Multiplayer GM Interface //
83 // virtual void PlayerDeath(FPlayerDeath& PlayerDeath) override;
84 // virtual void AIDeath(FPlayerDeath& PlayerDeath) override;
85
86
87 void AddDeathToKillFeed(const FPlayerDeath& PlayerDeath, const bool bPlayerDeath = true);
88
89
91 // UFUNCTION(BlueprintCallable, Category="Online GM")
92 // void SetupScore();
93 // UFUNCTION(BlueprintCallable, Category="Online GM")
94 // void UpdateScore();
95 // UFUNCTION(BlueprintCallable, Category="Online GM")
96 // void UpdateMatchState();
97
98 // UFUNCTION(BlueprintCallable, Category="Online GM")
99 // virtual void UpdatePlayerList();
100
101protected:
102
104 //- Game State //
105 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Game State")
106 class AMultiplayerGameState* MultiplayerGameState = nullptr;
107
108
109 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
110 int32 GoalScore = 1;
111 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
112 int32 PlayerKilledScore = 2;
113 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
114 int32 TeamKillScore =-1;
115 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
116 int32 AIKilledScore = 1;
117 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
118 int32 ObjectiveScore = 5;
119 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
120 float PlayerKilledXP = 100.0f;
121 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
122 float TeamKilledXP = -100.0f;
123 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
124 float SelfKilledXP = -25.0f;
125 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Score")
126 float AIKilledXP = 25.0f;
127
128 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules")
129 bool bEndOnTeamReachingGoal = true;
130 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Online GM|Rules")
131 bool bPlayerLifeLimit = false;
132 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Online GM|Rules")
133 int32 PlayerLifePool = 10;
134
135
136 //- Rounds //
137 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules|Rounds")
138 bool bRoundBased = false;
139 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules|Rounds")
140 bool bRoundsTimed = false;
141 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules|Rounds")
142 bool bRoundLimit = false;
143 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Online GM|Rules|Rounds")
144 int32 Round = 0;
145 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules|Rounds")
146 int32 RoundTime = 20;
147 int32 RoundTimeMax = 10;
148
149 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules|Rounds")
150 int32 RoundGoalScore = 1;
151 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Online GM|Rules|Rounds")
152 int32 MaxRounds = 10;
153 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Online GM|Rules|Rounds")
154 float TimeTillNextRound = 4.0f;
155 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Online GM|Rules|Rounds")
156 bool bEndRoundOnTeamReachingGoal = false;
157 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Online GM|Rules|Rounds")
158 // bool bEndRoundOnTeamFail = false;
159
160
161
162 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules")
163 bool bTeamKillPenalty = true;
164 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules")
165 int32 TeamKillPenaltyTime = 3;
166 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules")
167 bool bSelfKillPenalty = true;
168 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Rules")
169 int32 SelfKillPenaltyTime = 3;
170
171 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Feed")
172 bool bShowDeathsInFeed = true;
173 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Feed")
174 bool bShowPlayerDeathsInFeed = true;
175 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Feed")
176 bool bShowAIDeathInFeed = true;
177
178 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Match Start")
179 // int32 RespawnTime = 3;
180 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Match Start")
181 // int32 SelfDeathRespawnTimeMultiplier = 2;
182 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Match Start")
183 // int32 TeamKillDeathRespawnTimeMultiplier = 3;
184
185 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Match Start")
186 // bool bDisableStartTimers = false;
187 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Match Start")
188 // int32 PreMatchWaitTime = 5;
189 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Online GM|Match Start")
190 // int32 ReadyMatchWaitTime = 10;
191
192
193 //- Match States //
194 virtual void PreMatch() override;
195 virtual void ReadyMatch() override;
196 virtual void StartMatch() override;
197 virtual void EndMatch() override;
198 virtual void MatchCountdown() override;
199
200 //- Round States //
201 virtual void StartRound();
202 virtual void RoundCountdown();
203 virtual void EndRound();
204
205 virtual void UpdateGameState() override;
206
207
208 UFUNCTION(BlueprintImplementableEvent, Category="Online GM|Multiplayer")
209 void OnStartRound();
210 UFUNCTION(BlueprintImplementableEvent, Category="Online GM|Multiplayer")
211 void OnRoundCountdown();
212 UFUNCTION(BlueprintImplementableEvent, Category="Online GM|Multiplayer")
213 void OnEndRound();
214
215 UFUNCTION(BlueprintCallable, Category="Online GM|Multiplayer")
216 virtual void SetEndRoundCondition(){bEndRoundCondition = true;};
217 UFUNCTION(BlueprintCallable, Category="Online GM|Multiplayer")
218 virtual void ResetEndRoundCondition(){bEndRoundCondition = false;};
219
220
221
222 virtual void AddScoreToTeam(const int32 TeamID, const int32 ScoreToAdd);
223
224 virtual void AddScoreToPlayer(APlayerState* Player, const bool bTeamKill = false, const bool bSelfKill = false);
225 virtual void AddDeathToPlayer(APlayerState* Player, const bool bSelfKill = false);
226
227private:
228 UPROPERTY(VisibleAnywhere, Category="Online GM|State|Multiplayer")
229 FMatchState RoundMatchState;
230
231
232
233 FTimerHandle RoundTimerHandle;
234 FTimerHandle NextRoundTimerHandle;
235
236 // FTimerHandle SetupScoreTimerHandle;
237
238 bool bEndRoundCondition = false;
239};
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition MultiplayerGameMode.h:17
TMap< int32, TArray< APlayerStart * > > TeamStarts
Definition MultiplayerGameMode.h:61
Definition MultiplayerGameState.h:20
Definition OnlineGameMode.h:21
Definition BaseData.h:1077
Definition BaseData.h:613