コード例 #1
0
ファイル: MapEntity.cs プロジェクト: Tsunder/Barotrauma
        public override void Remove()
        {
            base.Remove();

            mapEntityList.Remove(this);

#if CLIENT
            if (SelectedList.Contains(this))
            {
                SelectedList = SelectedList.Where(e => e != this).ToHashSet();
            }
#endif

            if (aiTarget != null)
            {
                aiTarget.Remove();
                aiTarget = null;
            }

            if (linkedTo != null)
            {
                for (int i = linkedTo.Count - 1; i >= 0; i--)
                {
                    linkedTo[i].RemoveLinked(this);
                }
                linkedTo.Clear();
            }
        }
コード例 #2
0
        public bool Has(Data.Skill.Skill skill)
        {
            List <Data.Skill.Skill> SelectedList;
            int limit;

            if (skill == null)
            {
                Debug.Log("ConstellationPreset.Has() skill null");
                throw new Exception();
            }

            switch (skill.Category)
            {
            case Data.Skill.Skill.ECategory.Ability:
                SelectedList = SelectedAbilityList;
                limit        = App.Content.GameSettings.NumAbilities;
                break;

            case Data.Skill.Skill.ECategory.Class:
                SelectedList = SelectedClassList;
                limit        = App.Content.GameSettings.NumClasses;
                break;

            case Data.Skill.Skill.ECategory.Kit:
                SelectedList = SelectedKitList;
                limit        = App.Content.GameSettings.NumKits;
                break;

            default:
                Debug.Log("ConstellationPreset.Has() skill no type");
                throw new Exception();
            }

            return(SelectedList.Contains(skill));
        }
コード例 #3
0
        private void RemoveItemExecute(object obj)
        {
            Payment payment = obj as Payment;

            if (SelectedList.Contains(payment))
            {
                SelectedList.Remove(payment);
                TotalSumToPay = TotalSumToPay - payment.Sum;
            }
        }
コード例 #4
0
ファイル: MetaSelectionSet.cs プロジェクト: voidALPHA/cgc_viz
        public IEnumerator Select(IEnumerable <VisualPayload> payloads)
        {
            if (!payloads.Any())
            {
                yield return(null);

                yield break;
            }

            bool sendNormal = !SelectedList.Any();

            IEnumerator iterator;

            foreach (var payload in payloads)
            {
                if (SelectedList.Contains(payload))
                {
                    continue;
                }

                UnSelectedList.Remove(payload);
                SelectedList.Add(payload);

                payload.VisualData.Bound.ClearBounds();

                iterator = SelectedState.Transmit(payload);
                while (iterator.MoveNext())
                {
                    yield return(null);
                }
            }

            if (sendNormal)
            {
                iterator = SendUnselected();
                while (iterator.MoveNext())
                {
                    yield return(null);
                }
            }

            iterator = TransmitMultiStates();
            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
コード例 #5
0
ファイル: MetaSelectionSet.cs プロジェクト: voidALPHA/cgc_viz
        public IEnumerator ToggleFullySelected(IEnumerable <VisualPayload> payloads)
        {
            IEnumerator iterator;

            if (payloads.All(payload => SelectedList.Contains(payload)))
            {
                iterator = Deselect(payloads);
                while (iterator.MoveNext())
                {
                    yield return(null);
                }
            }
            else
            {
                iterator = Select(payloads);
                while (iterator.MoveNext())
                {
                    yield return(null);
                }
            }
        }
コード例 #6
0
ファイル: Structure.cs プロジェクト: bengibollen/Barotrauma
        public GUIComponent CreateEditingHUD(bool inGame = false)
        {
            int heightScaled = (int)(20 * GUI.Scale);

            editingHUD = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GUI.Canvas, Anchor.CenterRight)
            {
                MinSize = new Point(400, 0)
            })
            {
                UserData = this
            };
            GUIListBox listBox = new GUIListBox(new RectTransform(new Vector2(0.95f, 0.8f), editingHUD.RectTransform, Anchor.Center), style: null)
            {
                CanTakeKeyBoardFocus = false
            };
            var editor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, titleFont: GUI.LargeFont)
            {
                UserData = this
            };

            if (Submarine.MainSub?.Info?.Type == SubmarineType.OutpostModule)
            {
                GUITickBox tickBox = new GUITickBox(new RectTransform(new Point(listBox.Content.Rect.Width, 10)), TextManager.Get("sp.structure.removeiflinkedoutpostdoorinuse.name"))
                {
                    Font       = GUI.SmallFont,
                    Selected   = RemoveIfLinkedOutpostDoorInUse,
                    ToolTip    = TextManager.Get("sp.structure.removeiflinkedoutpostdoorinuse.description"),
                    OnSelected = (tickBox) =>
                    {
                        RemoveIfLinkedOutpostDoorInUse = tickBox.Selected;
                        return(true);
                    }
                };
                editor.AddCustomContent(tickBox, 1);
            }

            var buttonContainer = new GUILayoutGroup(new RectTransform(new Point(listBox.Content.Rect.Width, heightScaled)), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.01f
            };

            new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"))
            {
                ToolTip   = TextManager.Get("MirrorEntityXToolTip"),
                OnClicked = (button, data) =>
                {
                    foreach (MapEntity me in SelectedList)
                    {
                        me.FlipX(relativeToSub: false);
                    }
                    if (!SelectedList.Contains(this))
                    {
                        FlipX(relativeToSub: false);
                    }
                    return(true);
                }
            };
            new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"))
            {
                ToolTip   = TextManager.Get("MirrorEntityYToolTip"),
                OnClicked = (button, data) =>
                {
                    foreach (MapEntity me in SelectedList)
                    {
                        me.FlipY(relativeToSub: false);
                    }
                    if (!SelectedList.Contains(this))
                    {
                        FlipY(relativeToSub: false);
                    }
                    return(true);
                }
            };
            new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("ReloadSprite"))
            {
                OnClicked = (button, data) =>
                {
                    Sprite.ReloadXML();
                    Sprite.ReloadTexture(updateAllSprites: true);
                    return(true);
                }
            };
            new GUIButton(new RectTransform(new Vector2(0.23f, 1.0f), buttonContainer.RectTransform), TextManager.Get("ResetToPrefab"))
            {
                OnClicked = (button, data) =>
                {
                    foreach (MapEntity me in SelectedList)
                    {
                        (me as Item)?.Reset();
                        (me as Structure)?.Reset();
                    }
                    if (!SelectedList.Contains(this))
                    {
                        Reset();
                    }
                    CreateEditingHUD();
                    return(true);
                }
            };
            buttonContainer.RectTransform.Resize(new Point(buttonContainer.Rect.Width, buttonContainer.RectTransform.Children.Max(c => c.MinSize.Y)));
            buttonContainer.RectTransform.IsFixedSize = true;
            GUITextBlock.AutoScaleAndNormalize(buttonContainer.Children.Where(c => c is GUIButton).Select(b => ((GUIButton)b).TextBlock));
            editor.AddCustomContent(buttonContainer, editor.ContentCount);

            PositionEditingHUD();

            return(editingHUD);
        }
