public void AddAttachment(AttachmentType type, GunAttachment newAttachment) { if (equippedAttachments.ContainsKey(type)) { equippedAttachments.Remove(type); } equippedAttachments.Add(type, newAttachment); UpdateStatOnAttachment(); }
public void RemoveAttachment(AttachmentType type) { GunAttachment removedAttachment = null; if (equippedAttachments.ContainsKey(type)) { removedAttachment = equippedAttachments[type]; equippedAttachments.Remove(type); } Debug.Log($"Removing attachment : {removedAttachment}"); UpdateStatOnAttachment(); }
private Dictionary <AttributeType, List <ModDetails> > UpdateStatOnAttachment() { Dictionary <AttributeType, List <ModDetails> > dictUpdatingAttributes = new Dictionary <AttributeType, List <ModDetails> >(); foreach (var i in equippedAttachments) { GunAttachment attachment = i.Value; AttachmentType type = i.Key; foreach (var current in attachment.attachmentDetails) { //add each attribute type to its own specific list if (!dictUpdatingAttributes.ContainsKey(current.Key)) { dictUpdatingAttributes.Add(current.Key, new List <ModDetails>()); dictUpdatingAttributes[current.Key].Add(current.Value); } else { dictUpdatingAttributes[current.Key].Add(current.Value); } } } return(dictUpdatingAttributes); }