Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Abathur/Core/Combat/Squad.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Abathur.Model;
using NydusNetwork.API.Protocol;

namespace Abathur.Core.Combat
{
public class Squad {
public class Squad : IPosition {
public ulong Id { get; set; }
public String Name { get; set; }
public ISet<IUnit> Units { get; set; } = new HashSet<IUnit>();
public ISquadController SquadController { get; set; }


Point2D IPosition.Point { get {
var count = Units.Count;
if (count == 0)
return new Point2D { X = float.NaN, Y = float.NaN };
var p = Units.Aggregate((0.0f, 0.0f), (sum, unit) => (sum.Item1 + unit.Point.X, sum.Item2 + unit.Point.Y));
return new Point2D { X = p.Item1 / count, Y = p.Item2 / count};
}
}

public bool AddUnit(IUnit unit)
{
return Units.Add(unit);
Expand Down