Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 committed Jan 22, 2025
1 parent 1025786 commit c963e8d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Content.Client.SS220.PlacerItem;

public sealed class AlignPlacerItemConstrucrion : PlacementMode
public sealed class AlignPlacerItemConstruction : PlacementMode
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
Expand All @@ -32,7 +32,7 @@ public sealed class AlignPlacerItemConstrucrion : PlacementMode

private EntityCoordinates _unalignedMouseCoords = default;

public AlignPlacerItemConstrucrion(PlacementManager pMan) : base(pMan)
public AlignPlacerItemConstruction(PlacementManager pMan) : base(pMan)
{
IoCManager.InjectDependencies(this);
_rcdSystem = _entityManager.System<RCDSystem>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class PlacerItemConstructionGhostSystem : EntitySystem
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;

private string _placementMode = typeof(AlignPlacerItemConstrucrion).Name;
private string _placementMode = typeof(AlignPlacerItemConstruction).Name;
private Direction _placementDirection = default;

public override void Update(float frameTime)
Expand Down
30 changes: 15 additions & 15 deletions Content.Server/SS220/EventCapturePoint/EventCapturePointSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public sealed class EventCapturePointSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly FractWarRuleSystem _fractWarRule = default!;

private const float RefreshWPRate = 60f;
private const float RefreshWinPointsRate = 60f;

private TimeSpan _nextRefreshWP = TimeSpan.Zero;
private TimeSpan _nextRefreshWinPoints = TimeSpan.Zero;

public override void Initialize()
{
Expand Down Expand Up @@ -60,14 +60,14 @@ public override void Update(float frameTime)
flagComp.Fraction is not { } flagFraction)
continue;

if (!component.PointRetentionTime.TryAdd(flagFraction, 0))
component.PointRetentionTime[flagFraction] += frameTime;
if (!component.PointRetentionTime.TryAdd(flagFraction, TimeSpan.Zero))
component.PointRetentionTime[flagFraction] += TimeSpan.FromSeconds(frameTime);
}

if (_timing.CurTime >= _nextRefreshWP)
if (_timing.CurTime >= _nextRefreshWinPoints)
{
RefreshWP(gameRule);
_nextRefreshWP = _timing.CurTime + TimeSpan.FromSeconds(RefreshWPRate);
RefreshWinPoints(gameRule);
_nextRefreshWinPoints = _timing.CurTime + TimeSpan.FromSeconds(RefreshWinPointsRate);
}
}

