internal void SetMarker(Player player, Guid lId, string name, int count) { int oldCount = 0; Marker marker = FindMarker(lId, name); if (marker != null) { oldCount = marker.Count; marker.SetCount((ushort)count); } else if (count > 0) { MarkerModel model = Program.Game.GetMarkerModel(lId); var defaultMarkerModel = model as DefaultMarkerModel; if (defaultMarkerModel != null) { (defaultMarkerModel).SetName(name); } AddMarker(model, (ushort)count); } if (count != oldCount) { Program.TracePlayerEvent(player, "{0} sets {1} ({2}) markers {3} on {4}.", player, count, (count - oldCount).ToString("+#;-#"), marker != null ? marker.Model.Name : name, this); } }
//public Dictionary<Tuple<string,string>,int> MarkersDict //{ // get // { // Dictionary<Tuple<string, string>, int> markertuple = new Dictionary<Tuple<string,string>,int>(); // if (_markers.Count > 0) // { // foreach (Marker m in _markers) // { // Tuple<string, string> key = Tuple.Create<string, string>(m.Model.Name, m.Model.Id.ToString()); // markertuple.Add(key, m.Count); // } // } // return markertuple; // } //} internal void AddMarker(DataNew.Entities.Marker model, ushort count) { Marker marker = _markers.FirstOrDefault(m => m.Model.Equals(model)); if (marker != null) { marker.SetCount((ushort)(marker.Count + count)); } else if (count > 0) { _markers.Add(new Marker(this, model, count)); } }
internal void SetMarker(Player player, Guid lId, string name, int count, bool notify = true) { int oldCount = 0; Marker marker = FindMarker(lId, name); if (marker != null) { oldCount = marker.Count; marker.SetCount((ushort)count); } else if (count > 0) { DataNew.Entities.Marker model = Program.GameEngine.GetMarkerModel(lId); model.Name = name; AddMarker(model, (ushort)count); } }
internal int RemoveMarker(Marker marker, ushort count) { if (!_markers.Contains(marker)) { return(0); } if (marker.Count <= count) { int realCount = marker.Count; _markers.Remove(marker); return(realCount); } marker.SetCount((ushort)(marker.Count - count)); return(count); }
internal int RemoveMarker(Marker marker, ushort count) { if (!_markers.Contains(marker)) return 0; if (marker.Count <= count) { int realCount = marker.Count; _markers.Remove(marker); return realCount; } marker.SetCount((ushort) (marker.Count - count)); return count; }