Skip to content

Commit

Permalink
Merge branch 'FixDamageMeterForAvaAndHce'
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Jun 29, 2022
2 parents 1e26e1d + 8f781c7 commit 5d3ba42
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 32 deletions.
79 changes: 61 additions & 18 deletions src/StatisticsAnalysisTool/Models/NetworkModel/PlayerGameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,56 @@ namespace StatisticsAnalysisTool.Models.NetworkModel
{
public class PlayerGameObject : GameObject
{
private CharacterEquipment _characterEquipment;
private Guid _userGuid;
private Guid? _interactGuid;
private List<TimeCollectObject> _combatTimes = new();

public PlayerGameObject(long objectId)
{
ObjectId = objectId;
LastUpdate = DateTime.UtcNow.Ticks;
}

public Guid UserGuid { get; set; }
public Guid? InteractGuid { get; set; }
public long LastUpdate { get; private set; }
public Guid UserGuid
{
get => _userGuid;
set
{
_userGuid = value;
LastUpdate = DateTime.UtcNow.Ticks;
}
}
public Guid? InteractGuid
{
get => _interactGuid;
set
{
_interactGuid = value;
LastUpdate = DateTime.UtcNow.Ticks;
}
}
public string Name { get; set; } = "Unknown";
public CharacterEquipment CharacterEquipment { get; set; } = null;
public CharacterEquipment CharacterEquipment
{
get => _characterEquipment;
set
{
_characterEquipment = value;
LastUpdate = DateTime.UtcNow.Ticks;
}
}
public DateTime? CombatStart { get; set; }
public List<TimeCollectObject> CombatTimes { get; } = new ();
public List<TimeCollectObject> CombatTimes
{
get => _combatTimes;
set
{
_combatTimes = value;
LastUpdate = DateTime.UtcNow.Ticks;
}
}
public TimeSpan CombatTime { get; set; } = new (1);
public long Damage { get; set; }
public long Heal { get; set; }
Expand All @@ -29,26 +68,14 @@ public override string ToString()
return $"{ObjectType}[ObjectId: {ObjectId}, Name: '{Name}']";
}

#region Combat

public void AddCombatTime(TimeCollectObject timeCollectObject)
{
CombatTimes.Add(timeCollectObject);
SetCombatTimeSpan();
}

public int CompareTo(object obj)
{
if (obj is not long dmg)
{
return -1;
}

if (Damage > dmg) return 1;

if (Damage == dmg) return 0;

return -1;
}

public void ResetCombatTimes()
{
CombatTimes.Clear();
Expand All @@ -63,5 +90,21 @@ private void SetCombatTimeSpan()
CombatTimes.Remove(combatTime);
}
}

#endregion

public int CompareTo(object obj)
{
if (obj is not long dmg)
{
return -1;
}

if (Damage > dmg) return 1;

if (Damage == dmg) return 0;

return -1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public ChangeClusterResponseHandler(TrackingController trackingController)
{
_trackingController = trackingController;
}

public async Task OnActionAsync(ChangeClusterResponse value)
{
_trackingController.ClusterController.ChangeClusterInformation(value.MapType, value.Guid, value.Index, value.IslandName, value.WorldMapDataType, value.DungeonInformation, value.MainClusterIndex);

_trackingController.EntityController.RemoveAllEntities();
_trackingController.LootController.ResetViewedLootLists();
_trackingController.EntityController.RemoveEntitiesByLastUpdate(2);

await Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using StatisticsAnalysisTool.Enumerations;
using StatisticsAnalysisTool.Network.Events;
using StatisticsAnalysisTool.Network.Events;
using StatisticsAnalysisTool.Network.Manager;
using System.Threading.Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task AddDamageAsync(long objectId, long causerId, double healthChan

var gameObject = _trackingController?.EntityController?.GetEntity(causerId);
var gameObjectValue = gameObject?.Value;

if (gameObject?.Value == null
|| gameObject.Value.Value?.ObjectType != GameObjectType.Player
|| !_trackingController.EntityController.IsUserInParty(gameObject.Value.Value.Name)
Expand Down
18 changes: 11 additions & 7 deletions src/StatisticsAnalysisTool/Network/Manager/EntityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ public void AddEntity(long objectId, Guid userGuid, Guid? interactGuid, string n
_knownEntities.TryAdd(gameObject.UserGuid, gameObject);
OnAddEntity?.Invoke(gameObject);
}

public void RemoveAllEntities()
public void RemoveEntitiesByLastUpdate(int withoutAnUpdateForMinutes)
{
foreach (var entity in _knownEntities.Where(x =>
x.Value.ObjectSubType != GameObjectSubType.LocalPlayer && !_knownPartyEntities.ContainsKey(x.Key)))
x.Value.ObjectSubType != GameObjectSubType.LocalPlayer
&& x.Value.Damage <= 0
&& !IsEntityInParty(x.Key)
&& new DateTime(x.Value.LastUpdate).AddMinutes(withoutAnUpdateForMinutes).Ticks < DateTime.UtcNow.Ticks))
{
_knownEntities.TryRemove(entity.Key, out _);

foreach (var entity in _knownEntities.Where(x =>
x.Value.ObjectSubType == GameObjectSubType.LocalPlayer || _knownPartyEntities.ContainsKey(x.Key)))
entity.Value.ObjectId = null;
}
}

public KeyValuePair<Guid, PlayerGameObject>? GetEntity(long objectId)
Expand All @@ -112,6 +113,8 @@ public List<KeyValuePair<Guid, PlayerGameObject>> GetAllEntities(bool onlyInPart

public bool IsEntityInParty(string name) => GetAllEntities(true).Any(x => x.Value.Name == name);

public bool IsEntityInParty(Guid guid) => GetAllEntities(true).Any(x => x.Value.UserGuid == guid);

#endregion

#region Party
Expand Down Expand Up @@ -215,6 +218,7 @@ public void SetCharacterEquipment(long objectId, CharacterEquipment equipment)
if (entity?.Value != null)
{
entity.Value.Value.CharacterEquipment = equipment;
entity.Value.Value.CharacterEquipment = equipment;
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.9.2.*")]
[assembly: AssemblyFileVersion("5.9.2.0")]
[assembly: AssemblyVersion("5.9.3.*")]
[assembly: AssemblyFileVersion("5.9.3.0")]

0 comments on commit 5d3ba42

Please sign in to comment.