Beispiel #1
0
        public void TestCargoComponentCreation()
        {
            ComponentTemplateSD cargo = GeneralCargo();

            ComponentDesigner cargoDesigner = new ComponentDesigner(cargo, _faction.GetDataBlob <FactionTechDB>());

            cargoDesigner.ComponentDesignAttributes["Size"].SetValue();

            ComponentDesign cargoDesign = cargoDesigner.CreateDesign(_faction);

            bool hasAttribute = cargoDesign.TryGetAttribute <CargoStorageAtbDB>(out var attributeDB);

            Assert.IsTrue(hasAttribute);



            CargoTypeSD cargotype = _game.StaticData.CargoTypes[attributeDB.CargoTypeGuid];

            Assert.AreEqual(100, attributeDB.StorageCapacity);

            Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>();

            componentsDict.Add(cargo.ID, cargo);
            StaticDataManager.ExportStaticData(componentsDict, "CargoComponentTest.json");
        }
Beispiel #2
0
        public void TestCargoType()
        {
            Dictionary <Guid, CargoTypeSD> cargoTypes = new Dictionary <Guid, CargoTypeSD>();
            CargoTypeSD cargoTypeGeneral = new CargoTypeSD()
            {
                ID          = new Guid("16B4C4F0-7292-4F4D-8FEA-22103C70B288"),
                Name        = "General",
                Description = "Storage for general cargo items"
            };

            cargoTypes.Add(cargoTypeGeneral.ID, cargoTypeGeneral);

            CargoTypeSD cargoTypeFuel = new CargoTypeSD()
            {
                ID          = new Guid("D8E8DA2D-8DC8-4A3F-B989-5F2E67C55E77"),
                Name        = "Fuel",
                Description = "Storage for fuel"
            };

            cargoTypes.Add(cargoTypeFuel.ID, cargoTypeFuel);

            CargoTypeSD cargoTypePopulation = new CargoTypeSD()
            {
                ID          = new Guid("9E52A3AF-66AF-4935-982D-26F3FEE775B0"),
                Name        = "Cryogenic Storage",
                Description = "Storage for frozen people"
            };

            cargoTypes.Add(cargoTypePopulation.ID, cargoTypePopulation);

            StaticDataManager.ExportStaticData(cargoTypes, "CargoTypeDataExportTest.json");
        }
Beispiel #3
0
        public void Display()
        {
            var width = ImGui.GetWindowWidth() * 0.5f;

            ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(240, 200), true, ImGuiWindowFlags.AlwaysAutoResize);
            foreach (var typeStore in _stores)
            {
                CargoTypeSD stype        = _staticData.CargoTypes[typeStore.Key];
                var         freeVolume   = typeStore.Value.FreeVolume;
                var         maxVolume    = typeStore.Value.MaxVolume;
                var         storedVolume = maxVolume - freeVolume;

                string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free";
                ImGui.PushID(_entityState.Entity.Guid.ToString());
                if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader))
                {
                    ImGui.Columns(3);
                    ImGui.Text("Item");
                    ImGui.NextColumn();
                    ImGui.Text("Count");
                    ImGui.NextColumn();
                    ImGui.Text("Total Mass");
                    ImGui.NextColumn();
                    ImGui.Separator();
                    foreach (var cargoType in typeStore.Value.CurrentStoreInUnits)
                    {
                        ICargoable ctype         = typeStore.Value.Cargoables[cargoType.Key];
                        var        cname         = ctype.Name;
                        var        volumeStored  = cargoType.Value;
                        var        volumePerItem = ctype.VolumePerUnit;
                        var        massStored    = cargoType.Value * ctype.MassPerUnit;
                        var        itemsStored   = typeStore.Value.CurrentStoreInUnits[ctype.ID];
                        if (ImGui.Selectable(cname))
                        {
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Number(itemsStored));
                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Mass(massStored));
                        ImGui.SetTooltip(Stringify.Volume(volumeStored));
                        ImGui.NextColumn();
                    }

                    ImGui.Columns(1);
                }
            }


            ImGui.EndChild();
        }
        public void TestCargoComponentCreation()
        {
            ComponentTemplateSD cargo = GeneralCargo();

            ComponentDesign cargoDesign = GenericComponentFactory.StaticToDesign(cargo, _faction.GetDataBlob <FactionTechDB>(), _game.StaticData);

            cargoDesign.ComponentDesignAttributes[0].SetValue();
            Entity cargoEntity = GenericComponentFactory.DesignToDesignEntity(_game, _faction, cargoDesign);

            CargoStorageAtbDB attributeDB = cargoEntity.GetDataBlob <CargoStorageAtbDB>();


            CargoTypeSD cargotype = _game.StaticData.CargoTypes[attributeDB.CargoTypeGuid];

            Assert.AreEqual(100, attributeDB.StorageCapacity);

            Dictionary <Guid, ComponentTemplateSD> componentsDict = new Dictionary <Guid, ComponentTemplateSD>();

            componentsDict.Add(cargo.ID, cargo);
            StaticDataManager.ExportStaticData(componentsDict, "CargoComponentTest.json");
        }
