Esempio n. 1
0
        public override bool OnFarmWork(GameSession session)
        {
            if (!Program.Instance.Config.ReadCustomBool("superplow", "maintainplots", false))
                return true;

            List<PlotDefinition> toPlot = new List<PlotDefinition>();
            foreach (PlotDefinition plotSetting in _plotDefinitions)
            {
                string hashKey = plotSetting.X.ToString() + "," + plotSetting.Y.ToString();
                if (session.World.SuperPlots.ContainsKey(hashKey))
                {
                    int leftOver = plotSetting.PlotCount - session.World.SuperPlots[hashKey].Count;
                    if ( leftOver > 0 )
                        toPlot.Add(new PlotDefinition() { PlotCount = leftOver, X = plotSetting.X, Y = plotSetting.Y });
                }
            }

            if ( toPlot.Count == 0 )
                return true;

            foreach ( PlotDefinition plot in toPlot )
            {
                int plotCount = plot.PlotCount;
                string hashKey = plot.X.ToString() + "," + plot.Y.ToString();
                for ( int  x = 0; x< plotCount; x++ )
                {

                    Game.Objects.PlotObject newplot = new Game.Objects.PlotObject();
                    newplot.ClassName = "Plot";
                    newplot.Giftable = false;
                    newplot.GiftSenderId = "";
                    newplot.HasGiftRemaining = false;
                    newplot.Id = 0;
                    newplot.IsBigPlot = false;
                    newplot.IsJumbo = false;
                    newplot.IsProduceItem = false;
                    newplot.ItemName = "";
                    newplot.State = "plowed";
                    newplot.UsesAltGraphic = false;
                    newplot.PlantTime = float.NaN;
                    newplot.Position = new Game.Classes.ObjectPosition() { X = plot.X, Y = plot.Y, Z = 0 };
                    if ( !newplot.Plow() )
                        return false;
                    session.World.ObjectsArray.Add(newplot);
                    if ( !session.World.SuperPlots.ContainsKey( hashKey ) )
                        session.World.SuperPlots.Add( hashKey, new List<Game.Objects.PlotObject>() );
                    session.World.SuperPlots[hashKey].Add(newplot);
                }
            }
            return true;
        }
Esempio n. 2
0
 public PlantPlotSubRequest(int sequence, Game.Objects.PlotObject plot, string plantName )
     : base(sequence, "WorldService.performAction")
 {
     _plot = plot;
     PlantRequest = plantName;
 }
 public HarvestPlotSubRequest(int sequence, Game.Objects.PlotObject plot)
     : base(sequence, "WorldService.performAction")
 {
     _plot = plot;
 }