Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ngines into wizmerge
  • Loading branch information
sleepyyapril committed Dec 22, 2024
2 parents bf75328 + d1bd845 commit c198ef2
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 33 deletions.
30 changes: 30 additions & 0 deletions Content.Server/Clothing/Systems/LoadoutSystem.Functions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using JetBrains.Annotations;
using Robust.Shared.Serialization.Manager;
using Content.Shared.Clothing.Loadouts.Prototypes;
using Content.Server.NPC.Components;
using Content.Server.NPC.Systems;
using Content.Server.NPC.HTN;
using Content.Server.NPC;
using Robust.Shared.Map;
using System.Numerics;

namespace Content.Server.Clothing.Systems;

[UsedImplicitly]
public sealed partial class LoadoutMakeFollower : LoadoutFunction
{
public override void OnPlayerSpawn(EntityUid character,
EntityUid loadoutEntity,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager)
{
var npc = entityManager.System<NPCSystem>();
var htn = entityManager.System<HTNSystem>();
if (!entityManager.TryGetComponent<HTNComponent>(loadoutEntity, out var hTNComponent))
return;

npc.SetBlackboard(loadoutEntity, NPCBlackboard.FollowTarget, new EntityCoordinates(character, Vector2.Zero), hTNComponent);
htn.Replan(hTNComponent);
}
}
5 changes: 4 additions & 1 deletion Content.Server/Clothing/Systems/LoadoutSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Traits.Assorted.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand All @@ -33,6 +32,7 @@ public sealed class LoadoutSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;


public override void Initialize()
Expand Down Expand Up @@ -103,6 +103,9 @@ public void ApplyCharacterLoadout(
comp.Owner = loadout.Item1;
EntityManager.AddComponent(loadout.Item1, comp);
}

foreach (var function in loadoutProto.Functions)
function.OnPlayerSpawn(uid, loadout.Item1, _componentFactory, EntityManager, _serialization);
}


Expand Down
16 changes: 16 additions & 0 deletions Content.Shared/Clothing/Loadouts/Prototypes/LoadoutPrototype.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Customization.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager;

namespace Content.Shared.Clothing.Loadouts.Prototypes;

Expand Down Expand Up @@ -45,4 +46,19 @@ public sealed partial class LoadoutPrototype : IPrototype

[DataField]
public string GuideEntry { get; } = "";

[DataField(serverOnly: true)]
public LoadoutFunction[] Functions { get; private set; } = Array.Empty<LoadoutFunction>();
}

/// This serves as a hook for loadout functions to modify one or more entities upon spawning in.
[ImplicitDataDefinitionForInheritors]
public abstract partial class LoadoutFunction
{
public abstract void OnPlayerSpawn(
EntityUid character,
EntityUid loadoutEntity,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager);
}
15 changes: 15 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8742,3 +8742,18 @@ Entries:
id: 6586
time: '2024-12-21T19:25:13.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1365
- author: VMSolidus
changes:
- type: Add
message: Loadouts can now apply modular functions to items upon spawning in.
- type: Add
message: >-
A new LoadoutMakeFollower function, which lets you buy NPC followers in
loadouts.
- type: Add
message: >-
added Pet Mice, Cockroach, Mothroach, and Hamster to Loadouts. All of
which use the new LoadoutMakeFollower function.
id: 6587
time: '2024-12-22T10:26:41.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1366
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/loadouts/generic/items.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ loadout-name-LoadoutItemLighterFlippo = flippo lighter (colorable)
loadout-name-LoadoutItemDrinkShinyFlask = shiny flask (colorable)
loadout-name-LoadoutItemDrinkLithiumFlask = lithium flask (colorable)
loadout-name-LoadoutItemDrinkVacuumFlask = vacuum flask (colorable)
loadout-name-LoadoutItemPetMouse = pet mouse
loadout-name-LoadoutItemPetHamster = pet hamster
loadout-name-LoadoutItemPetMothroach = pet mothroach
loadout-name-LoadoutItemPetCockroach = pet cockroach
1 change: 1 addition & 0 deletions Resources/Locale/en-US/loadouts/itemgroups.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ character-item-group-LoadoutInstrumentsAny = Musical Instruments (Non-Musician)
character-item-group-LoadoutSmokes = Smokeables
character-item-group-LoadoutBoxKits = Survival Kits
character-item-group-LoadoutWritables = Writing Tools
character-item-group-LoadoutPets = Pets
# Job Specific Template
character-item-group-LoadoutJOBBackpacks = JOB Backpacks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,16 @@
id: LoadoutBookRandom
- type: loadout
id: LoadoutPen

