Exemplo n.º 1
0
        ///<summary>
        ///Adds the newLiquid to the LiquidsDict with regards to the remainingSpace.
        ///If remainingSpace = -1, this condition is ignored.
        ///</summary>
        public void AddLiquid(Liquid newLiquid, double remainingSpace)
        {
            // If there's no space, don't do anything
            if (remainingSpace == 0)
            {
                return;
            }

            // Ignore volume requirements
            else if (remainingSpace == -1)
            {
            }

            // If the incoming volume is greater than remaining space, change vol to remaining vol
            else
            {
                if (newLiquid.volume > remainingSpace)
                {
                    newLiquid.volume = remainingSpace;
                }
            }

            // Handle if liquid type already exists or not
            if (LiquidsDict.ContainsKey(newLiquid.liquidType))
            {
                LiquidsDict[newLiquid.liquidType].volume += newLiquid.volume;
            }
            else
            {
                LiquidsDict.Add(newLiquid.liquidType, newLiquid);
            }

            // Update stats according to the new levels
            UpdateInfo();
        }
 public override bool UseItem(Player player)                   // allows us to change what happens when we use an item
 {
     if (player.whoAmI != Main.myPlayer && !player.noBuilding) // Checks if the player is the right one, and not another player etc in multiplayer
     {
         return(false);
     }
     {
         int     range       = 2; // extra tool range after default range
         Vector2 adjustedPos = player.position / 16;
         float   xDist       = Math.Abs(Player.tileTargetX - adjustedPos.X);
         float   yDist       = Math.Abs(Player.tileTargetY - adjustedPos.Y);
         if (xDist > Player.tileRangeX + range || yDist > Player.tileRangeY + range)
         {
             return(false);
         }
     }
     // Thanks to mariothedog, Champion Mod for this range check^
     {
         Point16 tilepos = Main.MouseWorld.ToTileCoordinates16();                                   // grabs the x & y cooordinates from where the mouse is currently at
         // thanks to absoluteAquarian for telling me about point16 for easy mouse pos checking
         Main.PlaySound(SoundID.Splash, (int)player.position.X, (int)player.position.Y, 1, 1f, 0f); // plays soundid 19(splash) when using the item at the player
         Main.tile[tilepos.X, tilepos.Y].liquidType(2);                                             // decides what type of liquid to should be at x & y
         Main.tile[tilepos.X, tilepos.Y].liquid = byte.MaxValue;                                    // decides what amount of liquid should be at x & y
         if (Main.netMode == NetmodeID.MultiplayerClient)                                           // checks if its singleplayer or multiplayer
         {
             NetMessage.sendWater(tilepos.X, tilepos.Y);                                            // if its multiplayer send a message to the server that we are sending liquid
         }
         else
         {
             Liquid.AddWater(tilepos.X, tilepos.Y); // if its singleplayer just add the liquid
         }
         return(true);
     }
 }
Exemplo n.º 3
0
    public void AddLiquid(LiquidType liquidType, double volumeAdded)
    {
        if (currentVolume >= maxVolume)
        {
            return;
        }

        //
        if (LiquidsList != null)
        {
            for (int i = 0; i < LiquidsList.Count; i++)
            {
                if (LiquidsList[i].liquidType == liquidType)
                {
                    LiquidsList[i].volume += volumeAdded;
                    return;
                }
            }
        }
        // else // liquids is null, or liquidType is not in list
        {
            Liquid addedLiquid = new Liquid(liquidType, volumeAdded);
            LiquidsList.Add(addedLiquid);
        }
    }
