Beispiel #1
0
        public static void AddFluid(string name, ModFluid fluid)
        {
            int type;

            switch (name)
            {
            case "Water":
                type = 0;
                break;

            case "Lava":
                type = 1;
                break;

            case "Honey":
                type = 2;
                break;

            default:
                type = NextFluid();
                break;
            }

            fluid.type = type;
            fluid.Name = name;

            fluidNames[name] = fluid;
            fluids.Add(fluid);
        }
Beispiel #2
0
        private static void AutoloadFluid(Type type, Mod mod)
        {
            ModFluid fluid = (ModFluid)Activator.CreateInstance(type);
            string   name  = type.Name;

            fluid.DisplayName = mod.CreateTranslation(mod.Name + "." + name);
            fluid.mod         = mod;
            AddFluid(name, fluid);
        }
Beispiel #3
0
 public override void Load(TagCompound tag)
 {
     if (tag.Count > 0)
     {
         ModFluid f = Utility.Utility.SetDefaults(tag.GetString("Type"));
         f.volume = tag.GetInt("Volume");
         fluid    = f;
     }
 }
Beispiel #4
0
        internal static void SetDefaults(ModFluid fluid)
        {
            fluid = GetFluid(fluid.Name).NewInstance();

            fluid.SetDefaults();
        }
Beispiel #5
0
        public override bool UseItem(Player player)
        {
            if (player.altFunctionUse == 2)
            {
                if (fluid != null)
                {
                    Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY];
                    if ((!tile.nactive() || !Main.tileSolid[tile.type] || Main.tileSolidTop[tile.type]) && TileLoader.GetTile(tile.type)?.GetType().GetAttribute <BucketDisablePlacement>() == null)
                    {
                        if (tile.liquid == 0 || tile.liquidType() == fluid.type)
                        {
                            Main.PlaySound(19, (int)player.position.X, (int)player.position.Y);

                            if (tile.liquid == 0)
                            {
                                tile.liquidType(fluid.type);
                            }

                            int volume = Math.Min(fluid.volume, 255 - tile.liquid);
                            tile.liquid  += (byte)volume;
                            fluid.volume -= volume;
                            if (fluid.volume <= 0)
                            {
                                fluid = null;
                            }

                            WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY);

                            if (Main.netMode == NetmodeID.MultiplayerClient)
                            {
                                NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
                            }
                            NetUtility.SyncItem(item);
                        }
                    }
                }
            }
            else
            {
                if (!Main.GamepadDisableCursorItemIcon)
                {
                    player.showItemIcon = true;
                    Main.ItemIconCacheUpdate(item.type);
                }

                Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY];
                if ((fluid == null || fluid.type == tile.liquidType()) && tile.liquid > 0 && TileLoader.GetTile(tile.type)?.GetType().GetAttribute <BucketDisablePickup>() == null)
                {
                    Main.PlaySound(19, (int)player.position.X, (int)player.position.Y);

                    if (fluid == null)
                    {
                        fluid = Utility.Utility.SetDefaults(tile.liquidType());
                    }

                    int drain = Math.Min(tile.liquid, MaxAmount - fluid.volume);
                    fluid.volume += drain;

                    tile.liquid -= (byte)drain;

                    if (tile.liquid <= 0)
                    {
                        tile.lava(false);
                        tile.honey(false);
                    }

                    WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, false);
                    if (Main.netMode == NetmodeID.MultiplayerClient)
                    {
                        NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
                    }
                    else
                    {
                        Liquid.AddWater(Player.tileTargetX, Player.tileTargetY);
                    }

                    NetUtility.SyncItem(item);
                }
            }

            return(true);
        }
Beispiel #6
0
 public void SetFluid(ModFluid value, int slot = 0) => fluid = value;