Skip to content

Commit

Permalink
fix (#844)
Browse files Browse the repository at this point in the history
* fix

* cd fix
  • Loading branch information
Rxup authored Oct 17, 2024
1 parent ff33e52 commit bf4446d
Show file tree
Hide file tree
Showing 36 changed files with 264 additions and 146 deletions.
69 changes: 68 additions & 1 deletion Content.IntegrationTests/Tests/Backmen/Language/LanguageTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
using Content.Server.Backmen.Blob.NPC.BlobPod;
using Content.Server.Antag.Components;
using Content.Server.Backmen.Blob.NPC.BlobPod;
using Content.Server.Backmen.Cloning.Components;
using Content.Server.Backmen.Language;
using Content.Server.GameTicking;
using Content.Server.Ghost.Roles.Components;
using Content.Shared.Backmen.Blob.Components;
using Content.Shared.Backmen.Language;
using Content.Shared.Backmen.Language.Components;
using Content.Shared.Backmen.Language.Systems;
using Content.Shared.Destructible;
using Content.Shared.Ghost.Roles.Components;
using Robust.Client.UserInterface.RichText;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
Expand All @@ -13,6 +20,66 @@ namespace Content.IntegrationTests.Tests.Backmen.Language;
[TestOf(typeof(SharedLanguageSystem))]
public sealed class LanguageTest
{
[Test]
public async Task RoleCanUnderstandTest()
{
await using var pair = await PoolManager.GetServerClient(new PoolSettings
{
Dirty = false,
DummyTicker = false,
Connected = true
});

var server = pair.Server;
var client = pair.Client;

var entMan = server.EntMan;
var ticker = server.System<GameTicker>();
var sys = (LanguageSystem)server.System<SharedLanguageSystem>();
var proto = server.ResolveDependency<IPrototypeManager>();
var compFactory = server.ResolveDependency<IComponentFactory>();

var testMap = await pair.CreateTestMap();

Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.InRound));

await server.WaitAssertion(() =>
{
foreach (var entProto in proto.EnumeratePrototypes<EntityPrototype>())
{
if(entProto.ID is "GhostRoleTestEntity" or "SpawnPointReturnToMenu")
continue;

EntityUid ent;
if (
entProto.TryGetComponent<GhostRoleAntagSpawnerComponent>(out _, compFactory) ||
entProto.TryGetComponent<CloningAppearanceComponent>(out _, compFactory)
)
{
continue;
}
if (entProto.TryGetComponent<GhostRoleMobSpawnerComponent>(out var ghostRoleMobSpawnerComponent, compFactory))
{
ent = entMan.Spawn(ghostRoleMobSpawnerComponent.Prototype, testMap.MapCoords);
}
else if (entProto.TryGetComponent<GhostRoleComponent>(out var ghostRoleComponent, compFactory))
{
ent = entMan.Spawn(entProto.ID, testMap.MapCoords);
}
else
{
continue;
}
Assert.That(entMan.HasComponent<LanguageSpeakerComponent>(ent), Is.True, $"{entMan.ToPrettyString(ent)} does not have a language speaker component");
Assert.That(entMan.HasComponent<LanguageKnowledgeComponent>(ent), Is.True, $"{entMan.ToPrettyString(ent)} does not have a language knowledge");
Assert.That(sys.CanUnderstand(ent, "TauCetiBasic"), $"{entMan.ToPrettyString(ent)} does not understand TauCetiBasic");
entMan.DeleteEntity(ent);
}
});

await pair.CleanReturnAsync();
}

[Test]
public async Task FontsTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace Content.Server.Backmen.Abilities.Psionics;

public sealed class MindSwapPowerSystem : EntitySystem
public sealed class MindSwapPowerSystem : SharedMindSwapPowerSystem
{
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
Expand Down
24 changes: 24 additions & 0 deletions Content.Server/Backmen/Blob/BlobTileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
using Content.Shared.Damage;
using Content.Shared.Destructible;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.NPC.Components;
using Content.Shared.NPC.Prototypes;
using Content.Shared.NPC.Systems;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
Expand All @@ -28,13 +34,19 @@ public sealed class BlobTileSystem : SharedBlobTileSystem
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly NpcFactionSystem _npcFactionSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;

private EntityQuery<BlobCoreComponent> _blobCoreQuery;

[ValidatePrototypeId<NpcFactionPrototype>]
private const string BlobFaction = "Blob";

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BlobTileComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<BlobTileComponent, DestructionEventArgs>(OnDestruction);
SubscribeLocalEvent<BlobTileComponent, BlobTileGetPulseEvent>(OnPulsed);
SubscribeLocalEvent<BlobTileComponent, FlashAttemptEvent>(OnFlashAttempt);
Expand All @@ -43,6 +55,18 @@ public override void Initialize()
_blobCoreQuery = GetEntityQuery<BlobCoreComponent>();
}

