-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #500 from Timfa2112/gladiabot-teams
Gladiabot Teams
- Loading branch information
Showing
18 changed files
with
232 additions
and
4 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Content.Client/NPC/Systems/NpcFactionSpriteStateSetterSystem.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,25 @@ | ||
|
||
using Content.Shared.NPC.Components; | ||
using Content.Shared.NPC.Events; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.NPC.Systems; | ||
public sealed partial class NpcFactionSpriteStateSetterSystem : EntitySystem | ||
{ | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeNetworkEvent<NpcFactionAddedEvent>(OnFactionAdded); | ||
} | ||
|
||
private void OnFactionAdded(NpcFactionAddedEvent ev) | ||
{ | ||
if (!TryGetEntity(ev.EntityUid, out var entity) || !TryComp<SpriteComponent>(entity.Value, out var sprite) || !TryComp<NpcFactionSpriteStateSetterComponent>(entity.Value, out var _)|| !TryComp<NpcFactionSelectorComponent>(entity.Value, out var factionSelector)) | ||
return; | ||
|
||
if(factionSelector.SelectableFactions.Contains(ev.FactionID)) | ||
sprite.LayerSetState(0, new (ev.FactionID)); | ||
} | ||
} |
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,59 @@ | ||
using Content.Server.NPC.Components; | ||
using Content.Shared.Database; | ||
using Content.Shared.Popups; | ||
using Content.Shared.Verbs; | ||
using Robust.Shared.Prototypes; | ||
using System.Linq; | ||
using Content.Shared.NPC.Components; | ||
|
||
|
||
namespace Content.Server.NPC.Systems; | ||
public sealed partial class NpcFactionSelectorSystem : EntitySystem | ||
{ | ||
|
||
[Dependency] private readonly SharedPopupSystem _popup = default!; | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
[Dependency] private readonly NpcFactionSystem _factionSystem = default!; | ||
[Dependency] private readonly EntityManager _entityManager = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<NpcFactionSelectorComponent, GetVerbsEvent<Verb>>(OnGetVerb); | ||
} | ||
|
||
private void OnGetVerb(Entity<NpcFactionSelectorComponent> entity, ref GetVerbsEvent<Verb> args) | ||
{ | ||
if (!args.CanAccess || !args.CanInteract || args.Hands == null) | ||
return; | ||
|
||
if (!TryComp<NpcFactionSelectorComponent>(entity, out var factionSelectorComponent) || factionSelectorComponent.SelectableFactions.Count < 2) | ||
return; | ||
|
||
foreach (var type in factionSelectorComponent.SelectableFactions) | ||
{ | ||
var proto = _prototype.Index<NpcFactionPrototype>(type); | ||
|
||
var v = new Verb | ||
{ | ||
Priority = 1, | ||
Category = VerbCategory.SelectFaction, | ||
Text = proto.ID, | ||
Impact = LogImpact.Medium, | ||
DoContactInteraction = true, | ||
Act = () => | ||
{ | ||
_popup.PopupPredicted(Loc.GetString("npcfaction-component-faction-set", ("faction", proto.ID)), entity.Owner, null); | ||
foreach (var type in factionSelectorComponent.SelectableFactions) | ||
{ | ||
_factionSystem.RemoveFaction(entity.Owner, type); | ||
} | ||
|
||
_factionSystem.AddFaction(entity.Owner, proto.ID); | ||
} | ||
}; | ||
args.Verbs.Add(v); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.NPC.Events; | ||
|
||
/// <summary> | ||
/// Raised from client to server to notify a faction was added to an NPC. | ||
/// </summary> | ||
[Serializable, NetSerializable] | ||
public sealed class NpcFactionAddedEvent : EntityEventArgs | ||
{ | ||
public readonly string FactionID; | ||
public readonly NetEntity EntityUid; | ||
|
||
public NpcFactionAddedEvent(NetEntity entity, string factionId) | ||
{ | ||
FactionID = factionId; | ||
EntityUid = entity; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Raised from client to server to notify a faction was removed from an NPC. | ||
/// </summary> | ||
[Serializable, NetSerializable] | ||
public sealed class NpcFactionRemovedEvent : EntityEventArgs | ||
{ | ||
public readonly string FactionID; | ||
public readonly NetEntity EntityUid; | ||
|
||
public NpcFactionRemovedEvent(NetEntity entity, string factionId) | ||
{ | ||
FactionID = factionId; | ||
EntityUid = entity; | ||
} | ||
} |
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,9 @@ | ||
namespace Content.Shared.NPC.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class NpcFactionSelectorComponent : Component | ||
{ | ||
[DataField] | ||
public List<string> SelectableFactions = new(); | ||
} | ||
|
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,7 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.NPC.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class NpcFactionSpriteStateSetterComponent : Component {} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npcfaction-component-faction-set = Faction set to: {$faction} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added
BIN
+1.19 KB
Resources/Textures/Mobs/Silicon/Bots/gladiabot.rsi/GladiabotGreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.19 KB
Resources/Textures/Mobs/Silicon/Bots/gladiabot.rsi/GladiabotYellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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