Exemplo n.º 4
0
        private void IrrigateButton_Click(object sender, RoutedEventArgs e)
        {
            var underGroundFarms = GnomanEmpire.Instance.Fortress.FarmManager.Farms.Where(x => x.Underground);

            foreach (var underGroundFarm in underGroundFarms)
            {
                var level = (int)underGroundFarm.RandomPosition().Z;

                foreach (var area in underGroundFarm.Areas)
                {
                    for (var x = 0; x <= area.Width; x++) // Width and height are one less than actual size?
                    {
                        for (var y = 0; y <= area.Height; y++)
                        {
                            var posX    = x + area.Location.X;
                            var posY    = y + area.Location.Y;
                            var mapCell = GnomanEmpire.Instance.Map.Levels[level][posY][posX];
                            if (mapCell.Liquid == null)
                            {
                                var position = new Vector3(posX, posY, level);
                                var water    = new Liquid(position, Material.Water.ToString(), 1.0f, new Vector3(0, 0, 0), false);
                                mapCell.AddLiquid(water);
                            }
                        }
                    }
                }
            }
            AddStatusText("Irrigated underground farms");
        }
 /// <inheritdoc />
 public void LiquidChange(World world, Vector3i position, Liquid liquid, LiquidLevel level)
 {
     if (liquid.IsLiquid)
     {
         world.SetBlock(Dirt.AsInstance(), position);
     }
 }
Exemplo n.º 6
0
        public override void PreUpdate()
        {
            /*
             * count++;
             * if(count >= 100)
             * {
             *      count = 0;
             *      Main.NewText(Liquid.numLiquid +","+ LiquidBuffer.numLiquidBuffer + "," + LiquidBuffer2.numLiquidBuffer);
             * }
             */

            if (quickSwitch)
            {
                Liquid.cycles       = 1;
                Liquid.panicCounter = 0;

                while (LiquidBuffer.numLiquidBuffer > 5000 && LiquidBuffer2.numLiquidBuffer != 100000 - 1)
                {
                    LiquidBuffer2.AddBuffer(Main.liquidBuffer[LiquidBuffer.numLiquidBuffer - 1].x, Main.liquidBuffer[LiquidBuffer.numLiquidBuffer - 1].y);
                    LiquidBuffer.DelBuffer(LiquidBuffer.numLiquidBuffer - 1);
                }
                while (LiquidBuffer.numLiquidBuffer < 5000 && LiquidBuffer2.numLiquidBuffer != 0)
                {
                    //LiquidBuffer.AddBuffer(liquidBuffer2[LiquidBuffer2.numLiquidBuffer].x,liquidBuffer2[LiquidBuffer2.numLiquidBuffer].y);
                    Main.liquidBuffer[LiquidBuffer.numLiquidBuffer].x = liquidBuffer2[LiquidBuffer2.numLiquidBuffer - 1].x;
                    Main.liquidBuffer[LiquidBuffer.numLiquidBuffer].y = liquidBuffer2[LiquidBuffer2.numLiquidBuffer - 1].y;
                    LiquidBuffer.numLiquidBuffer++;

                    LiquidBuffer2.DelBuffer(LiquidBuffer2.numLiquidBuffer - 1);
                }

                Liquid.UpdateLiquid();
            }
        }
Exemplo n.º 7
0
        public ActionResult Create(Liquid liquid)
        {
            if (ModelState.IsValid)
            {
                string             imagename   = Path.GetFileNameWithoutExtension(liquid.Image2.FileName);
                string             extension   = Path.GetExtension(liquid.Image2.FileName);
                HttpPostedFileBase serverimage = liquid.Image2;
                int size = serverimage.ContentLength;
                if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
                {
                    if (size <= 2000000)
                    {
                        imagename  = imagename + extension;
                        liquid.img = "~/liquidfiles/" + imagename;
                        imagename  = Path.Combine(Server.MapPath("~/liquidfiles/"), imagename);
                        liquid.Image2.SaveAs(imagename);
                        db.Liquid.Add(liquid);
                        db.SaveChanges();
                        ModelState.Clear();
                    }
                    else
                    {
                        ViewBag.msg = "<script>alert('invalid error')</script>";
                    }
                }
                else
                {
                    ViewBag.msg = "<script>alert('Wrong Extension')</script>";
                }
            }

            return(View());
        }
        public void OnFinishMixing()
        {
            Liquid?newLiquid = null;

            foreach (var pair in Liquids)
            {
                var l = pair.liquid;
                if (newLiquid == null)
                {
                    newLiquid = l;
                }
                else
                {
                    var tmp = new Liquid();
                    tmp = new Liquid {
                        Name = newLiquid.Value.Name + "+" + l.Name, Description = "Mixed Drink"
                    };


                    var col = ColorHelper.Blend(l.GetColor(), newLiquid.Value.GetColor());

                    tmp.LiquidColor = new LiquidColor((short)(col.r * 255), (short)(col.g * 255), (short)(col.b * 255), (short)(col.a * 255));

                    newLiquid = tmp;
                }
            }

            this.Spill();
            // ReSharper disable once PossibleInvalidOperationException
            this.AddLiquid(20, newLiquid.Value, false);
        }
