GhostRoleMobSpawner can make entities sentient when spawning them.

This commit is contained in:
Vera Aguilera Puerto
2021-02-14 13:34:02 +01:00
parent 8185a4b4d3
commit 10bfc087e7
2 changed files with 15 additions and 1 deletions

View File

@@ -43,6 +43,11 @@ namespace Content.Server.Commands
return;
}
MakeSentient(entity);
}
public static void MakeSentient(IEntity entity)
{
if(entity.HasComponent<AiControllerComponent>())
entity.RemoveComponent<AiControllerComponent>();

View File

@@ -1,4 +1,5 @@
using System;
using Content.Server.Commands;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.Players;
using JetBrains.Annotations;
@@ -18,9 +19,12 @@ namespace Content.Server.GameObjects.Components.Observer
public override string Name => "GhostRoleMobSpawner";
[ViewVariables]
[ViewVariables(VVAccess.ReadWrite)]
private bool _deleteOnSpawn = true;
[ViewVariables(VVAccess.ReadWrite)]
private bool _makeSentient = true;
[ViewVariables(VVAccess.ReadWrite)]
private int _availableTakeovers = 1;
@@ -35,6 +39,7 @@ namespace Content.Server.GameObjects.Components.Observer
serializer.DataField(this, x => x.Prototype, "prototype", null);
serializer.DataField(ref _deleteOnSpawn, "deleteOnSpawn", true);
serializer.DataField(ref _makeSentient, "makeSentient", true);
serializer.DataField(ref _availableTakeovers, "availableTakeovers", 1);
}
@@ -48,7 +53,11 @@ namespace Content.Server.GameObjects.Components.Observer
var mob = Owner.EntityManager.SpawnEntity(Prototype, Owner.Transform.Coordinates);
if(_makeSentient)
MakeSentientCommand.MakeSentient(mob);
mob.EnsureComponent<MindComponent>();
session.ContentData().Mind.TransferTo(mob);
if (++_currentTakeovers < _availableTakeovers) return true;