- type: characterItemGroup
id: LoadoutPets
maxItems: 1
items:
- type: loadout
id: LoadoutItemPetMouse
- type: loadout
id: LoadoutItemPetHamster
- type: loadout
id: LoadoutItemPetMothroach
- type: loadout
id: LoadoutItemPetCockroach
60 changes: 60 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@
speaks: [Hissing]
understands: [Hissing]

- type: entity
parent: MobCockroach
id: MobCockroachPet
components:
- type: HTN
rootTask:
task: FollowCompound
blackboard:
IdleRange: !type:Single
1.5
FollowCloseRange: !type:Single
1.0
FollowRange: !type:Single
2.0

- type: entity
name: glockroach
parent: MobCockroach
Expand Down Expand Up @@ -575,6 +590,21 @@
enum.SurgeryUIKey.Key:
type: SurgeryBui

- type: entity
parent: MobMothroach
id: MobMothroachPet
components:
- type: HTN
rootTask:
task: FollowCompound
blackboard:
IdleRange: !type:Single
1.5
FollowCloseRange: !type:Single
1.0
FollowRange: !type:Single
2.0

# Note that the mallard duck is actually a male drake mallard, with the brown duck being the female variant of the same species, however ss14 lacks sex specific textures
# The white duck is more akin to a pekin or call duck.

Expand Down Expand Up @@ -1773,6 +1803,21 @@
Burger: RatBurger
Skewer: RatSkewer

- type: entity
parent: MobMouse
id: MobMousePet
components:
- type: HTN
rootTask:
task: FollowCompound
blackboard:
IdleRange: !type:Single
1.5
FollowCloseRange: !type:Single
1.0
FollowRange: !type:Single
2.0

- type: entity
parent: MobMouse
suffix: Dead
Expand Down Expand Up @@ -3464,6 +3509,21 @@
sprite: Mobs/Effects/onfire.rsi
normalState: Mouse_burning

- type: entity
parent: MobHamster
id: MobHamsterPet
components:
- type: HTN
rootTask:
task: FollowCompound
blackboard:
IdleRange: !type:Single
1.5
FollowCloseRange: !type:Single
1.0
FollowRange: !type:Single
2.0

- type: entity
name: pig
parent: SimpleMobBase
Expand Down
53 changes: 53 additions & 0 deletions Resources/Prototypes/Loadouts/Generic/items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,56 @@
customColorTint: true
items:
- DrinkVacuumFlask

# Pets
- type: loadout
id: LoadoutItemPetMouse
category: Items
cost: 2
canBeHeirloom: true
items:
- MobMousePet
requirements:
- !type:CharacterItemGroupRequirement
group: LoadoutPets
functions:
- !type:LoadoutMakeFollower

- type: loadout
id: LoadoutItemPetHamster
category: Items
cost: 2
canBeHeirloom: true
items:
- MobHamsterPet
requirements:
- !type:CharacterItemGroupRequirement
group: LoadoutPets
functions:
- !type:LoadoutMakeFollower

- type: loadout
id: LoadoutItemPetMothroach
category: Items
cost: 2
canBeHeirloom: true
items:
- MobMothroachPet
requirements:
- !type:CharacterItemGroupRequirement
group: LoadoutPets
functions:
- !type:LoadoutMakeFollower

- type: loadout
id: LoadoutItemPetCockroach
category: Items
cost: 2
canBeHeirloom: true
items:
- MobCockroachPet
requirements:
- !type:CharacterItemGroupRequirement
group: LoadoutPets
functions:
- !type:LoadoutMakeFollower
Binary file modified Resources/Textures/Logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c198ef2

Please sign in to comment.