Exemplo n.º 9
0
        // Fylder tanken op med den væske den har fået i sin parameter
        public string Fill(Liquid liquid)
        {
            this.liquid = liquid;
            amount      = 1000;

            return("Liqiud tank is filled with " + liquid.GetType().Name.ToLower());
        }
Exemplo n.º 10
0
    void OnParticleCollision(GameObject other)
    {
        Liquid liquid = other.GetComponent <Liquid>();

        lastFilledTime = Time.time;
        if (liquid != null && fillPercentage < 1f)
        {
            fillPercentage += fillAmount;
            liquids.Add(liquid);

            // Source code from [https://answers.unity.com/questions/725895/best-way-to-mix-color-values.html]; accessed December 5, 2018
            Color result = new Color(0, 0, 0, 0);
            foreach (Liquid l in liquids)
            {
                result += l.colour;
            }
            result /= liquids.Count;
            // End source code from
            fillMaterial.material.color = new Color(result.r, result.g, result.b, 1f);

            // Set the fills
            if (contents.ContainsKey(liquid.name))
            {
                contents[liquid.name] += fillAmount;
            }
            else
            {
                contents.Add(liquid.name, fillAmount);
            }

            SetContainerText();
        }
    }
Exemplo n.º 11
0
 /// <inheritdoc />
 public void LiquidChange(World world, Vector3i position, Liquid liquid, LiquidLevel level)
 {
     if (liquid.IsLiquid && level > LiquidLevel.Three)
     {
         ScheduleDestroy(world, position);
     }
 }
Exemplo n.º 12
0
 public LiquidMix(Liquid liquid)
 {
     LiquidProportions.Add(liquid.liquidType, 1.0);
     TotalVolume = liquid.volume;
     UpdateInfo();
     //LayerObj = Instantiate(LiquidLayerPrefab, new Vector3(0, 0, 0), Quaternion.identity)
 }
Exemplo n.º 13
0
        public override void PreUpdate()
        {
            if (quickSwitch)
            {
                count++;
                if (count >= 100)
                {
                    count = 0;
                    //Main.NewText(Liquid.numLiquid +","+ LiquidBuffer.numLiquidBuffer +","+ Liquid2.numLiquid);
                }

                Liquid.cycles       = 1;
                Liquid.panicCounter = 0;
                Liquid.UpdateLiquid();

                while (LiquidBuffer.numLiquidBuffer > 0 && Liquid2.numLiquid != 1000000 - 1)
                {
                    //Liquid2.AddWater(Main.liquidBuffer[LiquidBuffer.numLiquidBuffer -1].x,Main.liquidBuffer[LiquidBuffer.numLiquidBuffer -1].y);
                    //LiquidBuffer.DelBuffer(LiquidBuffer.numLiquidBuffer -1);
                    Main.tile[Main.liquidBuffer[0].x, Main.liquidBuffer[0].y].checkingLiquid(false);
                    Liquid2.AddWater(Main.liquidBuffer[0].x, Main.liquidBuffer[0].y);
                    LiquidBuffer.DelBuffer(0);
                }
                Liquid2.cycles       = 1;
                Liquid2.panicCounter = 0;
                Liquid2.UpdateLiquid();
            }
        }
