24 [
Attribute(
category:
"Respawn Handler",
desc:
"If enabled, previous controlled entity prior to respawn will be destroyed (killed).")]
27 [
Attribute(
category:
"Respawn Handler",
desc:
"If enabled, previous controlled entity prior to respawn will be destroyed (killed).")]
35 super.OnPostInit(owner);
39 Debug.Error(
string.Format(
"%1 could not find %2! (should be a child of)", Type().ToString(), SCR_RespawnSystemComponent));
48 int playerId = requestComponent.GetPlayerController().GetPlayerId();
49 #ifdef _ENABLE_RESPAWN_LOGS
50 Print(
string.Format(
"%1::CanHandleRequest_S(playerId: %2, data: %3)", Type().ToString(),
52 data), LogLevel.NORMAL);
84 int playerId = requestComponent.GetPlayerController().GetPlayerId();
85 #ifdef _ENABLE_RESPAWN_LOGS
86 Print(
string.Format(
"%1::HandleRequest_S(playerId: %2, data: %3)", Type().ToString(),
88 data), LogLevel.NORMAL);
98 Debug.BeginTimeMeasure();
105 Debug.Error(
string.Format(
"Bad %1 implementation! Result is %2, but entity is %3!",
106 Type().ToString(),
typename.EnumToString(
SCR_ESpawnResult, result), spawnedEntity));
113 Debug.EndTimeMeasure(
"SpawnEntity_S");
124 requestComponent.StartSpawnPreload(
data.GetPosition());
135 return !requestComponent.IsPreloading();
146 int playerId = requestComponent.GetPlayerId();
147 #ifdef _ENABLE_RESPAWN_LOGS
148 Print(
string.Format(
"%1::FinalizeRequest_S(playerId: %2, data: %3)", Type().ToString(),
150 data), LogLevel.NORMAL);
157 respawnSystem.OnPlayerSpawnFinalize_S(requestComponent,
this,
data, entity);
176 #ifdef _ENABLE_RESPAWN_LOGS
177 Print(
string.Format(
"%1::ValidateData_S(playerId: %1, data: %2)", Type().ToString(), requestComponent.GetPlayerId(),
data), LogLevel.NORMAL);
179 return data.IsValid();
192 #ifdef _ENABLE_RESPAWN_LOGS
193 Print(
string.Format(
"%1::CanRequestSpawn_S(playerId: %2, data: %3)", Type().ToString(),
194 requestComponent.GetPlayerId(),
data), LogLevel.NORMAL);
197 SCR_RespawnSystemComponent respawnSystem = SCR_RespawnSystemComponent.GetInstance();
198 return respawnSystem.CanRequestSpawn_S(requestComponent,
this,
data, result);
213 int playerId = requestComponent.GetPlayerId();
214 #ifdef _ENABLE_RESPAWN_LOGS
215 Print(
string.Format(
"%1::SpawnEntity_S(playerId: %2, data: %3)", Type().ToString(),
217 data), LogLevel.NORMAL);
220 ResourceName prefab =
data.GetPrefab();
224 IEntity previousEntity =
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerId);
227 EntitySpawnParams
params =
new EntitySpawnParams();
228 params.TransformMode = ETransformMode.WORLD;
229 vector angles =
data.GetAngles();
230 vector yawPitchRoll = Vector(angles[1], angles[0], angles[2]);
231 Math3D.AnglesToMatrix(yawPitchRoll,
params.Transform);
236 Debug.BeginTimeMeasure();
240 Resource res = Resource.Load(prefab);
245 Debug.EndTimeMeasure(
"Resource::Load");
246 Debug.BeginTimeMeasure();
254 Debug.EndTimeMeasure(
"Game::SpawnEntityPrefab");
263 spawnedEntity = entity;
273 #ifdef _ENABLE_RESPAWN_LOGS
274 Print(
string.Format(
"%1::ValidatePrefab_S(pref: %2)", Type().ToString(), resourceName), LogLevel.NORMAL);
277 if (resourceName.IsEmpty())
280 Resource res = Resource.Load(resourceName);
288 IEntityComponentSource baseControllerComponent =
SCR_BaseContainerTools.FindComponentSource(res, RplComponent);
289 if (!baseControllerComponent)
304 #ifdef _ENABLE_RESPAWN_LOGS
305 Print(
string.Format(
"%1::PrepareEntity_S(playerId: %2, entity: %3, data: %4)", Type().ToString(),
306 requestComponent.GetPlayerController().GetPlayerId(),
308 data), LogLevel.NORMAL);
322 int playerId = requestComponent.GetPlayerController().GetPlayerId();
323 #ifdef _ENABLE_RESPAWN_LOGS
324 Print(
string.Format(
"%1::AssignEntity_S(playerId: %2, entity: %3, data: %4)", Type().ToString(),
327 data), LogLevel.NORMAL);
333 IEntity previous = playerController.GetControlledEntity();
334 if (previous == entity)
337 playerController.SetInitialMainEntity(entity);
354 #ifdef _ENABLE_RESPAWN_LOGS
355 Print(
string.Format(
"%1::HandleSpawnEntityFailure_S(playerId: %2, entity: %2, data: %3, res: %4)", Type().ToString(),
356 requestComponent.GetPlayerId(), entity,
data,
typename.EnumToString(
SCR_ESpawnResult, reason)), LogLevel.NORMAL);
360 respawnSystem.OnSpawnPlayerEntityFailure_S(requestComponent,
this, entity,
data, reason);
363 RplComponent.DeleteRplEntity(entity,
false);
386 #ifdef _ENABLE_RESPAWN_LOGS
387 Print(
string.Format(
"%1::HandleEntityChange_S(playerId: %2, previousEntity: %3, newEntity: %4, data: %5)", Type().ToString(),
388 requestComponent.GetPlayerController().GetPlayerId(),
391 data), LogLevel.NORMAL);
396 respawnSystem.OnPlayerEntityChange_S(requestComponent,
this, previousEntity, newEntity,
data);
406 damageManager.SetHealthScaled(0.0);
410 RplComponent.DeleteRplEntity(previousEntity,
false);