startingGear for NPCs (#1877)

Need to cover up the lewds.

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-08-25 04:11:32 +10:00
committed by GitHub
parent abc446109e
commit 997d3dcdd4
6 changed files with 45 additions and 3 deletions

View File

@@ -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;
@@ -60,6 +62,10 @@ namespace Content.IntegrationTests
public GridCoordinates GetJobSpawnPoint(string jobId) => GridCoordinates.InvalidGrid;
public GridCoordinates GetObserverSpawnPoint() => GridCoordinates.InvalidGrid;
public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear)
{
}
public T AddGameRule<T>() where T : GameRule, new()
{
return new T();

View File

@@ -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;
@@ -33,6 +37,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<AiSystem>().ProcessorInitialize(this);
}
protected override void Startup()
{
base.Startup();
if (StartingGearPrototype != null)
{
var startingGear = IoCManager.Resolve<IPrototypeManager>().Index<StartingGearPrototype>(StartingGearPrototype);
IoCManager.Resolve<IGameTicker>().EquipStartingGear(Owner, startingGear);
}
}
/// <inheritdoc />
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);
}

View File

@@ -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<StartingGearPrototype>(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<ItemComponent>(), hand);
}
}
return entity;
}
private void ApplyCharacterProfile(IEntity entity, ICharacterProfile profile)

View File

@@ -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<T>() where T : GameRule, new();
bool HasGameRule(Type type);

View File

@@ -5,6 +5,7 @@
id: HumanMob_PathDummy
description: A miserable pile of secrets
drawdepth: Mobs
suffix: AI
components:
- type: AiController
logic: PathingDummy

View File

@@ -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