Exemplo n.º 14
0
 public void ConvertLiquidUnits(Liquid unit)
 {
     foreach (Ingredient ing in _ingredients.Where(n => n.Measure.IsLiquid))
     {
         ing.Measure.ConvertUnitTo(unit);
     }
 }
Exemplo n.º 15
0
    public static void Create(GameObject prefab, Vector3 position, float amount)
    {
        if (amount <= 0)
        {
            Debug.Log("Failed to create puddle with zero amount");
            return;
        }

        GameObject newLiquid  = Instantiate(prefab);
        Liquid     liquidData = newLiquid.GetComponent <Liquid>();

        if (liquidData == null)
        {
            Debug.LogError("Failed to get puddle script data on puddle creation");
            Destroy(newLiquid);
            return;
        }

        newLiquid.transform.position = position;

        liquidData.volume = amount;
        liquidData.radius = Mathf.Pow(3.0f * amount / (Mathf.PI * 4.0f), 1.0f / 3.0f);

        newLiquid.transform.localScale = new Vector3(liquidData.radius, liquidData.radius, liquidData.radius);
    }
Exemplo n.º 16
0
    public void SetView(Liquid water, Liquid oil, Liquid mercury)
    {
        #region тупо хаrд код шляпа, нужен будет нормально рендер но пока и так сойдет
        _water.transform.localScale = new Vector3(rad, water.GetVolume(), rad);

        _oil.transform.localScale = new Vector3(rad, oil.GetVolume(), rad);

        _mercury.transform.localScale = new Vector3(rad, mercury.GetVolume(), rad);

        var totalVolume = oil.GetVolume() + water.GetVolume() + mercury.GetVolume();

        var totalHeight = totalVolume + .2f;

        _tube.transform.localScale = new Vector3(rad + .1f, totalHeight, rad + .1f);



        var basePostion = _tube.transform.position;


        var mercuryPosition = basePostion.y;
        var oilPosition     = mercuryPosition + mercury.GetVolume();
        var waterPosition   = oilPosition + oil.GetVolume();

        _mercury.transform.position = basePostion + new Vector3(0, mercuryPosition, 0);
        _oil.transform.position     = basePostion + new Vector3(0, oilPosition, 0);
        _water.transform.position   = basePostion + new Vector3(0, waterPosition, 0);

        #endregion
    }
Exemplo n.º 17
0
 public override void PreUpdate()
 {
     /*
      *          while (0 < Main.maxTilesX * Main.maxTilesY * (3E-05f * Main.worldRate))
      *          {
      *                  int tileX = WorldGen.genRand.Next(10, Main.maxTilesX - 10); //a random x tile
      *                  int tileY = WorldGen.genRand.Next(10, (int)Main.worldSurface - 1); //a psuedo random y tile based on the world surface
      *
      *                  int tileYAbovetileY = tileY - 1 < 10 ? 10 : tileY - 1; //the tile above the psuedo random tile y position
      *
      *                  Tile groundTile = Framing.GetTileSafely(tileX, tileY); //the ground tile that the new tile will be placed on
      *
      *                  //an array of all the tiles that will need to be free
      *                  Tile[] spaceRequired = new Tile[]
      *                  {
      *                          Framing.GetTileSafely(tileX, tileYAbovetileY), //bottom left
      *                          Framing.GetTileSafely(tileX, tileYAbovetileY - 1), //top left
      *                          Framing.GetTileSafely(tileX + 1, tileYAbovetileY), //bottom right
      *                          Framing.GetTileSafely(tileX + 1, tileYAbovetileY - 1) //top right
      *                  };
      *
      *                  //if the ground tile isnt null and its grass
      *                  if (groundTile != null && groundTile.type == TileID.Grass)
      *                  {
      *                          //loop through every required tile
      *                          foreach (Tile tile in spaceRequired)
      *                          {
      *                                  //if the tile isnt active; there is space for the new tile
      *                                  if (!tile.active())
      *                                  {
      *                                          if (WorldGen.genRand.NextBool(50)) //Random amount to slow down growing
      *                                          {
      *                                                  //place the 2x2 strawberry multitile
      *                                                  WorldGen.Place2x2(tileX, tileYAbovetileY - 1, (ushort)ModContent.TileType<StrawberryPlantTile>(), 0);
      *
      *                                                  //if its still active
      *                                                  if (tile.active())
      *                                                  {
      *                                                          //set the paint color to the ground tiles paint color
      *                                                          tile.color(groundTile.color());
      *
      *                                                          //Synce the multitile placement
      *                                                          if (Main.netMode == NetmodeID.Server)
      *                                                                  NetMessage.SendTileRange(-1, tileX, tileYAbovetileY - 1, 2, 2);
      *                                                  }
      *                                          }
      *                                  }
      *                          }
      *                  }
      *          }*/
     if (Subworld.IsActive <Dimensions.PlasmaDesert>())
     {
         if (++Liquid.skipCount > 1)
         {
             Liquid.UpdateLiquid();
             Liquid.skipCount = 0;
         }
     }
 }
