Пример #1
0
        public override void DoChange(MechLabHelper mechLab, LocationHelper loc)
        {
            Control.LogDebug(DType.ComponentInstall, $"-- AddFromInventoryChange: {item.ComponentRef.ComponentDefID} to {location}");

            var widget = location == loc.widget.loadout.Location ? loc.widget : mechLab.GetLocationWidget(location);

            if (widget == null)
            {
                return;
            }

            widget.OnAddItem(item, false);
            Control.LogDebug(DType.ComponentInstall, "--- added");


            if (mechLab.MechLab.IsSimGame)
            {
                Control.LogDebug(DType.ComponentInstall, "--- not default: create work order");
                WorkOrderEntry_InstallComponent subEntry = mechLab.MechLab.Sim.CreateComponentInstallWorkOrder(
                    mechLab.MechLab.baseWorkOrder.MechID,
                    item.ComponentRef, widget.loadout.Location, item.MountedLocation);
                mechLab.MechLab.baseWorkOrder.AddSubEntry(subEntry);
            }
            item.MountedLocation = location;
        }
Пример #2
0
        public IEnumerable <IChange> ValidateDropOnRemove(MechLabItemSlotElement item, LocationHelper location, MechLabHelper mechlab, List <IChange> changes)
        {
            Control.LogDebug(DType.ComponentInstall, "--- AutoLinked Remove");

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

            foreach (var link in Links)
            {
                var widget = mechlab.GetLocationWidget(link.Location);
                if (widget != null)
                {
                    Control.LogDebug(DType.ComponentInstall, $"---- {link.ComponentDefId} from {link.Location}");
                    var remove = new LocationHelper(widget).LocalInventory.FirstOrDefault(e =>
                                                                                          e?.ComponentRef?.ComponentDefID == link.ComponentDefId);
                    if (remove != null)
                    {
                        Control.LogDebug(DType.ComponentInstall, $"----- removed");
                        yield return(new RemoveChange(link.Location, remove));
                    }
                    else
                    {
                        Control.LogDebug(DType.ComponentInstall, $"----- not found");
                    }
                }
            }
        }
Пример #3
0
        public static void RemoveMechLab(string id, ComponentType type, MechLabHelper mechLab, ChassisLocations location)
        {
            var widget = mechLab.GetLocationWidget(location);

            if (widget == null)
            {
                Control.LogDebug(DType.DefaultHandle, $"DefaultHelper: Cannot remove {id} from {location} - wrong location ");
                return;
            }
            var helper = new LocationHelper(widget);

            var remove = helper.LocalInventory.FirstOrDefault(e => e.ComponentRef.ComponentDefID == id);

            if (remove == null)
            {
                Control.LogDebug(DType.DefaultHandle, $"- not found");
            }
            else if (!remove.ComponentRef.IsDefault())
            {
                Control.LogDebug(DType.DefaultHandle, $"- not default");
            }
            else
            {
                widget.OnRemoveItem(remove, true);
                Control.LogDebug(DType.DefaultHandle, $"- removed");
                remove.thisCanvasGroup.blocksRaycasts = true;
                mechLab.MechLab.dataManager.PoolGameObject(MechLabPanel.MECHCOMPONENT_ITEM_PREFAB, remove.GameObject);
            }
        }
Пример #4
0
        public override void DoChange(MechLabHelper mechLab, LocationHelper loc)
        {
            Control.LogDebug(DType.ComponentInstall, $"-- AddFromInventoryChange: {item.ComponentRef.ComponentDefID} to {location}");

            var widget = location == loc.widget.loadout.Location ? loc.widget : mechLab.GetLocationWidget(location);

            if (widget == null)
            {
                return;
            }

            widget.OnAddItem(item, false);
            Control.LogDebug(DType.ComponentInstall, "--- added");
            item.MountedLocation = location;
        }
Пример #5
0
        public static void AddMechLab(string id, ComponentType type, MechLabHelper mechLab, ChassisLocations location)
        {
            Control.LogDebug(DType.DefaultHandle, $"DefaultHelper.AddMechLab: adding {id} to {location}");

            var target = mechLab.GetLocationWidget(location);

            if (target == null)
            {
                Control.LogDebug(DType.DefaultHandle, $"DefaultHelper: Cannot add {id} to {location} - wrong location ");
                return;
            }

            var slot = CreateSlot(id, type, mechLab.MechLab);

            slot.MountedLocation = location;
            target.OnAddItem(slot, false);
        }
Пример #6
0
        internal static void AddMechLab(MechComponentRef replace, MechLabHelper mechLab)
        {
            Control.LogDebug(DType.DefaultHandle, $"DefaultHelper.AddMechLab: adding {replace.ComponentDefID} to {replace.MountedLocation}");

            var target = mechLab.GetLocationWidget(replace.MountedLocation);

            if (target == null)
            {
                Control.LogDebug(DType.DefaultHandle, $"DefaultHelper: Cannot add - wrong location ");
                return;
            }

            var slot = CreateSlot(replace, mechLab.MechLab);

            slot.MountedLocation = replace.MountedLocation;
            target.OnAddItem(slot, false);
        }
Пример #7
0
        public override void DoChange(MechLabHelper mechLab, LocationHelper loc)
        {
            Control.LogDebug(DType.ComponentInstall, $"-- RemoveChange: {item.ComponentRef.ComponentDefID} from {location}");
            var widget = location == loc.widget.loadout.Location ? loc.widget : mechLab.GetLocationWidget(location);

            if (widget == null)
            {
                return;
            }

            widget.OnRemoveItem(item, true);
            Control.LogDebug(DType.ComponentInstall, $"--- removed");
            if (item.ComponentRef.Is <Flags>(out var f) && f.Default)
            {
                Control.LogDebug(DType.ComponentInstall, $"--- Default: clear");
                item.thisCanvasGroup.blocksRaycasts = true;
                mechLab.MechLab.dataManager.PoolGameObject(MechLabPanel.MECHCOMPONENT_ITEM_PREFAB, item.gameObject);
            }