Ejemplo n.º 1
0
        public IEnumerable <IChange> ValidateDropOnAdd(MechLabItemSlotElement item, LocationHelper location, MechLabHelper mechlab, List <IChange> changes)
        {
            Control.LogDebug(DType.ComponentInstall, "--- AutoLinked Add");

            if (Links == null || Links.Length == 0)
            {
                yield break;
            }

            foreach (var link in Links)
            {
                Control.LogDebug(DType.ComponentInstall, $"---- {link.ComponentDefId} to {link.Location}");
                var slot = DefaultHelper.CreateSlot(link.ComponentDefId, link.ComponentDefType ?? Def.ComponentType, mechlab.MechLab);

                if (slot != null)
                {
                    Control.LogDebug(DType.ComponentInstall, $"----- added");
                    yield return(new AddDefaultChange(link.Location, slot));
                }
                else
                {
                    Control.LogDebug(DType.ComponentInstall, $"----- not found");
                }
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <IChange> ValidateDropOnRemove(MechLabItemSlotElement item, LocationHelper location, MechLabHelper mechlab, List <IChange> changes)
        {
            var replace = DefaultFixer.Shared.GetReplaceFor(mechlab.MechLab.activeMechDef, CategoryID, item.MountedLocation, mechlab.MechLab.sim);

            if (replace == null)
            {
                Control.LogDebug(DType.ComponentInstall, $"--- Category {CategoryID} - no replace, return");
                yield break;
            }

            foreach (var addChange in changes.OfType <AddChange>())
            {
                if (addChange.item.ComponentRef.IsCategory(CategoryID))
                {
                    Control.LogDebug(DType.ComponentInstall, $"--- Category {CategoryID} - replace already added");
                    yield break;
                }
            }

            Control.LogDebug(DType.ComponentInstall, $"--- Category {CategoryID} - add replace {replace.ComponentDefID}");

            yield return(new AddDefaultChange(replace.MountedLocation, DefaultHelper.CreateSlot(replace, mechlab.MechLab)));
        }