public Auto(FuelTank fuelTank, Engine engine, Gearbox gearbox, Wheels wheels) { this.fuelTank = fuelTank; this.engine = engine; this.gearbox = gearbox; this.wheels = wheels; }
public void Given_NewFuelTankWithFuel_When_RemovingAllFuel_Then_TheTankIsEmpty() { // Arrange var tank = new FuelTank(FuelType.Oxygen, 5); var amountOfFuel = 2; tank.AddFuel(FuelType.Oxygen, amountOfFuel); // Act // TODO Remove the added fuel // Assert // TODO Assert that volume removed is is correct -> tank.CurrentFuelVolume }
private void Start() { playerTank = PlayerData.Instance.GetCurrentVehicleFuelTank(); Debug.Log(playerTank.GetFuelAmount()); maxBars = Mathf.CeilToInt(playerTank.GetFuelAmount() / FuelPerBar); Image fuelBarIcon = Resources.Load <Image>("UIPrefabs/FuelBarIcon"); fuelBars = new List <Image>(maxBars); for (int i = 0; i < maxBars; i++) { fuelBars.Add(Instantiate <Image>(fuelBarIcon, transform)); } currentBars = maxBars; }
public void Given_NewFuelTankWithFuel_When_RemovingMoreFuelThanIsCurrentlyInTank_Then_TheTankShouldNotRemoveMoreFuelThanExistsInTheTank() { // Arrange var tank = new FuelTank(FuelType.Oxygen, 5); var amountOfFuel = 2; tank.AddFuel(FuelType.Oxygen, amountOfFuel); // Act // TODO Try to remove more than was added the fuel i.e. remove > 2 fuel and must return no more than 2 fuel // Assert // TODO Assert that tank is empty -> tank.CurrentFuelVolume not negative }
public void TestMemento() { //Arrange TankHistory history = new TankHistory(); FuelTank tank = new FuelTank() { FuelLevel = 100, FuelType = "Unleaded" }; //act history.memento = tank.CreateMemento(); //assert Assert.AreEqual(tank.FuelType, history.memento.FuelType); Assert.AreEqual(tank.FuelLevel, history.memento.FuelLevel); }
public IActionResult Edit(int id) { FuelTank fuelTank = db.FuelTanks.FirstOrDefault(f => f.Id == id); //TOD: add checking when edit fuelTank's type ViewBag.FuelId = fuelTank.FuelId; if (fuelTank != null) { ViewBag.Fuels = new SelectList(db.Fuels, "Id", "Name", fuelTank.FuelId); return(View(fuelTank)); } return(NotFound()); }
/// <summary> /// Applied after OnSpawn runs. /// </summary> internal static void Postfix(FuelTank __instance) { var obj = __instance?.gameObject; if (obj != null) { obj.Subscribe((int)GameHashes.LaunchRocket, (_) => { // Clear the contents foreach (var item in __instance.items) { Util.KDestroyGameObject(item); } __instance.items.Clear(); }); } }
public bool AddFuelTank(int x, int y, FuelTank fuelTank) { if (CanAddFuelTank(x, y)) { DataGridViewImageCell cell = (DataGridViewImageCell)field.Rows[y].Cells[x]; cell.Value = FuelTank.Image; cell.Tag = fuelTank; FuelTanksCount++; return(true); } return(false); }
private static void CreateFuelTank(FuelTank fuelTank, Point creationPoint) { var fuel = fuelTank.Fuel; var volume = fuelTank.Volume; var currentFullness = fuelTank.OccupiedVolume; // test //FuelModel fuel = new FuelModel(1, "АИ-92", 42.9); //var volume = 10000; //var currentFullness = 5000; // /test var fuelTankView = CreateFuelTankView("Fuel Tank", volume, currentFullness, fuel); CreateFuelTankPictureBox(fuelTankView, creationPoint); }
private void labelAddNewFuel_Click(object sender, EventArgs e) { if (clickedElement is FuelTank) { FuelTank clickedFuelTank = (FuelTank)clickedElement; AddNewFuel addNewFuel = new AddNewFuel(crudHelper, clickedFuelTank); addNewFuel.ShowDialog(); LoadList(); cbFuelList.Text = clickedFuelTank.Fuel.ToString(); cbFuelList.DisplayMember = "Fuel"; cbFuelList.ValueMember = "Id"; cbFuelList.DataSource = fuelDataTable; } }
public AddNewFuel(CrudHelper crudHelper, FuelTank fuelTank) { if (crudHelper == null || fuelTank == null) { throw new NullReferenceException(); } InitializeComponent(); this.crudHelper = crudHelper; this.fuelTank = fuelTank; labelWrongFuelName.Visible = false; nudCostPerLiter.Minimum = CashCounter.MinPricePerLiterOfFuelInRubles; nudCostPerLiter.Maximum = CashCounter.MaxPricePerLiterOfFuelInRubles; }
public double GetRequiredFuelMass(double deltaVelocity) { var totalMass = Mass; // TODO: Refactor Enginge.Components to be more user friendly, dont do this shit here var massPerCycleSum = Engine.FuelComponents.Sum(i => i.Mass); var componentsByItems = Engine.FuelComponents.ToDictionary(i => i.Item); var fuelTank = new FuelTank(Engine.GetAvailableFuel(CargoBay).Select(i => { var portion = componentsByItems[i.Item].Mass / massPerCycleSum; return(new FuelComponent(portion, i.Mass)); }).ToList()); var dryMass = totalMass - fuelTank.GetAvailableMass(); return(FuelCalculator.GetConsumedFuel(deltaVelocity, dryMass, fuelTank, Engine.ExhaustVelocity, 1.MeterPerSecond())); }
// If tank is of a different type, then return that too public FuelTank GetEmptiestFuelTankOfType(GameManager.FuelType type) { FuelTank emptiest = null; float leastAmountOfFuel = float.PositiveInfinity; foreach (FuelTank tank in fuelTanks) { if (tank.type != type && tank.quantity > 0.0f) continue; if (tank.quantity < leastAmountOfFuel) { emptiest = tank; leastAmountOfFuel = tank.quantity; } } return emptiest; }
public void Assert_EngineValves_Are_Open() { var rocket = RocketStub(); var engineMock = autoMoqer.GetMock <Engine>(); rocket.Engine = engineMock.Object; var fueltank1 = new FuelTank(FuelType.Oxygen, 5); var fueltank2 = new FuelTank(FuelType.Methane, 5); rocket.FuelTanks.Add(fueltank1); rocket.FuelTanks.Add(fueltank2); rocket.StartEngine(); engineMock.Verify(x => x.OpenFuelValves(), Times.Once); // engineMock.Verify(x=>x.IgniteEngine(It.IsAny<FuelTank[]>()), Times.Once); }
public void TestRevert() { //Arrange TankHistory history = new TankHistory(); FuelTank tank = new FuelTank() { FuelLevel = 100, FuelType = "Unleaded" }; //act history.memento = tank.CreateMemento(); tank.FuelLevel = 150; tank.FuelType = "Diesel"; tank.RevertTank(history.memento); //assert Assert.AreEqual(100, tank.FuelLevel); Assert.AreEqual("Unleaded", tank.FuelType); }
private void LoadPartModulesAndFields() { _roTankPM = part.Modules.GetModule("ModuleROTank"); _procPartPM = part.Modules.GetModule("ProceduralPart"); if (_procPartPM != null) { BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy; _procPartMinVolumeField = _procPartPM.GetType().GetField("volumeMin", flags); _procPartCurShapeProp = _procPartPM.GetType().GetProperty("CurrentShape", flags); } _rfPM = part.Modules.GetModule <ModuleFuelTanks>(); var fiTanks = typeof(ModuleFuelTanks).GetField("tankList", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); _tankList = (FuelTankList)fiTanks.GetValue(_rfPM); _ecTank = _tankList["ElectricCharge"]; _seekVolumeMethod = GetSeekVolumeMethod(); }
private void printEnergySourceDialog(ref Vehicle io_Vehicle, bool i_IsElectric) { if (i_IsElectric == true) { Battery battery = io_Vehicle.EnergySource as Battery; Console.Write( @"What is your vehicle current battery time in hours? (Max battry time is {0}) >> ", battery.MaxEnergyTime); string sBatteryTime = Console.ReadLine(); float fBatteryTime = float.Parse(sBatteryTime); if (fBatteryTime > battery.MaxEnergyTime) { throw new ValueOutOfRangeException("Battery time", 0, battery.MaxEnergyTime); } else { m_Garage.AddVehicleInfo("Current Battery Time", fBatteryTime); } } else { FuelTank fuelTank = io_Vehicle.EnergySource as FuelTank; Console.Write( @"What is your vehicle current fuel amount in liters? (Max fuel tank capacity is: {0}) >> ", fuelTank.MaxFuelAmount); string sFuelAmount = Console.ReadLine(); float fFuelAmount = float.Parse(sFuelAmount); if (fFuelAmount > fuelTank.MaxFuelAmount) { throw new ValueOutOfRangeException("Fuel tank", 0, fuelTank.MaxFuelAmount); } else { m_Garage.AddVehicleInfo("Current Fuel Amount", fFuelAmount); } } }
private void nudElementProperty1_ValueChanged(object sender, EventArgs e) { if (clickedElement is CashCounter) { CashCounter cashCounter = (CashCounter)clickedElement; cashCounter.CashInRubles = (int)nudElementProperty1.Value; } else if (clickedElement is FuelDispenser) { FuelDispenser fuelDispenser = (FuelDispenser)clickedElement; fuelDispenser.FuelFeedRateInLitersPerMinute = (int)nudElementProperty1.Value; } else if (clickedElement is FuelTank) { FuelTank fuelTank = (FuelTank)clickedElement; fuelTank.Volume = (int)nudElementProperty1.Value; nudElementProperty2.Maximum = fuelTank.Volume; } }
public void Load(ConfigNode node) { if (!(node.name.Equals("TANK_DEFINITION") && node.HasValue("name"))) { return; } ConfigNode.LoadObjectFromConfig(this, node); tankList.Load(node); for (int i = tankList.Count - 1; i >= 0; --i) { FuelTank tank = tankList[i]; if (!tank.resourceAvailable) { //log.warn ("Unable to initialize tank definition for resource \"" + tank.name + "\" in tank definition \"" + name + "\" as this resource is not defined."); tankList.RemoveAt(i); } } }
public void InitEquips() { CurrentHull = ManagerGame.HullList[0] as Hull; CurrentFuelTank = ManagerGame.FuelTankList[0] as FuelTank; CurrentDrill = ManagerGame.DrillList[0] as Drill; CurrentCargo = ManagerGame.CargoList[0] as Cargo; CurrentRocket = ManagerGame.RocketList[0] as Rocket; CurrentEquips.Add(CurrentHull); CurrentEquips.Add(CurrentFuelTank); CurrentEquips.Add(CurrentDrill); CurrentEquips.Add(CurrentCargo); CurrentEquips.Add(CurrentRocket); BuyedEquips.Add(CurrentHull); BuyedEquips.Add(CurrentFuelTank); BuyedEquips.Add(CurrentDrill); BuyedEquips.Add(CurrentCargo); BuyedEquips.Add(CurrentRocket); }
private void AttemptLightTorch() { Torch nearest = GameManager.instance.GetNearestTorch(this.gameObject.transform.position, lightTorchRange); if (nearest == null) { // TODO: Other stuff here, like start a shrug animation? return; } // Does the player have a matching fuel type? FuelTank emptiest = GetEmptiestNonEmptyFuelTankOfType(nearest.type); // If so, get the emptiest tank with that type and put it in the torch if (emptiest != null) { float leftover = nearest.addFuel(emptiest.quantity, emptiest.type); emptiest.SetFuel(leftover, emptiest.type); } }
static public GameObject SetupInstance(GameObject source, GameObject dest) { GameObject template = (GameObject)Resources.Load("ShipPrefab", typeof(GameObject)); GameObject newRen = Instantiate(template); newRen.name = $"Ship #{GameEvents.current.GetNextShipNr()}"; newRen.transform.parent = source.transform.parent; newRen.transform.SetPositionAndRotation(source.transform.position, new Quaternion()); Ship ship = newRen.GetComponent <Ship>(); ship.flightState = new FlightState(source.GetComponent <Planet>(), FlightState.StateEnum.OnSurface, ship); FlightState autopilotTarget = new FlightState(dest.GetComponent <Planet>(), FlightState.StateEnum.OnSurface, ship); ship.autopilot = new HohmannTransferPendlerAutopilot(ship, ship.flightState, autopilotTarget); ship.autopilot.target = autopilotTarget; // fuel and engine initialization RP1Resource rp1 = new RP1Resource(); LOXResource lox = new LOXResource(); Fuel fuel = new RP1Fuel(rp1, lox); double fuelMass = 100000; FuelTank rp1Tank = new FuelTank(fuelMass, rp1, fuelMass * 0.07); FuelTank loxTank = new FuelTank(fuelMass * rp1.oxidizer_ratio, lox, fuelMass * rp1.oxidizer_ratio * 0.07); ship.engine = new ChemicalEngine(fuel, fuelMass * 0.07, ship); ship.fuelTanks.Add(rp1Tank); ship.fuelTanks.Add(loxTank); ship.Refuel(); ship.orbit = null; ship.orbitRenderer = null; GameEvents.current.allShips.Add(newRen); GameEvents.current.UpdateScales(); return(newRen); }
public IActionResult Create(FuelTank fuelTank) { ViewBag.Fuels = new SelectList(db.Fuels, "Id", "Name", fuelTank.FuelId); if (ModelState.IsValid) { try { db.Add(fuelTank); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch { return(View(fuelTank)); } } return(View(fuelTank)); }
public void ConnectTank(FuelTank tank) { if (!fuelTankConnected) { // Assign tank fuelTank = tank; fuelTank.uiFuelGuage.alpha = 1f; // Fuel pad indicator lights foreach (MeshRenderer light in lights) { light.material = connectedMaterial; } foreach (Light light in glow) { light.color = connectedColour; } fuelTankConnected = true; } }
private void Awake() { lastMessage = new Message_PlaneUpdate(false, 0, 0, 0, 0, 0, 0, false, false, networkUID); lastFiringMessage = new Message_WeaponFiring(-1, networkUID); lastStoppedFiringMessage = new Message_WeaponStoppedFiring(networkUID); wheelsController = GetComponent <WheelsController>(); aeroController = GetComponent <AeroController>(); vRThrottle = gameObject.GetComponentInChildren <VRThrottle>(); if (vRThrottle == null) { Debug.Log("Cound't find throttle"); } else { vRThrottle.OnSetThrottle.AddListener(SetThrottle); } weaponManager = GetComponent <WeaponManager>(); if (weaponManager == null) { Debug.LogError("Weapon Manager was null on our vehicle"); } cmManager = GetComponentInChildren <CountermeasureManager>(); if (cmManager == null) { Debug.LogError("CountermeasureManager was null on our vehicle"); } fuelTank = GetComponent <FuelTank>(); if (fuelTank == null) { Debug.LogError("FuelTank was null on our vehicle"); } Networker.WeaponSet += WeaponSet; traverse = Traverse.Create(weaponManager); Debug.Log("Done Plane Sender"); }
private void Update() { if (!foundParent) { for (int i = 0; i < 10; ++i) { if (parentTank == gameObject) { if (parentTank.transform.parent != null) { parentTank = parentTank.transform.parent.gameObject; } } else { foundParent = true; break; } } } if (parentTank != gameObject) { if (parentTank.GetComponent <FuelTank>()) { if (parentTank.GetComponent <FuelTank>().tankFuel > 0) { tank = parentTank.GetComponent <FuelTank>(); } else { tank = GetComponent <FuelTank>(); } } } else { tank = GetComponent <FuelTank>(); } }
private bool AddItemToInventory() { // Get Player Player player = FindObjectOfType <Player>(); // Hacky edge case for fuel if (MyType == InventoryItem.Type.Fuel || MyType == InventoryItem.Type.RefinedFuel) { // Add fuel to player GameManager.FuelType fuelType; if (MyType == InventoryItem.Type.Fuel) { fuelType = GameManager.FuelType.Regular; } else { fuelType = GameManager.FuelType.Refined; } FuelTank fuelTank = player.GetEmptiestFuelTankOfType(fuelType); if (fuelTank == null) { return(false); } float leftover = fuelTank.addFuel(5, fuelType); // If all fuel returned then return false if (leftover == 5) { return(false); } // Otherwise return true return(true); } return(player.inventory.AddItem(new InventoryItem(MyType))); }
private void FixedObjectsAddBtn_Click(object sender, RoutedEventArgs e) { FixedObject fixedObject = new FuelTank(); switch (fixedObjectsComboBox.SelectedItem) { case "Fuel Tank": fixedObject = new FuelTank(); break; case "Health Boost": fixedObject = new HealthBoost(); break; case "Ship": fixedObject = new Ship(); break; } fixedObject.Image.PointerPressed += SelectedImage_onMuseClick; Map.CreateAndAddFixedObjectToMap(fixedObject, 0, 0); }
} // skip original method static void Postfix(GameObject go) { RocketEngineImproved rocketEngine = go.AddOrGet <RocketEngineImproved>(); rocketEngine.ExhaustVelocity = SteamEngineStats.ExhaustVelocity; rocketEngine.RangePenalty = SteamEngineStats.RangePenalty; rocketEngine.MinFuel = SteamEngineStats.MinFuel; rocketEngine.MaxFuel = SteamEngineStats.MaxFuel; rocketEngine.OnlyFuel = true; rocketEngine.fuelTag = ElementLoader.FindElementByHash(SimHashes.Steam).tag; rocketEngine.explosionEffectHash = SpawnFXHashes.MeteorImpactDust; rocketEngine.requireOxidizer = false; rocketEngine.exhaustElement = SimHashes.Steam; rocketEngine.exhaustTemperature = ElementLoader.FindElementByHash(SimHashes.Steam).lowTemp + 50f; FuelTank fuelTank = go.AddOrGet <FuelTank>(); fuelTank.capacityKg = SteamEngineStats.MaxStorage; fuelTank.FuelType = ElementLoader.FindElementByHash(SimHashes.Steam).tag; var list = new List <Storage.StoredItemModifier>(); list.Add(Storage.StoredItemModifier.Hide); list.Add(Storage.StoredItemModifier.Seal); list.Add(Storage.StoredItemModifier.Insulate); fuelTank.SetDefaultStoredItemModifiers(list); ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>(); conduitConsumer.conduitType = ConduitType.Gas; conduitConsumer.consumptionRate = 10f; conduitConsumer.capacityTag = fuelTank.FuelType; conduitConsumer.capacityKG = SteamEngineStats.MaxStorage; conduitConsumer.forceAlwaysSatisfied = true; conduitConsumer.wrongElementResult = ConduitConsumer.WrongElementResult.Dump; go.AddOrGet <RocketModule>().SetBGKAnim(Assets.GetAnim("rocket_steam_engine_bg_kanim")); EntityTemplates.ExtendBuildingToRocketModule(go); }
public float GetTotalFuel(bool includeBoosters = false) { float num = 0f; foreach (GameObject item in AttachableBuilding.GetAttachedNetwork(commandModule.GetComponent <AttachableBuilding>())) { FuelTank component = item.GetComponent <FuelTank>(); Tag engineFuelTag = GetEngineFuelTag(); if ((Object)component != (Object)null) { num += component.GetAmountAvailable(engineFuelTag); } if (includeBoosters) { SolidBooster component2 = item.GetComponent <SolidBooster>(); if ((Object)component2 != (Object)null) { num += component2.fuelStorage.GetAmountAvailable(component2.fuelTag); } } } return(num); }
public void Setup(Item item, int itemType, FuelType fuel = null, FuelTank tank = null, RocketConfiguration config = null) { this.currentItem = item; this.itemType = itemType; switch (this.itemType) { case 0: this.currentType = fuel; break; case 1: this.currentTank = tank; break; case 2: this.currentConfig = config; break; default: break; } }