Exemplo n.º 18
0
        public ActionResult DeleteConfirmed(int id)
        {
            Liquid liquid = db.Liquid.Find(id);

            db.Liquid.Remove(liquid);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 19
0
        private static bool LiquidIntersectionCheck(World world, Ray ray, Vector3i position)
        {
            LiquidInstance?liquid = world.GetLiquid(position);

            // Check if the ray intersects the bounding box of the liquid.
            return(liquid != null && liquid.Liquid != Liquid.None &&
                   Liquid.GetBoundingBox(position, liquid.Level).Intersects(ray));
        }
Exemplo n.º 20
0
 // Sets the field's friction to the given amount
 // 0 < X < 1 : oil-ish
 // X == 1    : natural
 // X > 1     : sticky
 public void AddLiquid(Liquid liquid)
 {
     if (liquid > 0)
     {
         underThis.Friction = (liquid.GetHashCode());
     }
     Console.WriteLine("Invalidate AddLiquid");
     Graphic.Invalidate();
 }
Exemplo n.º 21
0
        public void CanCreateLiquidInstance()
        {
            IMatter matter = new Liquid("Water", 1);

            Assert.NotNull(matter);
            Assert.Equal("Water", matter.Name);
            Assert.Equal(1, matter.Mass);
            Assert.Equal(States.Liquid, matter.State);
        }
Exemplo n.º 22
0
        public Coffee MakeBlackCoffee()
        {
            // Use them to make coffee
            Console.WriteLine("Making coffee with {0} and {1}.",
                              Liquid.GetType().Name,
                              PowderedCoffee.GetType().Name);

            return(new BlackCoffee());
        }
Exemplo n.º 23
0
 public void CleanUp()
 {
     CocktailLiquid.Delete();
     CocktailLiquid.Save();
     Cocktail.Delete();
     Cocktail.Save();
     Liquid.Delete();
     Liquid.Save();
 }
Exemplo n.º 24
0
 /// <summary>
 /// Cooling.
 /// </summary>
 /// <param name="liquid">Liquid in the system.</param>
 /// <param name="temperature">Required temperature.</param>
 public static void Heating(Liquid liquid, int temperature)
 {
     if (temperature > liquid?.Temperature)
     {
         System.Console.WriteLine($"A heating unit is running. \nIt is necessary to heat the liquid from {liquid.Temperature} to {temperature} degrees.");
         liquid.Temperature = temperature;
         System.Console.WriteLine($"The temperature liquid is set at {liquid.Temperature} degrees.");
     }
 }
Exemplo n.º 25
0
        ///<summary>
        ///Adds the newLiquid to the LiquidsDict with regards to the remainingSpace.
        ///If remainingSpace = -1, this condition is ignored.
        ///</summary>
        public void AddLiquidToMix(Liquid newLiquid, double remainingSpace)
        {
            LiquidMix newLiquidMix = new LiquidMix(newLiquid);

            Combine(newLiquidMix, remainingSpace);

            // Update stats according to the new levels
            UpdateInfo();
        }
Exemplo n.º 26
0
    /// <summary>
    /// Add one liquid to another, setting temps, adding components, setting amount.
    /// </summary>
    /// <param name="other">The other solution to be added to this one.</param>
    public void addToSolution(Liquid liquidToAdd)
    {
        //No temperature.
        //this.temperature = temperature * currentAmount + other.temperature * other.currentAmount;

        liquidComponents.Add(liquidToAdd);

        currentAmount += liquidToAdd.amount;
    }
Exemplo n.º 27
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.GetComponent <Water>())
     {
         GetComponent <SpriteRenderer>().color = Color.blue;
         liquid = Liquid.Water;
         GetComponent <Rigidbody2D>().mass = 2;
         Destroy(collision.gameObject);
     }
 }
