serverization??? (#1457)
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Content.Shared._CP14.Demiplane.Components;
|
||||
public sealed partial class CP14DemiplaneTimedDestructionComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public TimeSpan TimeToDestruction = TimeSpan.FromSeconds(130f);
|
||||
public TimeSpan TimeToDestruction = TimeSpan.FromSeconds(240f);
|
||||
|
||||
[DataField, AutoPausedField]
|
||||
public TimeSpan EndTime = TimeSpan.Zero;
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using Content.Shared._CP14.MagicSpellStorage;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpell.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Blocks the target from using magic if they are pacified.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem), typeof(CP14SpellStorageSystem))]
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem))]
|
||||
public sealed partial class CP14MagicEffectPacifiedBlockComponent : Component
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Shared._CP14.MagicRitual.Prototypes;
|
||||
using Content.Shared._CP14.MagicSpell.Spells;
|
||||
using Content.Shared._CP14.MagicSpellStorage;
|
||||
using Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -10,7 +9,7 @@ namespace Content.Shared._CP14.MagicSpell.Components;
|
||||
/// <summary>
|
||||
/// Stores the results and appearance of the magic effect
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem), typeof(CP14SpellStorageSystem))]
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem), typeof(CP14SharedSpellStorageSystem))]
|
||||
public sealed partial class CP14MagicEffectComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Shared._CP14.MagicSpellStorage;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpell.Components;
|
||||
@@ -6,7 +5,7 @@ namespace Content.Shared._CP14.MagicSpell.Components;
|
||||
/// <summary>
|
||||
/// Restricts the use of this action, by spending mana or user requirements.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem), typeof(CP14SpellStorageSystem))]
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem))]
|
||||
public sealed partial class CP14MagicEffectManaCostComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using Content.Shared._CP14.MagicSpellStorage;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpell.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Restricts the use of this action, by spending stamina.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem), typeof(CP14SpellStorageSystem))]
|
||||
[RegisterComponent, Access(typeof(CP14SharedMagicSystem))]
|
||||
public sealed partial class CP14MagicEffectStaminaCostComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Content.Shared._CP14.MagicSpellStorage;
|
||||
|
||||
public abstract partial class CP14SharedSpellStorageSystem : EntitySystem
|
||||
{
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Hands;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpellStorage;
|
||||
|
||||
public sealed partial class CP14SpellStorageSystem
|
||||
{
|
||||
private void InitializeAccess()
|
||||
{
|
||||
SubscribeLocalEvent<CP14SpellStorageAccessHoldingComponent, GotEquippedHandEvent>(OnEquippedHand);
|
||||
|
||||
SubscribeLocalEvent<CP14SpellStorageAccessWearingComponent, ClothingGotEquippedEvent>(OnClothingEquipped);
|
||||
SubscribeLocalEvent<CP14SpellStorageAccessWearingComponent, ClothingGotUnequippedEvent>(OnClothingUnequipped);
|
||||
}
|
||||
|
||||
private void OnEquippedHand(Entity<CP14SpellStorageAccessHoldingComponent> ent, ref GotEquippedHandEvent args)
|
||||
{
|
||||
if (!TryComp<CP14SpellStorageComponent>(ent, out var spellStorage))
|
||||
return;
|
||||
|
||||
TryGrantAccess((ent, spellStorage), args.User);
|
||||
}
|
||||
|
||||
private void OnClothingEquipped(Entity<CP14SpellStorageAccessWearingComponent> ent, ref ClothingGotEquippedEvent args)
|
||||
{
|
||||
ent.Comp.Wearing = true;
|
||||
|
||||
if (!TryComp<CP14SpellStorageComponent>(ent, out var spellStorage))
|
||||
return;
|
||||
|
||||
TryGrantAccess((ent, spellStorage), args.Wearer);
|
||||
}
|
||||
|
||||
private void OnClothingUnequipped(Entity<CP14SpellStorageAccessWearingComponent> ent, ref ClothingGotUnequippedEvent args)
|
||||
{
|
||||
ent.Comp.Wearing = false;
|
||||
|
||||
_actions.RemoveProvidedActions(args.Wearer, ent);
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
using Content.Shared._CP14.MagicSpell.Components;
|
||||
using Content.Shared._CP14.MagicSpell.Events;
|
||||
using Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Mind;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpellStorage;
|
||||
|
||||
/// <summary>
|
||||
/// this part of the system is responsible for storing spells in items, and the methods players use to obtain them.
|
||||
/// </summary>
|
||||
public sealed partial class CP14SpellStorageSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mind = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
InitializeAccess();
|
||||
|
||||
SubscribeLocalEvent<CP14SpellStorageComponent, MapInitEvent>(OnMagicStorageInit);
|
||||
SubscribeLocalEvent<CP14SpellStorageComponent, ComponentShutdown>(OnMagicStorageShutdown);
|
||||
|
||||
SubscribeLocalEvent<CP14SpellStorageUseDamageComponent, CP14SpellFromSpellStorageUsedEvent>(OnSpellUsed);
|
||||
}
|
||||
|
||||
private void OnSpellUsed(Entity<CP14SpellStorageUseDamageComponent> ent, ref CP14SpellFromSpellStorageUsedEvent args)
|
||||
{
|
||||
_damageable.TryChangeDamage(ent, ent.Comp.DamagePerMana * args.Manacost);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When we initialize, we create action entities, and add them to this item.
|
||||
/// </summary>
|
||||
private void OnMagicStorageInit(Entity<CP14SpellStorageComponent> storage, ref MapInitEvent args)
|
||||
{
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
foreach (var spell in storage.Comp.Spells)
|
||||
{
|
||||
var spellEnt = _actionContainer.AddAction(storage, spell);
|
||||
if (spellEnt is null)
|
||||
continue;
|
||||
|
||||
var provided = EntityManager.EnsureComponent<CP14MagicEffectComponent>(spellEnt.Value);
|
||||
provided.SpellStorage = storage;
|
||||
|
||||
storage.Comp.SpellEntities.Add(spellEnt.Value);
|
||||
}
|
||||
|
||||
if (storage.Comp.GrantAccessToSelf)
|
||||
{
|
||||
if (!_mind.TryGetMind(storage.Owner, out var mind, out _))
|
||||
_actions.GrantActions(storage.Owner, storage.Comp.SpellEntities, storage.Owner);
|
||||
else
|
||||
{
|
||||
foreach (var spell in storage.Comp.SpellEntities)
|
||||
{
|
||||
_actionContainer.AddAction(mind, spell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMagicStorageShutdown(Entity<CP14SpellStorageComponent> mStorage, ref ComponentShutdown args)
|
||||
{
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
foreach (var spell in mStorage.Comp.SpellEntities)
|
||||
{
|
||||
QueueDel(spell);
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGrantAccess(Entity<CP14SpellStorageComponent> storage, EntityUid user)
|
||||
{
|
||||
if (!_mind.TryGetMind(user, out var mindId, out var mind))
|
||||
return false;
|
||||
|
||||
if (mind.OwnedEntity is null)
|
||||
return false;
|
||||
|
||||
_actions.GrantActions(user, storage.Comp.SpellEntities, storage.Owner);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Denotes that this item's spells can be accessed while holding it in your hand
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SpellStorageSystem))]
|
||||
public sealed partial class CP14SpellStorageAccessHoldingComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Denotes that this item's spells can be accessed while wearing it on your body
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SpellStorageSystem))]
|
||||
public sealed partial class CP14SpellStorageAccessWearingComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public bool Wearing;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// A component that allows you to store spells in items
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SpellStorageSystem))]
|
||||
public sealed partial class CP14SpellStorageComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Set true when giving starting abilities to creatures in this way
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool GrantAccessToSelf = false;
|
||||
|
||||
/// <summary>
|
||||
/// list of spell prototypes used for initialization.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public List<EntProtoId> Spells = new();
|
||||
|
||||
/// <summary>
|
||||
/// created after the initialization of spell entities.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public List<EntityUid> SpellEntities = new();
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// The component allows you to use actions nested in an object not through hotbar, but through direct interaction with the object.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SpellStorageSystem))]
|
||||
public sealed partial class CP14SpellStorageInteractionComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The selected action will automatically attempt to be used when interacting with the item.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int SelectedAction;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpellStorage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Causes damage to the Spell storage when spells from it are used
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SpellStorageSystem))]
|
||||
public sealed partial class CP14SpellStorageUseDamageComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// the amount of damage this entity will take per unit manacost of the spell used
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public DamageSpecifier DamagePerMana = default!;
|
||||
}
|
||||
Reference in New Issue
Block a user