Exemple #1
0
        public override bool Redo(PlanetFactory factory, PlayerAction_Build actionBuild)
        {
            if (previews == null)
            {
                return(false);
            }
            if (previews.Count != 1)
            {
                return(false);
            }

            BuildTool_PathAddon pathAddon = actionBuild.assistTool;

            pathAddon.InitTool();
            pathAddon.handbp = previews[0];
            bool condition;

            using (UndoManager.IgnoreAllEvents.On())
            {
                pathAddon.ActiveColliders();
                pathAddon.FindPotentialBelt();
                pathAddon.FindPotentialBeltStrict();
                condition = pathAddon.CheckBuildConditions();

                if (condition)
                {
                    pathAddon.CreatePrebuilds();
                }

                objectIds.Clear();
                objectIds.Add(pathAddon.handbp.objId);

                if (objectIds.Count > 0)
                {
                    if (!undoData.notifyBuildListeners.Contains(this))
                    {
                        undoData.notifyBuildListeners.Add(this);
                    }
                    if (!undoData.notifyDismantleListeners.Contains(this))
                    {
                        undoData.notifyDismantleListeners.Add(this);
                    }
                }
            }

            previews.Clear();
            previews = null;
            return(condition);
        }
        public static void OnPathAddonBuilt(BuildTool_PathAddon __instance)
        {
            if (UndoManager.IgnoreAllEvents.Value)
            {
                return;
            }
            if (NebulaModAPI.IsMultiplayerActive)
            {
                if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient)
                {
                    return;
                }
            }

            PlayerUndo data = UndoManager.GetCurrentPlayerData();

            data.AddUndoItem(new UndoPathAddon(data, __instance.handbp.objId));
        }