Exemplo n.º 28
0
        public Liquid MaptoModel()
        {
            var liquid = new Liquid(this.Article, this.AmountIndicated, this.StrengthIndicated, this.Link, this.Name,
                                    this.Availability, this.Price, this.Strength, this.Amount)
            {
                Id = this.Id
            };

            return(liquid);
        }
Exemplo n.º 29
0
    public bool Dispense(float amount, Liquid temp)
    {
        bool isPosiible = temp.GetVolume() - amount > 0;

        if (isPosiible)
        {
            temp.AddVolume(-amount);
        }
        return(isPosiible);
    }
Exemplo n.º 30
0
    public bool Fill(float amount, Liquid temp)
    {
        bool isPosiible = temp.GetVolume() + amount < _volumeOfThisTube;

        if (isPosiible)
        {
            temp.AddVolume(amount);
        }
        return(isPosiible);
    }
Exemplo n.º 31
0
        public override void Load()
        {
            Name = "Liquid";
            Description = "A plugin to manipulate liquids";
            Author = "amarriner";
            Version = "0.2.2";
            TDSMBuild = 33;

            plugin = this;
        }
Exemplo n.º 32
0
        private void IrrigateButton_Click(object sender, RoutedEventArgs e)
        {
            var underGroundFarms = GnomanEmpire.Instance.Fortress.FarmManager.Farms.Where(x => x.Underground);

            foreach (var underGroundFarm in underGroundFarms)
            {
                var level = (int)underGroundFarm.RandomPosition().Z;

                foreach (var area in underGroundFarm.Areas)
                {
                    for (var x = 0; x <= area.Width; x++) // Width and height are one less than actual size?
                        for (var y = 0; y <= area.Height; y++)
                        {
                            var posX = x + area.Location.X;
                            var posY = y + area.Location.Y;
                            var mapCell = GnomanEmpire.Instance.Map.Levels[level][posY][posX];
                            if (mapCell.Liquid == null)
                            {
                                var position = new Vector3(posX, posY, level);
                                var water = new Liquid(position, Material.Water.ToString(), 1.0f, new Vector3(0, 0, 0), false);
                                mapCell.AddLiquid(water);
                            }
                        }
                }
            }
            AddStatusText("Irrigated underground farms");
        }
Exemplo n.º 33
0
        public void SwapLiquid()
        {
            switch (_liquid)
            {
                case Liquid.Lava: _liquid = Liquid.Honey; break;
                case Liquid.Water: _liquid = Liquid.Lava; break;
                default: _liquid = Liquid.Water; break;
            }

            RaisePropertyChanged("IsWater");
            RaisePropertyChanged("IsLava");
            RaisePropertyChanged("IsHoney");
        }
Exemplo n.º 34
0
 static void Main()
 {
     Liquid c = new Liquid();
     Console.WriteLine(c.Capacity());
 }
Exemplo n.º 35
0
 private void ContentRichTextBlock_LinkClicked(object sender, Liquid.RichTextBoxEventArgs e)
 {
     System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(e.Parameter.ToString()), "_blank");
 }