From 997d3dcdd471b3fb2f3720f4eda0ef7ca85373c7 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 25 Aug 2020 04:11:32 +1000 Subject: [PATCH] startingGear for NPCs (#1877) Need to cover up the lewds. Co-authored-by: Metal Gear Sloth --- Content.IntegrationTests/DummyGameTicker.cs | 6 +++++ .../Movement/AiControllerComponent.cs | 24 +++++++++++++++++++ Content.Server/GameTicking/GameTicker.cs | 9 +++++-- .../Interfaces/GameTicking/IGameTicker.cs | 4 ++++ .../Entities/Mobs/NPCs/dummy_npcs.yml | 1 + .../Prototypes/Entities/Mobs/NPCs/human.yml | 4 +++- 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Content.IntegrationTests/DummyGameTicker.cs b/Content.IntegrationTests/DummyGameTicker.cs index 5259c3de5c..e6b7e2a3ef 100644 --- a/Content.IntegrationTests/DummyGameTicker.cs +++ b/Content.IntegrationTests/DummyGameTicker.cs @@ -2,7 +2,9 @@ using System; using System.Collections.Generic; using Content.Server.GameTicking; using Content.Server.Interfaces.GameTicking; +using Content.Shared.Roles; using Robust.Server.Interfaces.Player; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Map; using Robust.Shared.Timing; @@ -59,6 +61,10 @@ namespace Content.IntegrationTests public GridCoordinates GetLateJoinSpawnPoint() => GridCoordinates.InvalidGrid; public GridCoordinates GetJobSpawnPoint(string jobId) => GridCoordinates.InvalidGrid; public GridCoordinates GetObserverSpawnPoint() => GridCoordinates.InvalidGrid; + + public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear) + { + } public T AddGameRule() where T : GameRule, new() { diff --git a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs index e613b33f50..a1d595062d 100644 --- a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs @@ -1,12 +1,16 @@ #nullable enable using Content.Server.GameObjects.EntitySystems.AI; +using Content.Server.Interfaces.GameTicking; using Content.Shared.GameObjects.Components.Movement; +using Content.Shared.Roles; using Robust.Server.AI; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -32,6 +36,9 @@ namespace Content.Server.GameObjects.Components.Movement } public AiLogicProcessor? Processor { get; set; } + + [ViewVariables(VVAccess.ReadWrite)] + public string? StartingGearPrototype { get; set; } [ViewVariables(VVAccess.ReadWrite)] public float VisionRadius @@ -51,12 +58,29 @@ namespace Content.Server.GameObjects.Components.Movement EntitySystem.Get().ProcessorInitialize(this); } + protected override void Startup() + { + base.Startup(); + + if (StartingGearPrototype != null) + { + var startingGear = IoCManager.Resolve().Index(StartingGearPrototype); + IoCManager.Resolve().EquipStartingGear(Owner, startingGear); + } + + } + /// public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); serializer.DataField(ref _logicName, "logic", null); + serializer.DataReadWriteFunction( + "startingGear", + null, + startingGear => StartingGearPrototype = startingGear, + () => StartingGearPrototype); serializer.DataField(ref _visionRadius, "vision", 8.0f); } diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index a38aad78c2..0f3bf337a7 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -541,6 +541,13 @@ namespace Content.Server.GameTicking GridCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID); var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates); var startingGear = _prototypeManager.Index(job.StartingGear); + EquipStartingGear(entity, startingGear); + + return entity; + } + + public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear) + { if (entity.TryGetComponent(out InventoryComponent inventory)) { var gear = startingGear.Equipment; @@ -561,8 +568,6 @@ namespace Content.Server.GameTicking handsComponent.PutInHand(inhandEntity.GetComponent(), hand); } } - - return entity; } private void ApplyCharacterProfile(IEntity entity, ICharacterProfile profile) diff --git a/Content.Server/Interfaces/GameTicking/IGameTicker.cs b/Content.Server/Interfaces/GameTicking/IGameTicker.cs index a4e045e2ee..8f218a4850 100644 --- a/Content.Server/Interfaces/GameTicking/IGameTicker.cs +++ b/Content.Server/Interfaces/GameTicking/IGameTicker.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using Content.Server.GameTicking; +using Content.Shared.Roles; using Robust.Server.Interfaces.Player; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Map; using Robust.Shared.Timing; @@ -33,6 +35,8 @@ namespace Content.Server.Interfaces.GameTicking GridCoordinates GetJobSpawnPoint(string jobId); GridCoordinates GetObserverSpawnPoint(); + void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear); + // GameRule system. T AddGameRule() where T : GameRule, new(); bool HasGameRule(Type type); diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/dummy_npcs.yml b/Resources/Prototypes/Entities/Mobs/NPCs/dummy_npcs.yml index 60dab85b6f..31c801f5cc 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/dummy_npcs.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/dummy_npcs.yml @@ -5,6 +5,7 @@ id: HumanMob_PathDummy description: A miserable pile of secrets drawdepth: Mobs + suffix: AI components: - type: AiController logic: PathingDummy diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/human.yml b/Resources/Prototypes/Entities/Mobs/NPCs/human.yml index 37caacb018..6df6db7fab 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/human.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/human.yml @@ -5,20 +5,22 @@ id: HumanMob_Civilian description: A miserable pile of secrets drawdepth: Mobs + suffix: AI components: - type: AiController logic: Civilian + startingGear: AssistantGear - type: AiFactionTag factions: - NanoTransen - - type: entity save: false name: Spirate parent: BaseHumanMob_Content id: HumanMob_Spirate description: Yarr + suffix: AI components: - type: AiController logic: Spirate