コード例 #7
0
        public void Remove(Data.Skill.Skill skill)
        {
            List <Data.Skill.Skill> SelectedList;
            int limit;

            if (skill == null)
            {
                Debug.Log("ConstellationPreset.Remove() skill null");
                throw new Exception();
            }

            switch (skill.Category)
            {
            case Data.Skill.Skill.ECategory.Ability:
                SelectedList = SelectedAbilityList;
                limit        = App.Content.GameSettings.NumAbilities;
                break;

            case Data.Skill.Skill.ECategory.Class:
                SelectedList = SelectedClassList;
                limit        = App.Content.GameSettings.NumClasses;
                break;

            case Data.Skill.Skill.ECategory.Kit:
                SelectedList = SelectedKitList;
                limit        = App.Content.GameSettings.NumKits;
                break;

            default:
                Debug.Log("ConstellationPreset.Remove() skill no type");
                throw new Exception();
            }

            if (SelectedList.Count == 0 || !SelectedList.Contains(skill))
            {
                Debug.Log("ConstellationPreset.Remove() can't");
                throw new Exception();
            }

            /*if (skill.Type == Skill.TypeEnum.Ability)
             * {
             *      //clear if preset doesn't contain a starting node
             *      bool hasStartingAbility = false;
             *      foreach (var startingAbilityNodeIndex in Constellation.StartingAbilityNodeIndexList)
             *      {
             *              Skill startingSkill = Constellation.AbilityNodeList[startingAbilityNodeIndex].Skill;
             *              if (SelectedAbilityList.Contains(startingSkill))
             *              {
             *                      hasStartingAbility = true;
             *                      break;
             *              }
             *      }
             *      if (!hasStartingAbility)
             *      {
             *              Clear();
             *              return;
             *      }
             *
             *      SelectedAbilityList.Remove(skill);
             *      //unselect classes and kits that were solely dependent on this ability
             *      var newSelectedClassList = new List<Skill>();
             *      foreach (var selectedClass in SelectedClassList)
             *      {
             *              var selectedClassNode = Constellation.ClassNode(selectedClass);
             *              foreach (var selectedAbility in SelectedAbilityList)
             *              {
             *                      if (Constellation.AbilityNode(selectedAbility).ClassNodeList.Contains(selectedClassNode))
             *                      {
             *                              newSelectedClassList.Add(selectedClass);
             *                              break;
             *                      }
             *              }
             *      }
             *      SelectedClassList = newSelectedClassList;
             *      var newSelectedKitList = new List<Skill>();
             *      foreach (var selectedKit in SelectedKitList)
             *      {
             *              var selectedKitNode = Constellation.KitNode(selectedKit);
             *              foreach (var selectedAbility in SelectedAbilityList)
             *              {
             *                      if (Constellation.AbilityNode(selectedAbility).KitsNodeList.Contains(selectedKitNode))
             *                      {
             *                              newSelectedKitList.Add(selectedKit);
             *                              break;
             *                      }
             *              }
             *      }
             *      SelectedKitList = newSelectedKitList;
             * }
             * else*/
            SelectedList.Remove(skill);

            PresetUpdated();
        }