private void OnMapInit(Entity<BlobTileComponent> ent, ref MapInitEvent args)
{
var faction = EnsureComp<NpcFactionMemberComponent>(ent);
Entity<NpcFactionMemberComponent?> factionEnt = (ent, faction);

_npcFactionSystem.ClearFactions(factionEnt, false);
_npcFactionSystem.AddFaction(factionEnt, BlobFaction, true);

// make alive - true for npc combat
EnsureComp<MobStateComponent>(ent);
}

private void OnTerminate(EntityUid uid, BlobTileComponent component, EntityTerminatingEvent args)
{
if (TerminatingOrDeleted(component.Core))
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Backmen/Blob/NPC/BlobPod/BlobPodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Content.Shared.Inventory;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Rejuvenate;
using Robust.Server.Audio;
using Robust.Shared.Containers;
Expand All @@ -34,6 +35,7 @@ public sealed class BlobPodSystem : SharedBlobPodSystem
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly SharedMoverController _mover = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -116,6 +118,7 @@ public bool Zombify(Entity<BlobPodComponent> ent, EntityUid target)
if (HasComp<ActorComponent>(ent))
{
_npc.SleepNPC(target);
_mover.SetRelay(ent, target);
}

return true;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Backmen/Blob/ZombieBlobSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private void OnStartup(EntityUid uid, ZombieBlobComponent component, ComponentSt
var htn = EnsureComp<HTNComponent>(uid);
htn.RootTask = new HTNCompoundTask() {Task = "SimpleHostileCompound"};
htn.Blackboard.SetValue(NPCBlackboard.Owner, uid);
htn.Blackboard.SetValue(NPCBlackboard.NavBlob, true);

if (!HasComp<ActorComponent>(component.BlobPodUid))
{
Expand Down
10 changes: 7 additions & 3 deletions Content.Server/Backmen/Disease/DiseaseSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ public override void Update(float frameTime)
}
_cureQueue.Clear();

var q = EntityQueryEnumerator<DiseasedComponent, DiseaseCarrierComponent, MobStateComponent>();
while (q.MoveNext(out var owner, out _, out var carrierComp, out var mobState))
var q = EntityQueryEnumerator<DiseasedComponent, DiseaseCarrierComponent, MobStateComponent, MetaDataComponent>();
while (q.MoveNext(out var owner, out _, out var carrierComp, out var mobState, out var metaDataComponent))
{
if(Paused(owner, metaDataComponent))
continue;

if (carrierComp.Diseases.Count == 0)
{
continue;
Expand All @@ -129,7 +132,8 @@ public override void Update(float frameTime)
System = this,
Owner = (owner, carrierComp, mobState),
FrameTime = frameTime
}, carrierComp.Diseases.Count);
},
carrierComp.Diseases.Count);
}
}

Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Backmen/StationEvents/Events/BlobSpawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
using Content.Server.StationEvents.Events;
using Content.Shared.Backmen.Blob.Components;
using Content.Shared.GameTicking.Components;
using Content.Shared.Players;
using Content.Shared.Station.Components;
using Robust.Server.Player;
using Robust.Shared.Player;

namespace Content.Server.Backmen.StationEvents.Events;

Expand Down Expand Up @@ -82,5 +84,7 @@ private void OnSpawned(EntityUid uid, BlobCarrierComponent component, GhostRoleS
// Blob doesn't spawn when blob carrier was eaten.
RemComp<FoodComponent>(carrier);
RemComp<FelinidFoodComponent>(carrier);


}
}
2 changes: 2 additions & 0 deletions Content.Server/NPC/NPCBlackboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ public string GetVisionRadiusKey(IEntityManager entMan)
/// </summary>
public const string NavClimb = "NavClimb";

public const string NavBlob = "NavBlob";

/// <summary>
/// Default key storage for a movement pathfind.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/NPC/Pathfinding/PathFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ public enum PathFlags : byte
/// Can we open stuff that requires interaction (e.g. click-open doors).
/// </summary>
Interact = 1 << 4,

Blob = 1 << 5,
}
7 changes: 7 additions & 0 deletions Content.Server/NPC/Pathfinding/PathfindingSystem.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ private float GetTileCost(PathRequest request, PathPoly start, PathPoly end)
var isAccess = (end.Data.Flags & PathfindingBreadcrumbFlag.Access) != 0x0;
var isClimb = (end.Data.Flags & PathfindingBreadcrumbFlag.Climb) != 0x0;

