protected override void Init(MyObjectBuilder_DefinitionBase def) { base.Init(def); var ob = (MyObjectBuilder_EquiPlayerAttachmentComponentDefinition)def; if (ob.Anchor.HasValue) { Register(new ImmutableAttachmentInfo(ob)); } if (ob.Attachments != null) { foreach (var k in ob.Attachments) { Register(new ImmutableAttachmentInfo(ob, k)); } } ImmutableAttachmentInfo wildcard = null; foreach (var v in _attachmentPointsByName.Values) { if (v.Dummies.Count == 0) { if (wildcard != null) { MyDefinitionErrors.Add(Package, $"Attachments {wildcard.Name} and {v.Name} both are wildcard attachments", LogSeverity.Critical); } wildcard = v; } } _wildcardAttachment = wildcard; }
private void Register(ImmutableAttachmentInfo attachment) { if (_attachmentPointsByName.ContainsKey(attachment.Name)) { MyDefinitionErrors.Add(Package, $"Can't register {attachment.Name} twice", LogSeverity.Critical); return; } _attachmentPointsByName.Add(attachment.Name, attachment); foreach (var dum in attachment.Dummies) { if (_attachmentPointByDummy.ContainsKey(dum)) { MyDefinitionErrors.Add(Package, $"Can't register attachment for dummy {dum} twice", LogSeverity.Critical); continue; } _attachmentPointByDummy.Add(dum, attachment); } }