startingGear for NPCs (#1877)
Need to cover up the lewds. Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -2,7 +2,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
|
using Content.Shared.Roles;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -59,6 +61,10 @@ namespace Content.IntegrationTests
|
|||||||
public GridCoordinates GetLateJoinSpawnPoint() => GridCoordinates.InvalidGrid;
|
public GridCoordinates GetLateJoinSpawnPoint() => GridCoordinates.InvalidGrid;
|
||||||
public GridCoordinates GetJobSpawnPoint(string jobId) => GridCoordinates.InvalidGrid;
|
public GridCoordinates GetJobSpawnPoint(string jobId) => GridCoordinates.InvalidGrid;
|
||||||
public GridCoordinates GetObserverSpawnPoint() => GridCoordinates.InvalidGrid;
|
public GridCoordinates GetObserverSpawnPoint() => GridCoordinates.InvalidGrid;
|
||||||
|
|
||||||
|
public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public T AddGameRule<T>() where T : GameRule, new()
|
public T AddGameRule<T>() where T : GameRule, new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using Content.Server.GameObjects.EntitySystems.AI;
|
using Content.Server.GameObjects.EntitySystems.AI;
|
||||||
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Content.Shared.GameObjects.Components.Movement;
|
using Content.Shared.GameObjects.Components.Movement;
|
||||||
|
using Content.Shared.Roles;
|
||||||
using Robust.Server.AI;
|
using Robust.Server.AI;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -32,6 +36,9 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AiLogicProcessor? Processor { get; set; }
|
public AiLogicProcessor? Processor { get; set; }
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public string? StartingGearPrototype { get; set; }
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public float VisionRadius
|
public float VisionRadius
|
||||||
@@ -51,12 +58,29 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
EntitySystem.Get<AiSystem>().ProcessorInitialize(this);
|
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 />
|
/// <inheritdoc />
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
|
|
||||||
serializer.DataField(ref _logicName, "logic", null);
|
serializer.DataField(ref _logicName, "logic", null);
|
||||||
|
serializer.DataReadWriteFunction(
|
||||||
|
"startingGear",
|
||||||
|
null,
|
||||||
|
startingGear => StartingGearPrototype = startingGear,
|
||||||
|
() => StartingGearPrototype);
|
||||||
serializer.DataField(ref _visionRadius, "vision", 8.0f);
|
serializer.DataField(ref _visionRadius, "vision", 8.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -541,6 +541,13 @@ namespace Content.Server.GameTicking
|
|||||||
GridCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID);
|
GridCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID);
|
||||||
var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates);
|
var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates);
|
||||||
var startingGear = _prototypeManager.Index<StartingGearPrototype>(job.StartingGear);
|
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))
|
if (entity.TryGetComponent(out InventoryComponent inventory))
|
||||||
{
|
{
|
||||||
var gear = startingGear.Equipment;
|
var gear = startingGear.Equipment;
|
||||||
@@ -561,8 +568,6 @@ namespace Content.Server.GameTicking
|
|||||||
handsComponent.PutInHand(inhandEntity.GetComponent<ItemComponent>(), hand);
|
handsComponent.PutInHand(inhandEntity.GetComponent<ItemComponent>(), hand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyCharacterProfile(IEntity entity, ICharacterProfile profile)
|
private void ApplyCharacterProfile(IEntity entity, ICharacterProfile profile)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
|
using Content.Shared.Roles;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -33,6 +35,8 @@ namespace Content.Server.Interfaces.GameTicking
|
|||||||
GridCoordinates GetJobSpawnPoint(string jobId);
|
GridCoordinates GetJobSpawnPoint(string jobId);
|
||||||
GridCoordinates GetObserverSpawnPoint();
|
GridCoordinates GetObserverSpawnPoint();
|
||||||
|
|
||||||
|
void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear);
|
||||||
|
|
||||||
// GameRule system.
|
// GameRule system.
|
||||||
T AddGameRule<T>() where T : GameRule, new();
|
T AddGameRule<T>() where T : GameRule, new();
|
||||||
bool HasGameRule(Type type);
|
bool HasGameRule(Type type);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
id: HumanMob_PathDummy
|
id: HumanMob_PathDummy
|
||||||
description: A miserable pile of secrets
|
description: A miserable pile of secrets
|
||||||
drawdepth: Mobs
|
drawdepth: Mobs
|
||||||
|
suffix: AI
|
||||||
components:
|
components:
|
||||||
- type: AiController
|
- type: AiController
|
||||||
logic: PathingDummy
|
logic: PathingDummy
|
||||||
|
|||||||
@@ -5,20 +5,22 @@
|
|||||||
id: HumanMob_Civilian
|
id: HumanMob_Civilian
|
||||||
description: A miserable pile of secrets
|
description: A miserable pile of secrets
|
||||||
drawdepth: Mobs
|
drawdepth: Mobs
|
||||||
|
suffix: AI
|
||||||
components:
|
components:
|
||||||
- type: AiController
|
- type: AiController
|
||||||
logic: Civilian
|
logic: Civilian
|
||||||
|
startingGear: AssistantGear
|
||||||
- type: AiFactionTag
|
- type: AiFactionTag
|
||||||
factions:
|
factions:
|
||||||
- NanoTransen
|
- NanoTransen
|
||||||
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
save: false
|
save: false
|
||||||
name: Spirate
|
name: Spirate
|
||||||
parent: BaseHumanMob_Content
|
parent: BaseHumanMob_Content
|
||||||
id: HumanMob_Spirate
|
id: HumanMob_Spirate
|
||||||
description: Yarr
|
description: Yarr
|
||||||
|
suffix: AI
|
||||||
components:
|
components:
|
||||||
- type: AiController
|
- type: AiController
|
||||||
logic: Spirate
|
logic: Spirate
|
||||||
|
|||||||
Reference in New Issue
Block a user