Merge remote-tracking branch 'upstream/master' into ups
This commit is contained in:
24
Content.Server/_White/Alert/Click/AcceptOffer.cs
Normal file
24
Content.Server/_White/Alert/Click/AcceptOffer.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Content.Server._White.OfferItem;
|
||||
using Content.Shared._White.OfferItem;
|
||||
using Content.Shared.Alert;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server._White.Alert.Click;
|
||||
|
||||
/// <summary>
|
||||
/// Accepting the offer and receive item
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class AcceptOffer : IAlertClick
|
||||
{
|
||||
public void AlertClicked(EntityUid player)
|
||||
{
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entManager.TryGetComponent(player, out OfferItemComponent? offerItem))
|
||||
{
|
||||
entManager.System<OfferItemSystem>().Receive(player, offerItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
83
Content.Server/_White/OfferItem/OfferItemSystem.cs
Normal file
83
Content.Server/_White/OfferItem/OfferItemSystem.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared._White.OfferItem;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.OfferItem;
|
||||
|
||||
public sealed class OfferItemSystem : SharedOfferItemSystem
|
||||
{
|
||||
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<OfferItemComponent>();
|
||||
while (query.MoveNext(out var uid, out var offerItem))
|
||||
{
|
||||
if (!TryComp<HandsComponent>(uid, out var hands) || hands.ActiveHand == null)
|
||||
continue;
|
||||
|
||||
if (offerItem.Hand != null &&
|
||||
hands.Hands[offerItem.Hand].HeldEntity == null)
|
||||
{
|
||||
if (offerItem.Target != null)
|
||||
{
|
||||
UnReceive(offerItem.Target.Value, offerItem: offerItem);
|
||||
offerItem.IsInOfferMode = false;
|
||||
Dirty(uid, offerItem);
|
||||
}
|
||||
else
|
||||
UnOffer(uid, offerItem);
|
||||
}
|
||||
|
||||
if (!offerItem.IsInReceiveMode)
|
||||
{
|
||||
_alertsSystem.ClearAlert(uid, AlertType.Offer);
|
||||
continue;
|
||||
}
|
||||
|
||||
_alertsSystem.ShowAlert(uid, AlertType.Offer);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accepting the offer and receive item
|
||||
/// </summary>
|
||||
public void Receive(EntityUid uid, OfferItemComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component) ||
|
||||
!TryComp<OfferItemComponent>(component.Target, out var offerItem) ||
|
||||
offerItem.Hand == null ||
|
||||
component.Target == null ||
|
||||
!TryComp<HandsComponent>(uid, out var hands))
|
||||
return;
|
||||
|
||||
if (offerItem.Item != null)
|
||||
{
|
||||
if (!_hands.TryPickup(uid, offerItem.Item.Value, handsComp: hands))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("offer-item-full-hand"), uid, uid);
|
||||
return;
|
||||
}
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("offer-item-give",
|
||||
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
|
||||
("target", Identity.Entity(uid, EntityManager))), component.Target.Value, component.Target.Value);
|
||||
_popup.PopupEntity(Loc.GetString("offer-item-give-other",
|
||||
("user", Identity.Entity(component.Target.Value, EntityManager)),
|
||||
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
|
||||
("target", Identity.Entity(uid, EntityManager)))
|
||||
, component.Target.Value, Filter.PvsExcept(component.Target.Value, entityManager: EntityManager), true);
|
||||
}
|
||||
|
||||
offerItem.Item = null;
|
||||
UnReceive(uid, component, offerItem);
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,12 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
if (!userHasMind)
|
||||
return;
|
||||
|
||||
SwapComponent<WizardComponent>(uid, target);
|
||||
SwapComponent<RevolutionaryComponent>(uid, target);
|
||||
SwapComponent<HeadRevolutionaryComponent>(uid, target);
|
||||
SwapComponent<PentagramComponent>(uid, target);
|
||||
SwapComponent<CultistComponent>(uid, target);
|
||||
|
||||
_mindSystem.TransferTo(mindId, target, mind: mind);
|
||||
|
||||
if (targetHasMind)
|
||||
@@ -193,12 +199,6 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
_standing.TryLieDown(target);
|
||||
|
||||
Cast(msg);
|
||||
|
||||
SwapComponent<WizardComponent>(uid, target);
|
||||
SwapComponent<RevolutionaryComponent>(uid, target);
|
||||
SwapComponent<HeadRevolutionaryComponent>(uid, target);
|
||||
SwapComponent<PentagramComponent>(uid, target);
|
||||
SwapComponent<CultistComponent>(uid, target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -159,7 +159,8 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
var query = QueryActiveRules();
|
||||
while (query.MoveNext(out _, out _, out var wizardRule, out _))
|
||||
{
|
||||
AddRole(mindId, mind, wizardRule);
|
||||
if (!AddRole(mindId, mind, wizardRule))
|
||||
return;
|
||||
|
||||
if (mind.Session is not { } playerSession)
|
||||
return;
|
||||
@@ -171,10 +172,10 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRole(EntityUid mindId, MindComponent mind, WizardRuleComponent wizardRule)
|
||||
private bool AddRole(EntityUid mindId, MindComponent mind, WizardRuleComponent wizardRule)
|
||||
{
|
||||
if (_roles.MindHasRole<WizardRoleComponent>(mindId))
|
||||
return;
|
||||
return false;
|
||||
|
||||
wizardRule.WizardMinds.Add(mindId);
|
||||
|
||||
@@ -182,6 +183,8 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
_roles.MindAddRole(mindId, new WizardRoleComponent {PrototypeId = role});
|
||||
|
||||
GiveObjectives(mindId, mind, wizardRule);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GiveObjectives(EntityUid mindId, MindComponent mind, WizardRuleComponent wizardRule)
|
||||
@@ -280,30 +283,35 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
|
||||
private HumanoidCharacterProfile SetupWizardEntity(
|
||||
EntityUid mob,
|
||||
StartingGearPrototype gear,
|
||||
bool endRoundOnDeath)
|
||||
bool endRoundOnDeath,
|
||||
bool randomPtofile = true)
|
||||
{
|
||||
EnsureComp<WizardComponent>(mob, out var component);
|
||||
component.EndRoundOnDeath = endRoundOnDeath;
|
||||
EnsureComp<GlobalAntagonistComponent>(mob).AntagonistPrototype = "globalAntagonistWizard";
|
||||
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var profile = HumanoidCharacterProfile.RandomWithSpecies().WithAge(random.Next(component.MinAge, component.MaxAge));
|
||||
if (randomPtofile)
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var profile = HumanoidCharacterProfile.RandomWithSpecies()
|
||||
.WithAge(random.Next(component.MinAge, component.MaxAge));
|
||||
|
||||
var color = Color.FromHex(GetRandom(component.Color, "#B5B8B1"));
|
||||
var hair = GetRandom(component.Hair, "HumanHairAfricanPigtails");
|
||||
var facialHair = GetRandom(component.FacialHair, "HumanFacialHairAbe");
|
||||
profile = profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
var color = Color.FromHex(GetRandom(component.Color, "#B5B8B1"));
|
||||
var hair = GetRandom(component.Hair, "HumanHairAfricanPigtails");
|
||||
var facialHair = GetRandom(component.FacialHair, "HumanFacialHairAbe");
|
||||
profile = profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.Appearance.WithHairStyleName(hair))
|
||||
.Appearance.WithFacialHairStyleName(facialHair))
|
||||
.Appearance.WithHairColor(color))
|
||||
.Appearance.WithFacialHairColor(color));
|
||||
profile.WithCharacterAppearance(
|
||||
profile.WithCharacterAppearance(
|
||||
profile.Appearance.WithHairStyleName(hair))
|
||||
.Appearance.WithFacialHairStyleName(facialHair))
|
||||
.Appearance.WithHairColor(color))
|
||||
.Appearance.WithFacialHairColor(color));
|
||||
|
||||
_humanoid.LoadProfile(mob, profile);
|
||||
_humanoid.LoadProfile(mob, profile);
|
||||
|
||||
_metaData.SetEntityName(mob, GetRandom(component.Name, ""));
|
||||
_metaData.SetEntityName(mob, GetRandom(component.Name, ""));
|
||||
}
|
||||
|
||||
_stationSpawning.EquipStartingGear(mob, gear);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user