Skip to content

Commit 528ea10

Browse files
committed
new BUI for planting
1 parent 7876e52 commit 528ea10

File tree

7 files changed

+65
-37
lines changed

7 files changed

+65
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
2+
3+
using Content.Shared.Stacks;
4+
using Robust.Shared.Prototypes;
5+
using Robust.Shared.Serialization;
6+
using Robust.Shared.Utility;
7+
8+
namespace Content.Shared.SS220.CultYogg.MiGo;
9+
10+
[Prototype("cultYoggSeeds")]
11+
[Serializable, NetSerializable]
12+
public sealed partial class CultYoggSeedsPrototype : IPrototype
13+
{
14+
[IdDataField]
15+
public string ID { get; private set; } = default!;
16+
17+
/// <summary>
18+
/// What type of seed we will plant
19+
/// </summary>
20+
[DataField("seed", required: true)]
21+
public EntProtoId SeedProtoId { get; private set; }
22+
23+
/// <summary>
24+
/// What type of plant we will get in result
25+
/// Required to see result
26+
/// </summary>
27+
[DataField("plant")]
28+
public EntProtoId PlantProtoId { get; private set; }
29+
}

Content.Shared/SS220/CultYogg/MiGo/MiGoErectBuiState.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ public sealed class MiGoErectBuiState : BoundUserInterfaceState
1414
}
1515

1616
[Serializable, NetSerializable]
17-
public enum MiGoErectUiKey : byte
17+
public enum MiGoUiKey : byte
1818
{
19-
Key
19+
Erect,
20+
Plant
2021
}
2122

2223
[Serializable, NetSerializable]
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
22

3-
using Content.Shared.SS220.CultYogg.Buildings;
4-
using Robust.Shared.Map;
5-
using Robust.Shared.Prototypes;
63
using Robust.Shared.Serialization;
74

85
namespace Content.Shared.SS220.CultYogg.MiGo;
96

107
[Serializable, NetSerializable]
118
public sealed class MiGoPlantBuiState : BoundUserInterfaceState
129
{
13-
public List<CultYoggBuildingPrototype> Seeds = [];
14-
}
15-
16-
[Serializable, NetSerializable]
17-
public enum MiGoPlantUiKey : byte
18-
{
19-
Key
10+
public List<CultYoggSeedsPrototype> Seeds = [];
2011
}

Content.Shared/SS220/CultYogg/MiGo/SharedMiGoErectSystem.cs

+1-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using Robust.Shared.Timing;
2121
using Robust.Shared.Utility;
2222
using System.Diagnostics.CodeAnalysis;
23-
using System.Linq;
2423

2524
namespace Content.Shared.SS220.CultYogg.MiGo;
2625

@@ -46,7 +45,6 @@ public sealed class SharedMiGoErectSystem : EntitySystem
4645
/// <inheritdoc/>
4746
public override void Initialize()
4847
{
49-
SubscribeLocalEvent<MiGoComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
5048
SubscribeLocalEvent<MiGoComponent, MiGoErectBuildMessage>(OnBuildMessage);
5149
SubscribeLocalEvent<MiGoComponent, MiGoErectEraseMessage>(OnEraseMessage);
5250
SubscribeLocalEvent<MiGoComponent, MiGoErectDoAfterEvent>(OnDoAfterErect);
@@ -62,15 +60,7 @@ public override void Initialize()
6260

6361
public void OpenUI(Entity<MiGoComponent> entity, ActorComponent actor)
6462
{
65-
_userInterfaceSystem.TryToggleUi(entity.Owner, MiGoErectUiKey.Key, actor.PlayerSession);
66-
}
67-
68-
private void OnBoundUIOpened(Entity<MiGoComponent> entity, ref BoundUIOpenedEvent args)
69-
{
70-
_userInterfaceSystem.SetUiState(args.Entity, MiGoErectUiKey.Key, new MiGoErectBuiState()
71-
{
72-
Buildings = _prototypeManager.GetInstances<CultYoggBuildingPrototype>().Values.ToList(),
73-
});
63+
_userInterfaceSystem.TryToggleUi(entity.Owner, MiGoUiKey.Erect, actor.PlayerSession);
7464
}
7565

7666
private void OnBuildMessage(Entity<MiGoComponent> entity, ref MiGoErectBuildMessage args)
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
22

3-
using Content.Shared.SS220.CultYogg.Buildings;
43
using Robust.Shared.Player;
54
using Robust.Shared.Prototypes;
65
using System.Linq;
@@ -18,18 +17,8 @@ public override void Initialize()
1817
//SubscribeLocalEvent<MiGoComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
1918
}
2019

