Spawn point system.
Hey we can place spawn points on the map now instead of hardcoding them! Spawn points are simply invisible bare bones entities.
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
<Compile Include="GameObjects\Components\Items\Storage\StoreableComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Items\Storage\ServerStorageComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Items\Storage\ItemComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Markers\SpawnPointComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mobs\DamageStates.cs" />
|
||||
<Compile Include="GameObjects\Components\Mobs\DamageThresholdTemplates\DamageThresholdTemplates.cs" />
|
||||
<Compile Include="GameObjects\Components\Mobs\DamageThresholdTemplates\HumanTemplate.cs" />
|
||||
|
||||
@@ -34,11 +34,13 @@ using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Mobs;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
using Content.Server.GameObjects.Components.Markers;
|
||||
using Content.Server.GameObjects.Components.Weapon.Ranged;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.GameObjects.Components.Markers;
|
||||
using Content.Shared.Interfaces;
|
||||
using SS14.Server.Interfaces.ServerStatus;
|
||||
using SS14.Shared.Timing;
|
||||
@@ -119,6 +121,9 @@ namespace Content.Server
|
||||
factory.Register<MindComponent>();
|
||||
factory.Register<SpeciesComponent>();
|
||||
|
||||
factory.Register<SpawnPointComponent>();
|
||||
factory.RegisterReference<SpawnPointComponent, SharedSpawnPointComponent>();
|
||||
|
||||
IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
|
||||
IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
|
||||
IoCManager.Register<IGameTicker, GameTicker>();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Markers;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.Serialization;
|
||||
using SS14.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Markers
|
||||
{
|
||||
public sealed class SpawnPointComponent : SharedSpawnPointComponent
|
||||
{
|
||||
private SpawnPointType _spawnType;
|
||||
[ViewVariables]
|
||||
public SpawnPointType SpawnType => _spawnType;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _spawnType, "spawn_type", SpawnPointType.Unset);
|
||||
}
|
||||
}
|
||||
|
||||
public enum SpawnPointType
|
||||
{
|
||||
Unset = 0,
|
||||
LateJoin,
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Server.GameObjects.Components.Markers;
|
||||
using Content.Server.GameTicking.GamePresets;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Server.Mobs;
|
||||
@@ -16,6 +17,7 @@ using SS14.Server.Player;
|
||||
using SS14.Shared.Configuration;
|
||||
using SS14.Shared.Console;
|
||||
using SS14.Shared.Enums;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.Interfaces.Configuration;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.Map;
|
||||
@@ -75,6 +77,8 @@ namespace Content.Server.GameTicking
|
||||
[ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers;
|
||||
private DateTime _roundStartTimeUtc;
|
||||
|
||||
private readonly Random _spawnRandom = new Random();
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private IEntityManager _entityManager;
|
||||
[Dependency] private IMapManager _mapManager;
|
||||
@@ -217,7 +221,7 @@ namespace Content.Server.GameTicking
|
||||
|
||||
private IEntity _spawnPlayerMob()
|
||||
{
|
||||
var entity = _entityManager.ForceSpawnEntityAt(PlayerPrototypeName, _spawnPoint);
|
||||
var entity = _entityManager.ForceSpawnEntityAt(PlayerPrototypeName, _getLateJoinSpawnPoint());
|
||||
var shoes = _entityManager.SpawnEntity("ShoesItem");
|
||||
var uniform = _entityManager.SpawnEntity("UniformAssistant");
|
||||
if (entity.TryGetComponent(out InventoryComponent inventory))
|
||||
@@ -231,7 +235,29 @@ namespace Content.Server.GameTicking
|
||||
|
||||
private IEntity _spawnObserverMob()
|
||||
{
|
||||
return _entityManager.ForceSpawnEntityAt(ObserverPrototypeName, _spawnPoint);
|
||||
return _entityManager.ForceSpawnEntityAt(ObserverPrototypeName, _getLateJoinSpawnPoint());
|
||||
}
|
||||
|
||||
private GridCoordinates _getLateJoinSpawnPoint()
|
||||
{
|
||||
var location = _spawnPoint;
|
||||
|
||||
var possiblePoints = new List<GridCoordinates>();
|
||||
foreach (var entity in _entityManager.GetEntities(new TypeEntityQuery(typeof(SpawnPointComponent))))
|
||||
{
|
||||
var point = entity.GetComponent<SpawnPointComponent>();
|
||||
if (point.SpawnType == SpawnPointType.LateJoin)
|
||||
{
|
||||
possiblePoints.Add(entity.Transform.GridPosition);
|
||||
}
|
||||
}
|
||||
|
||||
if (possiblePoints.Count != 0)
|
||||
{
|
||||
location = _spawnRandom.Pick(possiblePoints);
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user