// start-backmen: blob
if ((end.Data.Flags & PathfindingBreadcrumbFlag.Blob) != 0x0 && (request.Flags & PathFlags.Blob) != 0x0)
{
modifier += 0f;
}
else
// end-backmen: blob
// TODO: Handling power + door prying
// Door we should be able to open
if (isDoor && !isAccess && (request.Flags & PathFlags.Interact) != 0x0)
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,13 @@ private void BuildBreadcrumbs(GridPathfindingChunk chunk, Entity<MapGridComponen
if (!colliding)
continue;

// start-backmen: blob
if (_tilesQuery.HasComponent(ent))
{
flags |= PathfindingBreadcrumbFlag.Blob;
}
// end-backmen: blob

if (_accessQuery.HasComponent(ent))
{
flags |= PathfindingBreadcrumbFlag.Access;
Expand Down
9 changes: 9 additions & 0 deletions Content.Server/NPC/Pathfinding/PathfindingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public sealed partial class PathfindingSystem : SharedPathfindingSystem
private int _portalIndex;
private readonly Dictionary<int, PathPortal> _portals = new();

private EntityQuery<Shared.Backmen.Blob.Components.BlobTileComponent> _tilesQuery; // backmen: blob
private EntityQuery<AccessReaderComponent> _accessQuery;
private EntityQuery<DestructibleComponent> _destructibleQuery;
private EntityQuery<DoorComponent> _doorQuery;
Expand All @@ -80,6 +81,7 @@ public override void Initialize()
{
base.Initialize();

_tilesQuery = GetEntityQuery<Shared.Backmen.Blob.Components.BlobTileComponent>(); // backmen: blob
_accessQuery = GetEntityQuery<AccessReaderComponent>();
_destructibleQuery = GetEntityQuery<DestructibleComponent>();
_doorQuery = GetEntityQuery<DoorComponent>();
Expand Down Expand Up @@ -472,6 +474,13 @@ public PathFlags GetFlags(NPCBlackboard blackboard)
flags |= PathFlags.Interact;
}

// start-backmen: blob
if (blackboard.TryGetValue<bool>(NPCBlackboard.NavBlob, out var blob, EntityManager) && blob)
{
flags |= PathFlags.Blob;
}
// end-backmen: blob

return flags;
}

Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Polymorph/Systems/PolymorphSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ public void CreatePolymorphAction(ProtoId<PolymorphPrototype> id, Entity<Polymor
// start-backmen: action fix
if (_actions.TryGetActionData(actionId, out var actionComponent))
{
actionComponent.UseDelay = polyProto.Configuration.Cooldown;
if (polyProto.Configuration.Cooldown != TimeSpan.Zero)
{
actionComponent.UseDelay = polyProto.Configuration.Cooldown;
_actions.SetCooldown(actionId, polyProto.Configuration.Cooldown);
}
}
// end-backmen: action fix

Expand Down
17 changes: 2 additions & 15 deletions Content.Shared/Backmen/Blob/NPC/BlobPod/SharedBlobPodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Systems;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.Serialization;
Expand All @@ -19,8 +20,8 @@ public abstract class SharedBlobPodSystem : EntitySystem
{
[Dependency] private readonly MobStateSystem _mobs = default!;


private EntityQuery<HumanoidAppearanceComponent> _query;
private EntityQuery<InputMoverComponent> _inputQuery;

public override void Initialize()
{
Expand All @@ -31,21 +32,7 @@ public override void Initialize()
SubscribeLocalEvent<BlobPodComponent, CanDropTargetEvent>(OnCanDragDropOn);
SubscribeLocalEvent<BlobPodComponent, DragDropTargetEvent>(OnBlobPodDragDrop);

SubscribeLocalEvent<BlobPodComponent, MoveInputEvent>(OnRelayMoveInput);

_query = GetEntityQuery<HumanoidAppearanceComponent>();
_inputQuery = GetEntityQuery<InputMoverComponent>();
}

private void OnRelayMoveInput(Entity<BlobPodComponent> ent, ref MoveInputEvent args)
{
if (ent.Comp.ZombifiedEntityUid == null || TerminatingOrDeleted(ent.Comp.ZombifiedEntityUid.Value) || !_inputQuery.TryComp(ent.Comp.ZombifiedEntityUid.Value, out var inputMoverComponent))
return;

var inputMoverEntity = new Entity<InputMoverComponent>(EntityUid.FirstUid, inputMoverComponent);
var moveEvent = new MoveInputEvent(inputMoverEntity, args.OldMovement);
inputMoverComponent.HeldMoveButtons = args.OldMovement;
RaiseLocalEvent(ent.Comp.ZombifiedEntityUid.Value, ref moveEvent);
}

private void OnBlobPodDragDrop(Entity<BlobPodComponent> ent, ref DragDropTargetEvent args)
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Mobs/Components/MobThresholdsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public sealed partial class MobThresholdsComponent : Component
/// <summary>
/// Whether or not this entity can be revived out of a dead state.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("allowRevives")]
public bool AllowRevives;
}
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/NPC/PathfindingBreadcrumb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,6 @@ public enum PathfindingBreadcrumbFlag : ushort
/// Is there climbing involved
/// </summary>
Climb = 1 << 4,

Blob = 1 << 5
}
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
- Mouse
understands:
- Mouse
- TauCetiBasic
- type: MeleeWeapon
soundHit:
path: /Audio/Effects/bite.ogg
Expand Down Expand Up @@ -544,6 +545,7 @@
- Moffic
understands:
- Moffic
- TauCetiBasic
- type: ZombieAccentOverride
accent: zombieMoth
- type: Vocal
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/carp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
- SpaceMob
- Carp
- Dragon
- TauCetiBasic
- type: Speech
speechVerb: LargeMob
- type: InteractionPopup
Expand Down
Loading

0 comments on commit bf4446d

Please sign in to comment.