Dash (#1445)
* dash basic logic + predict spell casts * dash * Update kick.yml * Update CP14SharedMagicSystem.Checks.cs
This commit is contained in:
17
Content.Client/_CP14/Dash/CP14ClientDashSystem.cs
Normal file
17
Content.Client/_CP14/Dash/CP14ClientDashSystem.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Content.Shared._CP14.Dash;
|
||||
|
||||
namespace Content.Client._CP14.Dash;
|
||||
|
||||
public sealed partial class CP14DClientDashSystem : EntitySystem
|
||||
{
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<CP14DashComponent>();
|
||||
while (query.MoveNext(out var uid, out var dash))
|
||||
{
|
||||
SpawnAtPosition(dash.DashEffect, Transform(uid).Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Content.Shared/_CP14/Dash/CP14DashComponent.cs
Normal file
21
Content.Shared/_CP14/Dash/CP14DashComponent.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._CP14.Dash;
|
||||
|
||||
/// <summary>
|
||||
/// This component marks entities that are currently in the dash
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(CP14DashSystem))]
|
||||
public sealed partial class CP14DashComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public EntProtoId DashEffect = "CP14DustEffect";
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier DashSound = new SoundPathSpecifier("/Audio/_CP14/Effects/dash.ogg")
|
||||
{
|
||||
Params = AudioParams.Default.WithVariation(0.05f)
|
||||
};
|
||||
}
|
||||
55
Content.Shared/_CP14/Dash/CP14DashSystem.cs
Normal file
55
Content.Shared/_CP14/Dash/CP14DashSystem.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Shared._CP14.Dash;
|
||||
|
||||
public sealed partial class CP14DashSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14DashComponent, UpdateCanMoveEvent>(OnMoveAttempt);
|
||||
SubscribeLocalEvent<CP14DashComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<CP14DashComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<CP14DashComponent, LandEvent>(OnLand);
|
||||
}
|
||||
|
||||
private void OnShutdown(Entity<CP14DashComponent> ent, ref ComponentShutdown args)
|
||||
{
|
||||
_blocker.UpdateCanMove(ent);
|
||||
}
|
||||
|
||||
private void OnInit(Entity<CP14DashComponent> ent, ref ComponentInit args)
|
||||
{
|
||||
_blocker.UpdateCanMove(ent);
|
||||
}
|
||||
|
||||
private void OnLand(Entity<CP14DashComponent> ent, ref LandEvent args)
|
||||
{
|
||||
RemCompDeferred<CP14DashComponent>(ent);
|
||||
}
|
||||
|
||||
private void OnMoveAttempt(Entity<CP14DashComponent> ent, ref UpdateCanMoveEvent args)
|
||||
{
|
||||
if (ent.Comp.LifeStage > ComponentLifeStage.Running)
|
||||
return;
|
||||
|
||||
//Cant move while dashing
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
public void PerformDash(EntityUid ent, EntityCoordinates targetPosition, float speed = 10f)
|
||||
{
|
||||
EnsureComp<CP14DashComponent>(ent, out var dash);
|
||||
_audio.PlayPredicted(dash.DashSound, ent, ent);
|
||||
_throwing.TryThrow(ent, targetPosition, speed, null, 0f, 10, true, false, false, false, false);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public abstract partial class CP14SharedMagicSystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_magicEnergy.HasEnergy(args.Performer, requiredMana, playerMana, true) && _net.IsServer)
|
||||
if (!_magicEnergy.HasEnergy(args.Performer, requiredMana, playerMana, true))
|
||||
_popup.PopupEntity(Loc.GetString($"cp14-magic-spell-not-enough-mana-cast-warning-{_random.Next(5)}"),
|
||||
args.Performer,
|
||||
args.Performer,
|
||||
@@ -199,9 +199,6 @@ public abstract partial class CP14SharedMagicSystem
|
||||
private void OnVerbalAspectAfterCast(Entity<CP14MagicEffectVerbalAspectComponent> ent,
|
||||
ref CP14MagicEffectConsumeResourceEvent args)
|
||||
{
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
var ev = new CP14SpellSpeechEvent
|
||||
{
|
||||
Performer = args.Performer,
|
||||
@@ -225,9 +222,6 @@ public abstract partial class CP14SharedMagicSystem
|
||||
|
||||
private void OnEmoteEndCast(Entity<CP14MagicEffectEmotingComponent> ent, ref CP14MagicEffectConsumeResourceEvent args)
|
||||
{
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
var ev = new CP14SpellSpeechEvent
|
||||
{
|
||||
Performer = args.Performer,
|
||||
|
||||
@@ -5,14 +5,12 @@ using Content.Shared._CP14.MagicEnergy.Components;
|
||||
using Content.Shared._CP14.MagicSpell.Components;
|
||||
using Content.Shared._CP14.MagicSpell.Events;
|
||||
using Content.Shared._CP14.MagicSpell.Spells;
|
||||
using Content.Shared._CP14.MagicSpellStorage;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -25,7 +23,6 @@ namespace Content.Shared._CP14.MagicSpell;
|
||||
public abstract partial class CP14SharedMagicSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
[Dependency] private readonly SharedCP14MagicEnergySystem _magicEnergy = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
@@ -165,9 +162,6 @@ public abstract partial class CP14SharedMagicSystem : EntitySystem
|
||||
|
||||
private void CastTelegraphy(Entity<CP14MagicEffectComponent> ent, CP14SpellEffectBaseArgs args)
|
||||
{
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
foreach (var effect in ent.Comp.TelegraphyEffects)
|
||||
{
|
||||
effect.Effect(EntityManager, args);
|
||||
@@ -179,9 +173,6 @@ public abstract partial class CP14SharedMagicSystem : EntitySystem
|
||||
var ev = new CP14MagicEffectConsumeResourceEvent(args.User);
|
||||
RaiseLocalEvent(ent, ref ev);
|
||||
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
foreach (var effect in ent.Comp.Effects)
|
||||
{
|
||||
effect.Effect(EntityManager, args);
|
||||
|
||||
20
Content.Shared/_CP14/MagicSpell/Spells/CP14SpellDash.cs
Normal file
20
Content.Shared/_CP14/MagicSpell/Spells/CP14SpellDash.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Content.Shared._CP14.Dash;
|
||||
|
||||
namespace Content.Shared._CP14.MagicSpell.Spells;
|
||||
|
||||
public sealed partial class CP14SpellDash : CP14SpellEffect
|
||||
{
|
||||
[DataField]
|
||||
public float DashSpeed = 10f;
|
||||
public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args)
|
||||
{
|
||||
if (args.User is null)
|
||||
return;
|
||||
if (args.Position is null)
|
||||
return;
|
||||
|
||||
var dashSys = entManager.System<CP14DashSystem>();
|
||||
|
||||
dashSys.PerformDash(args.User.Value, args.Position.Value, DashSpeed);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public sealed partial class CP14SpellProjectile : CP14SpellEffect
|
||||
(float) (random.NextDouble() * 2 - 1) * Spread,
|
||||
(float) (random.NextDouble() * 2 - 1) * Spread));
|
||||
|
||||
var ent = entManager.SpawnAtPosition(Prototype, spawnCoords);
|
||||
var ent = entManager.PredictedSpawnAtPosition(Prototype, spawnCoords);
|
||||
|
||||
var direction = offsetedTargetPoint.ToMapPos(entManager, transform) -
|
||||
spawnCoords.ToMapPos(entManager, transform);
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed partial class CP14SpellSpawnEntitiesOnTargetInRadius : CP14SpellEf
|
||||
var direction = (DirectionFlag) (1 << i);
|
||||
var coords = targetPoint.Value.Offset(direction.AsDir().ToVec());
|
||||
|
||||
entManager.SpawnAtPosition(Spawn, coords);
|
||||
entManager.PredictedSpawnAtPosition(Spawn, coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public sealed partial class CP14SpellSpawnEntityOnTarget : CP14SpellEffect
|
||||
|
||||
foreach (var spawn in Spawns)
|
||||
{
|
||||
entManager.SpawnAtPosition(spawn, targetPoint.Value);
|
||||
entManager.PredictedSpawnAtPosition(spawn, targetPoint.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public sealed partial class CP14SpellSpawnEntityOnUser : CP14SpellEffect
|
||||
|
||||
foreach (var spawn in Spawns)
|
||||
{
|
||||
entManager.SpawnAtPosition(spawn, transformComponent.Coordinates);
|
||||
entManager.PredictedSpawnAtPosition(spawn, transformComponent.Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed partial class CP14SpellSpawnInHandEntity : CP14SpellEffect
|
||||
|
||||
foreach (var spawn in Spawns)
|
||||
{
|
||||
var item = entManager.SpawnAtPosition(spawn, transformComponent.Coordinates);
|
||||
var item = entManager.PredictedSpawnAtPosition(spawn, transformComponent.Coordinates);
|
||||
if (!handSystem.TryPickupAnyHand(args.Target.Value, item) && DeleteIfCantPickup)
|
||||
entManager.QueueDeleteEntity(item);
|
||||
}
|
||||
|
||||
@@ -101,4 +101,9 @@
|
||||
- files: ["moon_strike1.ogg", "moon_strike2.ogg", "moon_strike3.ogg", "moon_strike4.ogg"]
|
||||
license: "CC-BY-4.0"
|
||||
copyright: 'Created by EminYILDIRIM on Freesound.org'
|
||||
source: "https://freesound.org/people/EminYILDIRIM/sounds/668244/"
|
||||
source: "https://freesound.org/people/EminYILDIRIM/sounds/668244/"
|
||||
|
||||
- files: ["dash.ogg"]
|
||||
license: "CC-BY-4.0"
|
||||
copyright: 'Created by qubodup on Freesound.org'
|
||||
source: "https://freesound.org/people/qubodup/sounds/714258/"
|
||||
BIN
Resources/Audio/_CP14/Effects/dash.ogg
Normal file
BIN
Resources/Audio/_CP14/Effects/dash.ogg
Normal file
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
- type: entity
|
||||
id: CP14ActionSpellDash
|
||||
parent: CP14ActionSpellBase
|
||||
name: Dash
|
||||
description: You make a quick dash to the chosen position to quickly close the distance or dodge danger.
|
||||
components:
|
||||
- type: CP14MagicEffectStaminaCost
|
||||
stamina: 40
|
||||
- type: CP14MagicEffect
|
||||
effects:
|
||||
- !type:CP14SpellDash
|
||||
dashSpeed: 20
|
||||
- type: Action
|
||||
icon:
|
||||
sprite: _CP14/Actions/Spells/physical.rsi
|
||||
state: dash
|
||||
- type: TargetAction
|
||||
checkCanAccess: false
|
||||
range: 3.5
|
||||
- type: WorldTargetAction
|
||||
event: !type:CP14WorldTargetActionEvent
|
||||
cooldown: 5
|
||||
@@ -20,6 +20,17 @@
|
||||
- !type:AddAction
|
||||
action: CP14ActionSpellSprint
|
||||
|
||||
- type: cp14Skill
|
||||
id: CP14ActionSpellDash
|
||||
skillUiPosition: 0, 4
|
||||
tree: Atlethic
|
||||
icon:
|
||||
sprite: _CP14/Actions/Spells/physical.rsi
|
||||
state: dash
|
||||
effects:
|
||||
- !type:AddAction
|
||||
action: CP14ActionSpellDash
|
||||
|
||||
- type: cp14Skill
|
||||
id: CP14ActionSpellSprintGoblin
|
||||
skillUiPosition: 2, 2
|
||||
|
||||
BIN
Resources/Textures/_CP14/Actions/Spells/physical.rsi/dash.png
Normal file
BIN
Resources/Textures/_CP14/Actions/Spells/physical.rsi/dash.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 350 B |
@@ -18,6 +18,9 @@
|
||||
},
|
||||
{
|
||||
"name": "kick_skull"
|
||||
},
|
||||
{
|
||||
"name": "dash"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user