21-
/*
2220
public void OpenUI(Entity<MiGoComponent> entity, ActorComponent actor)
2321
{
24-
_userInterfaceSystem.TryToggleUi(entity.Owner, MiGoPlantUiKey.Key, actor.PlayerSession);
25-
}
26-
*/
27-
28-
private void OnBoundUIOpened(Entity<MiGoComponent> entity, ref BoundUIOpenedEvent args)
29-
{
30-
_userInterfaceSystem.SetUiState(args.Entity, MiGoPlantUiKey.Key, new MiGoPlantBuiState()
31-
{
32-
Seeds = _prototypeManager.GetInstances<CultYoggBuildingPrototype>().Values.ToList(),
33-
});
22+
_userInterfaceSystem.TryToggleUi(entity.Owner, MiGoUiKey.Plant, actor.PlayerSession);
3423
}
3524
}

Content.Shared/SS220/CultYogg/MiGo/SharedMiGoSystem.cs

+27-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
using System.Linq;
2323
using Content.Shared.Item;
2424
using Content.Shared.Hands;
25+
using Content.Shared.SS220.CultYogg.Buildings;
26+
using Robust.Shared.Prototypes;
2527

2628

2729
namespace Content.Shared.SS220.CultYogg.MiGo;
@@ -35,13 +37,16 @@ public abstract class SharedMiGoSystem : EntitySystem
3537
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
3638
[Dependency] private readonly IGameTiming _timing = default!;
3739
[Dependency] private readonly SharedMiGoErectSystem _miGoErectSystem = default!;
40+
[Dependency] private readonly SharedMiGoPlantSystem _miGoPlantSystem = default!;
3841
[Dependency] private readonly SharedTransformSystem _transform = default!;
3942
[Dependency] private readonly SharedCultYoggHealSystem _heal = default!;
4043
[Dependency] private readonly SharedAudioSystem _audio = default!;
4144
[Dependency] private readonly SharedPopupSystem _popup = default!;
4245
[Dependency] private readonly MobStateSystem _mobState = default!;
4346
[Dependency] private readonly AlertsSystem _alerts = default!;
4447
[Dependency] private readonly SharedEyeSystem _eye = default!;
48+
[Dependency] private readonly SharedUserInterfaceSystem _userInterfaceSystem = default!;
49+
[Dependency] private readonly IPrototypeManager _proto = default!;
4550

4651

4752
//[Dependency] private readonly CultYoggRuleSystem _cultYoggRule = default!; //maybe use this for enslavement
@@ -68,6 +73,8 @@ public override void Initialize()
6873
SubscribeLocalEvent<MiGoComponent, ThrowAttemptEvent>(OnThrowAttempt);
6974
SubscribeLocalEvent<MiGoComponent, BeingUsedAttemptEvent>(OnBeingUsedAttempt);
7075
SubscribeLocalEvent<MiGoComponent, GettingPickedUpAttemptEvent>(OnGettingPickedUpAttempt);
76+
77+
SubscribeLocalEvent<MiGoComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
7178
}
7279

7380
protected virtual void OnCompInit(Entity<MiGoComponent> uid, ref ComponentStartup args)
@@ -80,7 +87,26 @@ protected virtual void OnCompInit(Entity<MiGoComponent> uid, ref ComponentStartu
8087
_actions.AddAction(uid, ref uid.Comp.MiGoSacrificeActionEntity, uid.Comp.MiGoSacrificeAction);
8188
}
8289

90+
private void OnBoundUIOpened(Entity<MiGoComponent> entity, ref BoundUIOpenedEvent args)
91+
{
92+
if (args.UiKey.ToString() == "Erect")
93+
{
94+
_userInterfaceSystem.SetUiState(args.Entity, args.UiKey, new MiGoErectBuiState()
95+
{
96+
Buildings = _proto.GetInstances<CultYoggBuildingPrototype>().Values.ToList(),
97+
});
98+
return;
99+
}
83100

101+
if (args.UiKey.ToString() == "Plant")
102+
{
103+
_userInterfaceSystem.SetUiState(args.Entity, args.UiKey, new MiGoPlantBuiState()
104+
{
105+
Seeds = _proto.GetInstances<CultYoggSeedsPrototype>().Values.ToList(),
106+
});
107+
return;
108+
}
109+
}
84110

85111
#region Heal
86112
private void MiGoHeal(Entity<MiGoComponent> uid, ref MiGoHealEvent args)
@@ -128,7 +154,7 @@ private void MiGoPlant(Entity<MiGoComponent> entity, ref MiGoPlantEvent args)
128154
if (!entity.Comp.IsPhysicalForm)
129155
return;
130156

131-
_miGoErectSystem.OpenUI(entity, actor);
157+
_miGoPlantSystem.OpenUI(entity, actor);
132158
}
133159
#endregion
134160

Resources/Prototypes/SS220/Entities/Mobs/NPCs/CultYogg/migo.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
voice: forester
3232
- type: UserInterface
3333
interfaces:
34-
enum.MiGoErectUiKey.Key:
34+
enum.MiGoUiKey.Erect:
3535
type: MiGoErectBoundUserInterface
36+
enum.MiGoUiKey.Plant:
37+
type: FungusMachineBoundUserInterface
3638
- type: ShowCultYoggIcons
3739
- type: NpcFactionMember
3840
factions:

0 commit comments

Comments
 (0)