Fix 3000 errors
This commit is contained in:
@@ -8,7 +8,6 @@ using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Cooldown;
|
||||
using Content.Server.Weapon.Melee.Components;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Hands;
|
||||
@@ -70,7 +69,7 @@ namespace Content.Server.Weapon.Melee
|
||||
RaiseLocalEvent(uid, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
}
|
||||
|
||||
private void OnClickAttack(EntityUid uid, MeleeWeaponComponent comp, ClickAttackEvent args)
|
||||
private void OnClickAttack(EntityUid owner, MeleeWeaponComponent comp, ClickAttackEvent args)
|
||||
{
|
||||
args.Handled = true;
|
||||
var curTime = _gameTiming.CurTime;
|
||||
@@ -78,18 +77,15 @@ namespace Content.Server.Weapon.Melee
|
||||
if (curTime < comp.CooldownEnd || !args.Target.IsValid())
|
||||
return;
|
||||
|
||||
var owner = EntityManager.GetEntity(uid);
|
||||
var target = args.TargetEntity;
|
||||
|
||||
var location = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(args.User).Coordinates;
|
||||
var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - location.ToMapPos(IoCManager.Resolve<IEntityManager>());
|
||||
var angle = Angle.FromWorldVec(diff);
|
||||
|
||||
if (target != null)
|
||||
if (args.Target is {Valid: true} target)
|
||||
{
|
||||
// Raise event before doing damage so we can cancel damage if the event is handled
|
||||
var hitEvent = new MeleeHitEvent(new List<IEntity>() { target }, args.User);
|
||||
RaiseLocalEvent(uid, hitEvent, false);
|
||||
var hitEvent = new MeleeHitEvent(new List<EntityUid>() { target }, args.User);
|
||||
RaiseLocalEvent(owner, hitEvent, false);
|
||||
|
||||
if (!hitEvent.Handled)
|
||||
{
|
||||
@@ -123,10 +119,10 @@ namespace Content.Server.Weapon.Melee
|
||||
comp.LastAttackTime = curTime;
|
||||
comp.CooldownEnd = comp.LastAttackTime + TimeSpan.FromSeconds(comp.CooldownTime);
|
||||
|
||||
RaiseLocalEvent(uid, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
RaiseLocalEvent(owner, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
}
|
||||
|
||||
private void OnWideAttack(EntityUid uid, MeleeWeaponComponent comp, WideAttackEvent args)
|
||||
private void OnWideAttack(EntityUid owner, MeleeWeaponComponent comp, WideAttackEvent args)
|
||||
{
|
||||
args.Handled = true;
|
||||
var curTime = _gameTiming.CurTime;
|
||||
@@ -136,8 +132,6 @@ namespace Content.Server.Weapon.Melee
|
||||
return;
|
||||
}
|
||||
|
||||
var owner = EntityManager.GetEntity(uid);
|
||||
|
||||
var location = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(args.User).Coordinates;
|
||||
var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve<IEntityManager>()) - location.ToMapPos(IoCManager.Resolve<IEntityManager>());
|
||||
var angle = Angle.FromWorldVec(diff);
|
||||
@@ -145,7 +139,7 @@ namespace Content.Server.Weapon.Melee
|
||||
// This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes.
|
||||
var entities = ArcRayCast(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(args.User).WorldPosition, angle, comp.ArcWidth, comp.Range, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(owner).MapID, args.User);
|
||||
|
||||
var hitEntities = new List<IEntity>();
|
||||
var hitEntities = new List<EntityUid>();
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (entity.IsInContainer() || entity == args.User)
|
||||
@@ -159,7 +153,7 @@ namespace Content.Server.Weapon.Melee
|
||||
|
||||
// Raise event before doing damage so we can cancel damage if handled
|
||||
var hitEvent = new MeleeHitEvent(hitEntities, args.User);
|
||||
RaiseLocalEvent(uid, hitEvent, false);
|
||||
RaiseLocalEvent(owner, hitEvent, false);
|
||||
SendAnimation(comp.Arc, angle, args.User, owner, hitEntities);
|
||||
|
||||
if (!hitEvent.Handled)
|
||||
@@ -195,14 +189,14 @@ namespace Content.Server.Weapon.Melee
|
||||
comp.LastAttackTime = curTime;
|
||||
comp.CooldownEnd = comp.LastAttackTime + TimeSpan.FromSeconds(comp.ArcCooldownTime);
|
||||
|
||||
RaiseLocalEvent(uid, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
RaiseLocalEvent(owner, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used for melee weapons that want some behavior on AfterInteract,
|
||||
/// but also want the cooldown (stun batons, flashes)
|
||||
/// </summary>
|
||||
private void OnAfterInteract(EntityUid uid, MeleeWeaponComponent comp, AfterInteractEvent args)
|
||||
private void OnAfterInteract(EntityUid owner, MeleeWeaponComponent comp, AfterInteractEvent args)
|
||||
{
|
||||
if (!args.CanReach)
|
||||
return;
|
||||
@@ -214,9 +208,7 @@ namespace Content.Server.Weapon.Melee
|
||||
return;
|
||||
}
|
||||
|
||||
var owner = EntityManager.GetEntity(uid);
|
||||
|
||||
if (args.Target == null)
|
||||
if (!args.Target.Valid)
|
||||
return;
|
||||
|
||||
var location = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(args.User).Coordinates;
|
||||
@@ -224,25 +216,25 @@ namespace Content.Server.Weapon.Melee
|
||||
var angle = Angle.FromWorldVec(diff);
|
||||
|
||||
var hitEvent = new MeleeInteractEvent(args.Target, args.User);
|
||||
RaiseLocalEvent(uid, hitEvent, false);
|
||||
RaiseLocalEvent(owner, hitEvent, false);
|
||||
|
||||
if (!hitEvent.CanInteract) return;
|
||||
SendAnimation(comp.ClickArc, angle, args.User, owner, new List<IEntity>() { args.Target }, comp.ClickAttackEffect, false);
|
||||
SendAnimation(comp.ClickArc, angle, args.User, owner, new List<EntityUid>() { args.Target }, comp.ClickAttackEffect, false);
|
||||
|
||||
comp.LastAttackTime = curTime;
|
||||
comp.CooldownEnd = comp.LastAttackTime + TimeSpan.FromSeconds(comp.CooldownTime);
|
||||
|
||||
RaiseLocalEvent(uid, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
RaiseLocalEvent(owner, new RefreshItemCooldownEvent(comp.LastAttackTime, comp.CooldownEnd), false);
|
||||
}
|
||||
|
||||
private HashSet<IEntity> ArcRayCast(Vector2 position, Angle angle, float arcWidth, float range, MapId mapId, IEntity ignore)
|
||||
private HashSet<EntityUid> ArcRayCast(Vector2 position, Angle angle, float arcWidth, float range, MapId mapId, EntityUid ignore)
|
||||
{
|
||||
var widthRad = Angle.FromDegrees(arcWidth);
|
||||
var increments = 1 + 35 * (int) Math.Ceiling(widthRad / (2 * Math.PI));
|
||||
var increment = widthRad / increments;
|
||||
var baseAngle = angle - widthRad / 2;
|
||||
|
||||
var resSet = new HashSet<IEntity>();
|
||||
var resSet = new HashSet<EntityUid>();
|
||||
|
||||
for (var i = 0; i < increments; i++)
|
||||
{
|
||||
@@ -260,9 +252,8 @@ namespace Content.Server.Weapon.Melee
|
||||
return resSet;
|
||||
}
|
||||
|
||||
private void OnChemicalInjectorHit(EntityUid uid, MeleeChemicalInjectorComponent comp, MeleeHitEvent args)
|
||||
private void OnChemicalInjectorHit(EntityUid owner, MeleeChemicalInjectorComponent comp, MeleeHitEvent args)
|
||||
{
|
||||
IEntity owner = EntityManager.GetEntity(uid);
|
||||
if (!_solutionsSystem.TryGetInjectableSolution(owner, out var solutionContainer))
|
||||
return;
|
||||
|
||||
@@ -291,13 +282,13 @@ namespace Content.Server.Weapon.Melee
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAnimation(string arc, Angle angle, IEntity attacker, IEntity source, IEnumerable<IEntity> hits, bool textureEffect = false, bool arcFollowAttacker = true)
|
||||
public void SendAnimation(string arc, Angle angle, EntityUid attacker, EntityUid source, IEnumerable<EntityUid> hits, bool textureEffect = false, bool arcFollowAttacker = true)
|
||||
{
|
||||
RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayMeleeWeaponAnimationMessage(arc, angle, attacker, source,
|
||||
hits.Select(e => (EntityUid) e).ToList(), textureEffect, arcFollowAttacker), Filter.Pvs(source, 1f));
|
||||
hits.Select(e => e).ToList(), textureEffect, arcFollowAttacker), Filter.Pvs(source, 1f));
|
||||
}
|
||||
|
||||
public void SendLunge(Angle angle, IEntity source)
|
||||
public void SendLunge(Angle angle, EntityUid source)
|
||||
{
|
||||
RaiseNetworkEvent(new MeleeWeaponSystemMessages.PlayLungeAnimationMessage(angle, source), Filter.Pvs(source, 1f));
|
||||
}
|
||||
@@ -323,14 +314,14 @@ namespace Content.Server.Weapon.Melee
|
||||
/// <summary>
|
||||
/// A list containing every hit entity. Can be zero.
|
||||
/// </summary>
|
||||
public IEnumerable<IEntity> HitEntities { get; }
|
||||
public IEnumerable<EntityUid> HitEntities { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The user who attacked with the melee wepaon.
|
||||
/// </summary>
|
||||
public IEntity User { get; }
|
||||
public EntityUid User { get; }
|
||||
|
||||
public MeleeHitEvent(List<IEntity> hitEntities, IEntity user)
|
||||
public MeleeHitEvent(List<EntityUid> hitEntities, EntityUid user)
|
||||
{
|
||||
HitEntities = hitEntities;
|
||||
User = user;
|
||||
@@ -346,12 +337,12 @@ namespace Content.Server.Weapon.Melee
|
||||
/// <summary>
|
||||
/// The entity interacted with.
|
||||
/// </summary>
|
||||
public IEntity Entity { get; }
|
||||
public EntityUid Entity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The user who interacted using the melee weapon.
|
||||
/// </summary>
|
||||
public IEntity User { get; }
|
||||
public EntityUid User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Modified by the event handler to specify whether they could successfully interact with the entity.
|
||||
@@ -359,7 +350,7 @@ namespace Content.Server.Weapon.Melee
|
||||
/// </summary>
|
||||
public bool CanInteract { get; set; } = false;
|
||||
|
||||
public MeleeInteractEvent(IEntity entity, IEntity user)
|
||||
public MeleeInteractEvent(EntityUid entity, EntityUid user)
|
||||
{
|
||||
Entity = entity;
|
||||
User = user;
|
||||
|
||||
Reference in New Issue
Block a user