Example #1
0
        public void DeleteAsset(MissionAsset asset)
        {
            Debug.Assert(asset != null, "asset != null");

            EntityDefinition      entity      = asset as EntityDefinition;
            FlightGroupDefinition flightGroup = asset as FlightGroupDefinition;
            FactionDefinition     faction     = asset as FactionDefinition;

            if (entity != null)
            {
                GetFlightGroup(entity.flightGroupId)?.RemoveEntity(entity);
            }
            else if (flightGroup != null)
            {
                faction = GetFaction(flightGroup.factionId);
                if (faction.flightGroups.Count == 1)
                {
                    Debug.Log($"Can't Delete Flight Group {flightGroup.name}, every faction needs at least one flight group");
                    return;
                }
                GetFaction(flightGroup.factionId)?.RemoveFlightGroup(flightGroup);
            }
            else if (faction != null)
            {
                factions.Remove(faction);
            }
            else
            {
                throw new ArgumentException($"Can\'t delete: {asset.GetType().Name}");
            }
            onChange?.Invoke(asset.id);
        }
Example #2
0
        public void UpdateDisplayName(MissionAsset asset)
        {
            TreeViewItem item = FindItem(asset.id, rootItem);

            if (item != null)
            {
                item.displayName = asset.DisplayName;
            }
        }
Example #3
0
 private void OnSelectionChanged(MissionTreeSelection treeSelection)
 {
     //todo currently ignoring multiselect
     selectionType = TranslateSelectionType(treeSelection);
     selectedAsset = treeSelection.properties?[0];
     if (selectedAsset == null)
     {
         reflectedSelection = null;
     }
     else
     {
         reflectedSelection = new ReflectedObject(selectedAsset);
     }
 }
Example #4
0
        private void OnFlightGroupDrop(FlightGroupDefinition child, MissionAsset dropTarget, int index)
        {
            MissionTreeItem       dropTargetItem = FindMissionItem(dropTarget.id);
            FactionDefinition     faction        = dropTarget as FactionDefinition;
            FlightGroupDefinition flightGroup    = dropTarget as FlightGroupDefinition;

            if (faction != null)
            {
                db.GetCurrentMission().SetFlightGroupFaction(child, faction, index);
            }
            else if (flightGroup != null)
            {
                db.GetCurrentMission().SetFlightGroupFaction(child, dropTargetItem.GetFaction(), index);
            }
        }
Example #5
0
        private void OnEntityDrop(EntityDefinition entity, MissionAsset dropTarget, int index)
        {
            MissionTreeItem   dropTargetItem    = FindMissionItem(dropTarget.id);
            FactionDefinition factionDefinition = dropTarget as FactionDefinition;

            if (factionDefinition != null)
            {
                db.GetCurrentMission().SetEntityFaction(entity, factionDefinition, index);
            }
            else if (dropTarget is EntityDefinition)
            {
                db.GetCurrentMission().SetEntityFlightGroup(entity, dropTargetItem.GetFlightGroup(), index);
            }
            else if (dropTarget is FlightGroupDefinition)
            {
                db.GetCurrentMission().SetEntityFlightGroup(entity, (FlightGroupDefinition)dropTarget, index);
            }
        }
Example #6
0
            public MissionTreeItem(MissionAsset asset)
            {
                this.id          = asset.id;
                this.displayName = asset.DisplayName;

                this.asset = asset;
                if (asset is FactionDefinition)
                {
                    this.itemType = ItemType.Faction;
                }
                else if (asset is FlightGroupDefinition)
                {
                    this.itemType = ItemType.FlightGroup;
                }
                else if (asset is EntityDefinition)
                {
                    this.itemType = ItemType.Entity;
                }
                else
                {
                    throw new ArgumentException("Asset must be non null and a known type");
                }
            }