Beispiel #5
0
        public void Initalise(CargoStorageDB storageDB, Guid storageTypeID)
        {
            _storageDB = storageDB;
            TypeID     = storageTypeID;

            CargoTypeSD cargoType = _dataStore.CargoTypes[TypeID];

            TypeName = cargoType.Name;
            foreach (var itemKVP in StorageSpaceProcessor.GetResourcesOfCargoType(storageDB, TypeID))
            {
                CargoItemVM cargoItem = new CargoItemVM(_gameVM, _storageDB, itemKVP.Key);
                TypeStore.Add(cargoItem);
            }
            if (_storageDB.StoredEntities.ContainsKey(TypeID))
            {
                InitEntities();
            }

            HeaderText = cargoType.Name + ": " + NetWeight.ToString() + " of " + MaxWeight.ToString() + " used, " + RemainingWeight.ToString() + " remaining";
            _storageDB.OwningEntity.Manager.ManagerSubpulses.SystemDateChangedEvent += ManagerSubpulses_SystemDateChangedEvent;
            _storageDB.MinsAndMatsByCargoType[TypeID].CollectionChanged             += _storageDB_CollectionChanged;
            _storageDB.StoredEntities.CollectionChanged += StoredEntities_CollectionChanged;
        }
Beispiel #6
0
        public void Display()
        {
            ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(260, 200), true);
            ImGui.Text(_entityState.Name);
            ImGui.Text("Transfer Rate: " + _volStorageDB.TransferRateInKgHr);
            ImGui.Text("At DeltaV < " + Stringify.Velocity(_volStorageDB.TransferRangeDv_mps));

            foreach (var typeStore in _stores)
            {
                CargoTypeSD stype        = _staticData.CargoTypes[typeStore.Key];
                var         freeVolume   = typeStore.Value.FreeVolume;
                var         maxVolume    = typeStore.Value.MaxVolume;
                var         storedVolume = maxVolume - freeVolume;

                string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free";
                ImGui.PushID(_entityState.Entity.Guid.ToString());
                if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader))
                {
                    ImGui.Columns(3);
                    ImGui.Text("Item");
                    ImGui.NextColumn();
                    ImGui.Text("Count");
                    ImGui.NextColumn();
                    ImGui.Text("Total Mass");
                    ImGui.NextColumn();
                    ImGui.Separator();

                    foreach (var cargoItemKvp in typeStore.Value.CurrentStoreInUnits.ToArray())
                    {
                        ICargoable cargoItem = _stores[typeStore.Key].Cargoables[cargoItemKvp.Key];
                        if (cargoItem == null)
                        {
                            FactionInfoDB factionInfoDB;
                            //factionInfoDB.
                        }

                        var cname         = cargoItem.Name;
                        var unitsStored   = cargoItemKvp.Value;
                        var volumePerItem = cargoItem.VolumePerUnit;
                        var volumeStored  = _volStorageDB.GetVolumeStored(cargoItem);
                        var massStored    = _volStorageDB.GetMassStored(cargoItem);

                        bool isSelected = selectedCargo == cargoItem;
                        if (ImGui.Selectable(cname, isSelected))
                        {
                            selectedCargo = cargoItem;
                            CargoItemSelectedEvent.Invoke(this);
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Number(unitsStored));


                        if (_cargoToMove.ContainsKey(cargoItem))
                        {
                            var    unitsMoving = _cargoToMove[cargoItem];
                            string text        = Stringify.Number(unitsMoving);
                            ImGui.SameLine();

                            float blue = 0f;
                            if (_cargoToMoveDatablob.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveDatablob[cargoItem] != 0)
                                {
                                    blue = 0.25f;
                                }
                            }
                            if (_cargoToMoveOrders.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveOrders[cargoItem] != 0)
                                {
                                    blue = 0.5f;
                                }
                            }
                            if (_cargoToMoveUI.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveUI[cargoItem] != 0)
                                {
                                    blue = 0.75f;
                                }
                            }

                            if (unitsMoving > 0)
                            {
                                ImGui.TextColored(new Vector4(0.5f, 1, blue, 1), text);
                            }
                            else
                            {
                                ImGui.TextColored(new Vector4(1f, 0.5f, blue, 1), text);
                            }
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Mass(massStored));
                        ImGui.NextColumn();
                    }

                    ImGui.Columns(1);
                }
            }


            ImGui.EndChild();
        }