Expand Down Expand Up @@ -107,7 +107,7 @@ private void OnFlagRemoved(Entity<EventCapturePointComponent> entity, ref FlagRe

private void OnPointShutdown(Entity<EventCapturePointComponent> entity, ref ComponentShutdown args)
{
RefreshPointWP(entity.Comp);
RefreshWinPointsFromCapturePoint(entity.Comp);

if (entity.Comp.FlagEntity.HasValue &&
entity.Comp.FlagEntity.Value.Valid &&
Expand Down Expand Up @@ -216,7 +216,7 @@ public void AddOrRemoveFlag(Entity<EventCapturePointComponent> entity, EntityUid
AddFlag(entity, user, newFlag);
}

public void RefreshWP(FractWarRuleComponent? gameRule = null)
public void RefreshWinPoints(FractWarRuleComponent? gameRule = null)
{
gameRule ??= _fractWarRule.GetActiveGameRule();
if (gameRule is null)
Expand All @@ -225,11 +225,11 @@ public void RefreshWP(FractWarRuleComponent? gameRule = null)
var query = EntityQueryEnumerator<EventCapturePointComponent>();
while (query.MoveNext(out _, out var comp))
{
RefreshPointWP(comp, gameRule);
RefreshWinPointsFromCapturePoint(comp, gameRule);
}
}

public void RefreshPointWP(EventCapturePointComponent comp, FractWarRuleComponent? gameRule = null)
public void RefreshWinPointsFromCapturePoint(EventCapturePointComponent comp, FractWarRuleComponent? gameRule = null)
{
gameRule ??= _fractWarRule.GetActiveGameRule();

Expand All @@ -238,12 +238,12 @@ public void RefreshPointWP(EventCapturePointComponent comp, FractWarRuleComponen

foreach (var (fraction, retTime) in comp.PointRetentionTime)
{
var wp = comp.WinPoints * (retTime / comp.RetentionTimeForWP);
var wp = comp.WinPointsCoefficient * (float)(retTime.TotalSeconds / comp.RetentionTimeForWinPoint.TotalSeconds);

if (!gameRule.FractionsWP.TryAdd(fraction, wp))
gameRule.FractionsWP[fraction] += wp;
if (!gameRule.FractionsWinPoints.TryAdd(fraction, wp))
gameRule.FractionsWinPoints[fraction] += wp;

comp.PointRetentionTime[fraction] = 0;
comp.PointRetentionTime[fraction] = TimeSpan.Zero;
}
}
}
2 changes: 1 addition & 1 deletion Content.Server/SS220/FractWar/FractWarRuleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Content.Server.SS220.FractWar;
public sealed partial class FractWarRuleComponent : Component
{
[ViewVariables]
public Dictionary<string, float> FractionsWP = [];
public Dictionary<string, float> FractionsWinPoints = [];
}
4 changes: 2 additions & 2 deletions Content.Server/SS220/FractWar/FractWarRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ protected override void AppendRoundEndText(EntityUid uid, FractWarRuleComponent
args.AddLine(Loc.GetString("fractwar-round-end-score-points"));
args.AddLine("");

_eventCapturePoint.RefreshWP(component);
var fractionsWinPoints = component.FractionsWP;
_eventCapturePoint.RefreshWinPoints(component);
var fractionsWinPoints = component.FractionsWinPoints;

if (fractionsWinPoints.Count <= 0)
return;
Expand Down
27 changes: 14 additions & 13 deletions Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,24 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?
{
var ray = new CollisionRay(from.Position, dir, hitscan.CollisionMask);
var rayCastResults =
Physics.IntersectRay(from.MapId, ray, hitscan.MaxLength, lastUser, false).ToList().
Where(x => // SS220 add barricade begin
{
var attemptEv = new HitscanAttempt(lastUser);
RaiseLocalEvent(x.HitEntity, ref attemptEv);
return !attemptEv.Cancelled;
}); // SS220 add barricade end
if (!rayCastResults.Any())
break;
Physics.IntersectRay(from.MapId, ray, hitscan.MaxLength, lastUser, false).ToList();

// SS220 add barricade begin
//var result = rayCastResults[0];
var result = rayCastResults.FirstOrNull();
if (result is null)
break;
foreach (var rayCastResult in rayCastResults)
{
var attemptEv = new HitscanAttempt(lastUser);
RaiseLocalEvent(rayCastResult.HitEntity, ref attemptEv);

if (attemptEv.Cancelled)
rayCastResults.Remove(rayCastResult);
}
// SS220 add barricade end

if (!rayCastResults.Any())
break;

var result = rayCastResults[0];

// Check if laser is shot from in a container
if (!_container.IsEntityOrParentInContainer(lastUser))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public sealed partial class EventCapturePointComponent : Component
public float FlagRemovalImpulse = 35;

/// <summary>
/// How many points does this pedestal give per <see cref="RetentionTimeForWP"/>
/// How many points does this pedestal give per <see cref="RetentionTimeForWinPoint"/>
/// </summary>
[DataField, AutoNetworkedField]
public float WinPoints = 1f;
public float WinPointsCoefficient = 1f;

/// <summary>
/// How many seconds need to hold a capture point to get win points
/// </summary>
[DataField, AutoNetworkedField]
public float RetentionTimeForWP = 15;
public TimeSpan RetentionTimeForWinPoint = TimeSpan.FromSeconds(15);

[ViewVariables, AutoNetworkedField]
public Dictionary<string, float> PointRetentionTime = new();
public Dictionary<string, TimeSpan> PointRetentionTime = new();
}

[Serializable, NetSerializable]
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/SS220/PlacerItem/PlacerItemComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Direction ConstructionDirection
/// The time required for the user to place the construction
/// </summary>
[DataField]
public float DoAfter = 0;
public TimeSpan DoAfter = TimeSpan.Zero;

/// <summary>
/// Should the placement toggle when item used in hand
Expand Down
4 changes: 1 addition & 3 deletions Content.Shared/SS220/PlacerItem/PlacerItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ private void OnAfterInteract(Entity<PlacerItemComponent> entity, ref AfterIntera
if (!IsPlacementOperationStillValid(entity, mapGridData.Value, args.Target, user))
return;

var doAfterTime = TimeSpan.FromSeconds(comp.DoAfter);
var ev = new PlacerItemDoAfterEvent(GetNetCoordinates(mapGridData.Value.Location), comp.ConstructionDirection, comp.SpawnProto);

var doAfterArgs = new DoAfterArgs(EntityManager, user, doAfterTime, ev, uid, args.Target, uid)
var doAfterArgs = new DoAfterArgs(EntityManager, user, comp.DoAfter, ev, uid, args.Target, uid)
{
BreakOnDamage = true,
BreakOnHandChange = true,
Expand Down

0 comments on commit c963e8d

Please sign in to comment.