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:
39
Content.Client/Commands/DebugCommands.cs
Normal file
39
Content.Client/Commands/DebugCommands.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using Content.Shared.GameObjects.Components.Markers;
|
||||||
|
using SS14.Client.Interfaces.Console;
|
||||||
|
using SS14.Client.Interfaces.GameObjects.Components;
|
||||||
|
using SS14.Shared.GameObjects;
|
||||||
|
using SS14.Shared.Interfaces.GameObjects;
|
||||||
|
using SS14.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Client.Commands
|
||||||
|
{
|
||||||
|
internal sealed class ShowMarkersCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
// ReSharper disable once StringLiteralTypo
|
||||||
|
public string Command => "togglemarkers";
|
||||||
|
public string Description => "Toggles visibility of markers such as spawn points.";
|
||||||
|
public string Help => "";
|
||||||
|
|
||||||
|
public bool Execute(IDebugConsole console, params string[] args)
|
||||||
|
{
|
||||||
|
bool? whichToSet = null;
|
||||||
|
foreach (var entity in IoCManager.Resolve<IEntityManager>()
|
||||||
|
.GetEntities(new TypeEntityQuery(typeof(SharedSpawnPointComponent))))
|
||||||
|
{
|
||||||
|
if (!entity.TryGetComponent(out ISpriteComponent sprite))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!whichToSet.HasValue)
|
||||||
|
{
|
||||||
|
whichToSet = !sprite.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite.Visible = whichToSet.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,6 +71,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Commands\DebugCommands.cs" />
|
||||||
<Compile Include="EntryPoint.cs" />
|
<Compile Include="EntryPoint.cs" />
|
||||||
<Compile Include="GameObjects\Components\Actor\CharacterInterface.cs" />
|
<Compile Include="GameObjects\Components\Actor\CharacterInterface.cs" />
|
||||||
<Compile Include="GameObjects\Components\DamageableComponent.cs" />
|
<Compile Include="GameObjects\Components\DamageableComponent.cs" />
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ using SS14.Shared.IoC;
|
|||||||
using SS14.Shared.Prototypes;
|
using SS14.Shared.Prototypes;
|
||||||
using System;
|
using System;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
|
using Content.Shared.GameObjects.Components.Markers;
|
||||||
using SS14.Client.Interfaces.UserInterface;
|
using SS14.Client.Interfaces.UserInterface;
|
||||||
using SS14.Shared.Log;
|
using SS14.Shared.Log;
|
||||||
|
|
||||||
@@ -97,6 +98,8 @@ namespace Content.Client
|
|||||||
|
|
||||||
factory.RegisterIgnore("PowerCell");
|
factory.RegisterIgnore("PowerCell");
|
||||||
|
|
||||||
|
factory.Register<SharedSpawnPointComponent>();
|
||||||
|
|
||||||
IoCManager.Register<IClientNotifyManager, ClientNotifyManager>();
|
IoCManager.Register<IClientNotifyManager, ClientNotifyManager>();
|
||||||
IoCManager.Register<ISharedNotifyManager, ClientNotifyManager>();
|
IoCManager.Register<ISharedNotifyManager, ClientNotifyManager>();
|
||||||
IoCManager.Register<IClientGameTicker, ClientGameTicker>();
|
IoCManager.Register<IClientGameTicker, ClientGameTicker>();
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
<Compile Include="GameObjects\Components\Items\Storage\StoreableComponent.cs" />
|
<Compile Include="GameObjects\Components\Items\Storage\StoreableComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\Items\Storage\ServerStorageComponent.cs" />
|
<Compile Include="GameObjects\Components\Items\Storage\ServerStorageComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\Items\Storage\ItemComponent.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\DamageStates.cs" />
|
||||||
<Compile Include="GameObjects\Components\Mobs\DamageThresholdTemplates\DamageThresholdTemplates.cs" />
|
<Compile Include="GameObjects\Components\Mobs\DamageThresholdTemplates\DamageThresholdTemplates.cs" />
|
||||||
<Compile Include="GameObjects\Components\Mobs\DamageThresholdTemplates\HumanTemplate.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.Mobs;
|
||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Server.GameObjects.Components.Interactable;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
|
using Content.Server.GameObjects.Components.Markers;
|
||||||
using Content.Server.GameObjects.Components.Weapon.Ranged;
|
using Content.Server.GameObjects.Components.Weapon.Ranged;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Content.Shared.GameObjects.Components.Inventory;
|
using Content.Shared.GameObjects.Components.Inventory;
|
||||||
|
using Content.Shared.GameObjects.Components.Markers;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using SS14.Server.Interfaces.ServerStatus;
|
using SS14.Server.Interfaces.ServerStatus;
|
||||||
using SS14.Shared.Timing;
|
using SS14.Shared.Timing;
|
||||||
@@ -119,6 +121,9 @@ namespace Content.Server
|
|||||||
factory.Register<MindComponent>();
|
factory.Register<MindComponent>();
|
||||||
factory.Register<SpeciesComponent>();
|
factory.Register<SpeciesComponent>();
|
||||||
|
|
||||||
|
factory.Register<SpawnPointComponent>();
|
||||||
|
factory.RegisterReference<SpawnPointComponent, SharedSpawnPointComponent>();
|
||||||
|
|
||||||
IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
|
IoCManager.Register<ISharedNotifyManager, ServerNotifyManager>();
|
||||||
IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
|
IoCManager.Register<IServerNotifyManager, ServerNotifyManager>();
|
||||||
IoCManager.Register<IGameTicker, GameTicker>();
|
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.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects;
|
using Content.Server.GameObjects;
|
||||||
|
using Content.Server.GameObjects.Components.Markers;
|
||||||
using Content.Server.GameTicking.GamePresets;
|
using Content.Server.GameTicking.GamePresets;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Content.Server.Mobs;
|
using Content.Server.Mobs;
|
||||||
@@ -16,6 +17,7 @@ using SS14.Server.Player;
|
|||||||
using SS14.Shared.Configuration;
|
using SS14.Shared.Configuration;
|
||||||
using SS14.Shared.Console;
|
using SS14.Shared.Console;
|
||||||
using SS14.Shared.Enums;
|
using SS14.Shared.Enums;
|
||||||
|
using SS14.Shared.GameObjects;
|
||||||
using SS14.Shared.Interfaces.Configuration;
|
using SS14.Shared.Interfaces.Configuration;
|
||||||
using SS14.Shared.Interfaces.GameObjects;
|
using SS14.Shared.Interfaces.GameObjects;
|
||||||
using SS14.Shared.Interfaces.Map;
|
using SS14.Shared.Interfaces.Map;
|
||||||
@@ -75,6 +77,8 @@ namespace Content.Server.GameTicking
|
|||||||
[ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers;
|
[ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers;
|
||||||
private DateTime _roundStartTimeUtc;
|
private DateTime _roundStartTimeUtc;
|
||||||
|
|
||||||
|
private readonly Random _spawnRandom = new Random();
|
||||||
|
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private IEntityManager _entityManager;
|
[Dependency] private IEntityManager _entityManager;
|
||||||
[Dependency] private IMapManager _mapManager;
|
[Dependency] private IMapManager _mapManager;
|
||||||
@@ -217,7 +221,7 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
private IEntity _spawnPlayerMob()
|
private IEntity _spawnPlayerMob()
|
||||||
{
|
{
|
||||||
var entity = _entityManager.ForceSpawnEntityAt(PlayerPrototypeName, _spawnPoint);
|
var entity = _entityManager.ForceSpawnEntityAt(PlayerPrototypeName, _getLateJoinSpawnPoint());
|
||||||
var shoes = _entityManager.SpawnEntity("ShoesItem");
|
var shoes = _entityManager.SpawnEntity("ShoesItem");
|
||||||
var uniform = _entityManager.SpawnEntity("UniformAssistant");
|
var uniform = _entityManager.SpawnEntity("UniformAssistant");
|
||||||
if (entity.TryGetComponent(out InventoryComponent inventory))
|
if (entity.TryGetComponent(out InventoryComponent inventory))
|
||||||
@@ -231,7 +235,29 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
private IEntity _spawnObserverMob()
|
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>
|
/// <summary>
|
||||||
|
|||||||
@@ -68,6 +68,7 @@
|
|||||||
<Compile Include="GameObjects\Components\Inventory\EquipmentSlotDefinitions.cs" />
|
<Compile Include="GameObjects\Components\Inventory\EquipmentSlotDefinitions.cs" />
|
||||||
<Compile Include="GameObjects\Components\Inventory\InventoryTemplates.cs" />
|
<Compile Include="GameObjects\Components\Inventory\InventoryTemplates.cs" />
|
||||||
<Compile Include="GameObjects\Components\Inventory\SharedInventoryComponent.cs" />
|
<Compile Include="GameObjects\Components\Inventory\SharedInventoryComponent.cs" />
|
||||||
|
<Compile Include="GameObjects\Components\Markers\SharedSpawnPointComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\Power\PowerShared.cs" />
|
<Compile Include="GameObjects\Components\Power\PowerShared.cs" />
|
||||||
<Compile Include="GameObjects\Components\Power\SharedPowerCellComponent.cs" />
|
<Compile Include="GameObjects\Components\Power\SharedPowerCellComponent.cs" />
|
||||||
<Compile Include="GameObjects\Components\Storage\SharedStorageComponent.cs" />
|
<Compile Include="GameObjects\Components\Storage\SharedStorageComponent.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using SS14.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Shared.GameObjects.Components.Markers
|
||||||
|
{
|
||||||
|
public class SharedSpawnPointComponent : Component
|
||||||
|
{
|
||||||
|
public sealed override string Name => "SpawnPoint";
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Resources/Prototypes/Entities/markers/spawn_points.yml
Normal file
31
Resources/Prototypes/Entities/markers/spawn_points.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
- type: entity
|
||||||
|
name: Spawn Point
|
||||||
|
id: spawn_point
|
||||||
|
abstract: true
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
netsync: false
|
||||||
|
visible: false
|
||||||
|
sprite: Objects/markers.rsi
|
||||||
|
|
||||||
|
- type: Icon
|
||||||
|
sprite: Objects/markers.rsi
|
||||||
|
|
||||||
|
- type: SpawnPoint
|
||||||
|
|
||||||
|
placement:
|
||||||
|
mode: SnapgridCenter
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
name: LateJoin Spawn Point
|
||||||
|
id: spawn_point_latejoin
|
||||||
|
parent: spawn_point
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
state: cross_red
|
||||||
|
|
||||||
|
- type: SpawnPoint
|
||||||
|
spawn_type: LateJoin
|
||||||
|
|
||||||
|
- type: Icon
|
||||||
|
state: cross_red
|
||||||
BIN
Resources/Textures/Objects/markers.rsi/cross_blue.png
Normal file
BIN
Resources/Textures/Objects/markers.rsi/cross_blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 214 B |
BIN
Resources/Textures/Objects/markers.rsi/cross_green.png
Normal file
BIN
Resources/Textures/Objects/markers.rsi/cross_green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 309 B |
BIN
Resources/Textures/Objects/markers.rsi/cross_red.png
Normal file
BIN
Resources/Textures/Objects/markers.rsi/cross_red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 296 B |
1
Resources/Textures/Objects/markers.rsi/meta.json
Normal file
1
Resources/Textures/Objects/markers.rsi/meta.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/vgstation-coders/vgstation13/blob/e71d6c4fba5a51f99b81c295dcaec4fc2f58fb19/icons/mob/screen1.dmi", "states": [{"name": "cross_blue", "directions": 1, "delays": [[1.0]]}, {"name": "cross_green", "directions": 1, "delays": [[1.0]]}, {"name": "cross_red", "directions": 1, "delays": [[1.0]]}]}
|
||||||
Reference in New Issue
Block a user