-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loadout Modular Functions (And Loadout Pets) (#1366)
# Description This PR implements a reflection based system for applying functions directly to entities spawned by loadouts. In order to provide an "Example" use of this system, I have created a "LoadoutMakeFollower" function, which can be applied to a loadout entity that happens to be an NPC with the Follower blackboard, making it follow the player who purchased that loadout. Basically. Pet mouse. The pet mouse will follow its owner. Yes I actually have tested this ingame, and it works great. The longest part about coding this was me spending almost 30 minutes straight wondering why the mouse wasn't following my character, until I remembered that I had to make a special "Pet" mouse variant that had the right HTN root task. This could be extended to other things. I happen to know that Nuclear14 wanted something like this for a Pet Dog. <details><summary><h1>Media</h1></summary> <p> ![image](https://github.com/user-attachments/assets/a18b026b-07a3-4ad7-8cce-4ea4dc4c3036) </p> </details> # Changelog :cl: - add: Loadouts can now apply modular functions to items upon spawning in. - add: A new LoadoutMakeFollower function, which lets you buy NPC followers in loadouts. - add: added Pet Mice, Cockroach, Mothroach, and Hamster to Loadouts. All of which use the new LoadoutMakeFollower function. Co-authored-by: sleepyyapril <[email protected]>
- Loading branch information
1 parent
35c95a5
commit 311b86e
Showing
8 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
Content.Server/Clothing/Systems/LoadoutSystem.Functions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters