Залью спеллы потестить, мне похуй ПР НОМЕР 156
* refactor CheZaHuetaMagicSystem * эщкере * alt-spells system. lmb, rmb, alt-click * fix * ChargeSpellsIndicator + Visual(CheZaHueta) * Custom charge effect for spell * Custom MaxChargeLevel * Finally. Alt spells seems to work!! Need to start do spells and gamerule * fuckkk * fix crash, actually burn scroll.. * some fixes blyat * ArcSpell * очередная CheZaHuetaSystem, ForceSpell * ONI'SOMA! * mraow * prepare this LMAO * Yebanyy rot etogo kazino blyat! - CardsSpell * forcewall * nig * blink * Ethereal Jaunt * игра говно * Блядина * ну на еще спеллов * blyadina * да иди ты нахуй БЛЯДЬ * кто прочитал, тот сдохнет. сделай 5 репостов чтобы выжить.... * icons * та ваще поебать * одежда
This commit is contained in:
@@ -22,6 +22,7 @@ using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Graphics.RSI;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Client.Actions.ActionsSystem;
|
||||
@@ -29,8 +30,7 @@ using static Content.Client.UserInterface.Systems.Actions.Windows.ActionsWindow;
|
||||
using static Robust.Client.UserInterface.Control;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
using static Robust.Client.UserInterface.Controls.LineEdit;
|
||||
using static Robust.Client.UserInterface.Controls.MultiselectOptionButton<
|
||||
Content.Client.UserInterface.Systems.Actions.Windows.ActionsWindow.Filters>;
|
||||
using static Robust.Client.UserInterface.Controls.MultiselectOptionButton<Content.Client.UserInterface.Systems.Actions.Windows.ActionsWindow.Filters>;
|
||||
using static Robust.Client.UserInterface.Controls.TextureRect;
|
||||
using static Robust.Shared.Input.Binding.PointerInputCmdHandler;
|
||||
|
||||
@@ -128,25 +128,45 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
}
|
||||
|
||||
builder
|
||||
.Bind(ContentKeyFunctions.OpenActionsMenu,
|
||||
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
||||
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(TargetingOnUse, outsidePrediction: true),
|
||||
typeof(ConstructionSystem), typeof(DragDropSystem))
|
||||
.BindBefore(EngineKeyFunctions.UIRightClick, new PointerInputCmdHandler(TargetingCancel, outsidePrediction: true))
|
||||
.Bind(ContentKeyFunctions.OpenActionsMenu, InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
||||
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(TargetingOnUse, outsidePrediction: true), typeof(ConstructionSystem), typeof(DragDropSystem))
|
||||
.BindBefore(ContentKeyFunctions.AltActivateItemInWorld, new PointerInputCmdHandler(AltUse, outsidePrediction: true))
|
||||
.Register<ActionUIController>();
|
||||
}
|
||||
|
||||
private bool TargetingCancel(in PointerInputCmdArgs args)
|
||||
private bool AltUse(in PointerInputCmdArgs args)
|
||||
{
|
||||
if (!_timing.IsFirstTimePredicted)
|
||||
if (!_timing.IsFirstTimePredicted || _actionsSystem == null || SelectingTargetFor is not { } actionId)
|
||||
return false;
|
||||
|
||||
// only do something for actual target-based actions
|
||||
if (SelectingTargetFor == null)
|
||||
if (_playerManager.LocalEntity is not { } user)
|
||||
return false;
|
||||
|
||||
StopTargeting();
|
||||
return true;
|
||||
if (!EntityManager.TryGetComponent(user, out ActionsComponent? comp))
|
||||
return false;
|
||||
|
||||
if (!_actionsSystem.TryGetActionData(actionId, out var baseAction) ||
|
||||
baseAction is not BaseTargetActionComponent action || !action.IsAltEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is the action currently valid?
|
||||
if (!action.Enabled
|
||||
|| action is { Charges: 0, RenewCharges: false }
|
||||
|| action.Cooldown.HasValue && action.Cooldown.Value.End > _timing.CurTime)
|
||||
{
|
||||
// The user is targeting with this action, but it is not valid. Maybe mark this click as
|
||||
// handled and prevent further interactions.
|
||||
return !action.InteractOnMiss;
|
||||
}
|
||||
|
||||
return action switch
|
||||
{
|
||||
WorldTargetActionComponent mapTarget => TryTargetWorld(args.Coordinates, actionId, mapTarget, user, comp,
|
||||
ActionUseType.AltUse, target: args.EntityUid) || !mapTarget.InteractOnMiss,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -179,28 +199,23 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
return !action.InteractOnMiss;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
return action switch
|
||||
{
|
||||
case WorldTargetActionComponent mapTarget:
|
||||
return TryTargetWorld(args, actionId, mapTarget, user, comp) || !mapTarget.InteractOnMiss;
|
||||
|
||||
case EntityTargetActionComponent entTarget:
|
||||
return TryTargetEntity(args, actionId, entTarget, user, comp) || !entTarget.InteractOnMiss;
|
||||
|
||||
default:
|
||||
Logger.Error($"Unknown targeting action: {actionId.GetType()}");
|
||||
return false;
|
||||
}
|
||||
WorldTargetActionComponent mapTarget => TryTargetWorld(args.Coordinates, actionId, mapTarget, user, comp) ||
|
||||
!mapTarget.InteractOnMiss,
|
||||
EntityTargetActionComponent entTarget => TryTargetEntity(args.EntityUid, actionId, entTarget, user, comp) ||
|
||||
!entTarget.InteractOnMiss,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
private bool TryTargetWorld(in PointerInputCmdArgs args, EntityUid actionId, WorldTargetActionComponent action, EntityUid user, ActionsComponent actionComp)
|
||||
public bool TryTargetWorld(EntityCoordinates coordinates, EntityUid actionId, WorldTargetActionComponent action,
|
||||
EntityUid user, ActionsComponent actionComp, ActionUseType type = ActionUseType.Default, int chargeLevel = 0, EntityUid? target = default)
|
||||
{
|
||||
if (_actionsSystem == null)
|
||||
return false;
|
||||
|
||||
var coords = args.Coordinates;
|
||||
|
||||
if (!_actionsSystem.ValidateWorldTarget(user, coords, action))
|
||||
if (!_actionsSystem.ValidateWorldTarget(user, coordinates, action))
|
||||
{
|
||||
// Invalid target.
|
||||
if (action.DeselectOnMiss)
|
||||
@@ -213,14 +228,24 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
{
|
||||
if (action.Event != null)
|
||||
{
|
||||
action.Event.Target = coords;
|
||||
action.Event.Target = coordinates;
|
||||
action.Event.Performer = user;
|
||||
}
|
||||
|
||||
_actionsSystem.PerformAction(user, actionComp, actionId, action, action.Event, _timing.CurTime);
|
||||
}
|
||||
else
|
||||
EntityManager.RaisePredictiveEvent(new RequestPerformActionEvent(EntityManager.GetNetEntity(actionId), EntityManager.GetNetCoordinates(coords)));
|
||||
{
|
||||
var msg = new RequestPerformActionEvent(EntityManager.GetNetEntity(actionId), EntityManager.GetNetCoordinates(coordinates))
|
||||
{
|
||||
ActionUseType = type,
|
||||
ChargeLevel = chargeLevel,
|
||||
EntityTarget = EntityManager.GetNetEntity(target)
|
||||
};
|
||||
|
||||
EntityManager.RaisePredictiveEvent(msg);
|
||||
}
|
||||
|
||||
|
||||
if (!action.Repeat)
|
||||
StopTargeting();
|
||||
@@ -228,14 +253,12 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryTargetEntity(in PointerInputCmdArgs args, EntityUid actionId, EntityTargetActionComponent action, EntityUid user, ActionsComponent actionComp)
|
||||
public bool TryTargetEntity(EntityUid uid, EntityUid actionId, EntityTargetActionComponent action, EntityUid user, ActionsComponent actionComp, ActionUseType type = ActionUseType.Default)
|
||||
{
|
||||
if (_actionsSystem == null)
|
||||
return false;
|
||||
|
||||
var entity = args.EntityUid;
|
||||
|
||||
if (!_actionsSystem.ValidateEntityTarget(user, entity, action))
|
||||
if (!_actionsSystem.ValidateEntityTarget(user, uid, action))
|
||||
{
|
||||
if (action.DeselectOnMiss)
|
||||
StopTargeting();
|
||||
@@ -247,14 +270,21 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
{
|
||||
if (action.Event != null)
|
||||
{
|
||||
action.Event.Target = entity;
|
||||
action.Event.Target = uid;
|
||||
action.Event.Performer = user;
|
||||
}
|
||||
|
||||
_actionsSystem.PerformAction(user, actionComp, actionId, action, action.Event, _timing.CurTime);
|
||||
}
|
||||
else
|
||||
EntityManager.RaisePredictiveEvent(new RequestPerformActionEvent(EntityManager.GetNetEntity(actionId), EntityManager.GetNetEntity(args.EntityUid)));
|
||||
{
|
||||
var msg = new RequestPerformActionEvent(EntityManager.GetNetEntity(actionId), EntityManager.GetNetEntity(uid))
|
||||
{
|
||||
ActionUseType = type
|
||||
};
|
||||
|
||||
EntityManager.RaisePredictiveEvent(msg);
|
||||
}
|
||||
|
||||
if (!action.Repeat)
|
||||
StopTargeting();
|
||||
@@ -409,12 +439,6 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
};
|
||||
}
|
||||
|
||||
private void ClearList()
|
||||
{
|
||||
if (_window?.Disposed == false)
|
||||
_window.ResultsGrid.RemoveAllChildren();
|
||||
}
|
||||
|
||||
private void PopulateActions(IEnumerable<(EntityUid Id, BaseActionComponent Comp)> actions)
|
||||
{
|
||||
if (_window is not { Disposed: false, IsOpen: true })
|
||||
@@ -432,7 +456,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
existing.Add(button);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
foreach (var action in actions)
|
||||
{
|
||||
if (i < existing.Count)
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
using Content.Client.Actions;
|
||||
using Content.Shared._White.Wizard;
|
||||
using Content.Shared._White.Wizard.Charging;
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions;
|
||||
|
||||
public sealed class ChargeActionSystem : SharedChargingSystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly ActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
|
||||
[Dependency] private readonly InputSystem _inputSystem = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||
|
||||
private ActionUIController? _controller;
|
||||
|
||||
public event Action<bool>? ChargingUpdated;
|
||||
|
||||
private bool _charging;
|
||||
private bool _prevCharging;
|
||||
|
||||
private float _chargeTime;
|
||||
private int _chargeLevel;
|
||||
private int _prevChargeLevel;
|
||||
|
||||
private bool _isChargingPlaying;
|
||||
private bool _isChargedPlaying;
|
||||
|
||||
private const float LevelChargeTime = 1.5f;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_controller = _uiManager.GetUIController<ActionUIController>();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
if (_playerManager.LocalEntity is not { } user)
|
||||
return;
|
||||
|
||||
if (!_timing.IsFirstTimePredicted || _controller == null || _controller.SelectingTargetFor is not { } actionId)
|
||||
return;
|
||||
|
||||
if (!_actionsSystem.TryGetActionData(actionId, out var baseAction) ||
|
||||
baseAction is not BaseTargetActionComponent action || !action.IsChargeEnabled)
|
||||
return;
|
||||
|
||||
if (!action.Enabled
|
||||
|| action is { Charges: 0, RenewCharges: false }
|
||||
|| action.Cooldown.HasValue && action.Cooldown.Value.End > _timing.CurTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var altDown = _inputSystem.CmdStates.GetState(EngineKeyFunctions.UseSecondary);
|
||||
switch (altDown)
|
||||
{
|
||||
case BoundKeyState.Down:
|
||||
_prevCharging = _charging;
|
||||
_charging = true;
|
||||
_chargeTime += frameTime;
|
||||
_chargeLevel = (int) (_chargeTime / LevelChargeTime) + 1;
|
||||
_chargeLevel = Math.Clamp(_chargeLevel, 1, action.MaxChargeLevel);
|
||||
break;
|
||||
case BoundKeyState.Up when _charging:
|
||||
_prevCharging = _charging;
|
||||
_charging = false;
|
||||
_chargeTime = 0f;
|
||||
_isChargingPlaying = false;
|
||||
_isChargedPlaying = false;
|
||||
|
||||
HandleAction(actionId, action, user, _chargeLevel);
|
||||
_chargeLevel = 0;
|
||||
|
||||
RaiseNetworkEvent(new RequestAudioSpellStop());
|
||||
RaiseNetworkEvent(new RemoveWizardChargeEvent());
|
||||
break;
|
||||
case BoundKeyState.Up:
|
||||
_prevCharging = _charging;
|
||||
_chargeLevel = 0;
|
||||
_charging = false;
|
||||
_chargeTime = 0f;
|
||||
_isChargingPlaying = false;
|
||||
_isChargedPlaying = false;
|
||||
|
||||
RaiseNetworkEvent(new RequestAudioSpellStop());
|
||||
RaiseNetworkEvent(new RemoveWizardChargeEvent());
|
||||
break;
|
||||
}
|
||||
|
||||
if (_chargeLevel != _prevChargeLevel)
|
||||
{
|
||||
if (_chargeLevel > 0 && _charging)
|
||||
{
|
||||
RaiseNetworkEvent(new AddWizardChargeEvent(action.ChargeProto));
|
||||
}
|
||||
_prevChargeLevel = _chargeLevel;
|
||||
}
|
||||
|
||||
if (_prevCharging != _charging)
|
||||
{
|
||||
ChargingUpdated?.Invoke(_charging);
|
||||
}
|
||||
|
||||
if (_charging && !_isChargingPlaying)
|
||||
{
|
||||
_isChargingPlaying = true;
|
||||
RaiseNetworkEvent(new RequestSpellChargingAudio(action.ChargingSound, action.LoopCharging));
|
||||
}
|
||||
|
||||
if (_chargeLevel >= action.MaxChargeLevel && !_isChargedPlaying && _charging)
|
||||
{
|
||||
_isChargedPlaying = true;
|
||||
RaiseNetworkEvent(new RequestSpellChargedAudio(action.MaxChargedSound, action.LoopMaxCharged));
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleAction(EntityUid actionId, BaseTargetActionComponent action, EntityUid user, int chargeLevel)
|
||||
{
|
||||
var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition);
|
||||
if (mousePos.MapId == MapId.Nullspace)
|
||||
return;
|
||||
|
||||
var coordinates = EntityCoordinates.FromMap(_mapManager.TryFindGridAt(mousePos, out var gridUid, out _)
|
||||
? gridUid
|
||||
: _mapManager.GetMapEntityId(mousePos.MapId), mousePos, _transformSystem, EntityManager);
|
||||
|
||||
if (!EntityManager.TryGetComponent(user, out ActionsComponent? comp))
|
||||
return;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case WorldTargetActionComponent mapTarget:
|
||||
_controller?.TryTargetWorld(coordinates, actionId, mapTarget, user, comp, ActionUseType.Charge, chargeLevel);
|
||||
break;
|
||||
}
|
||||
|
||||
RaiseNetworkEvent(new RequestAudioSpellStop());
|
||||
RaiseNetworkEvent(new RemoveWizardChargeEvent());
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
_controller = null;
|
||||
|
||||
_charging = false;
|
||||
_prevCharging = false;
|
||||
_chargeTime = 0f;
|
||||
_chargeLevel = 0;
|
||||
_prevChargeLevel = 0;
|
||||
_isChargingPlaying = false;
|
||||
_isChargedPlaying = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user