Ejemplo n.º 1
0
        private void OnPaint(UIElement element, SKCanvas canvas)
        {
            Timer.Update();

            var deltaTime = HipsterEngine.DeltaTime.GetDeltaTime();

            mControl.Update();
            mControl.Draw();
            aControl.Draw();

            HipsterEngine.Surface.Canvas.Save();
            HipsterEngine.Surface.Canvas.Translate(HipsterEngine.Surface.Canvas.Camera.X,
                                                   HipsterEngine.Surface.Canvas.Camera.Y);
            HipsterEngine.Surface.Canvas.Scale(HipsterEngine.Surface.Canvas.Camera.ScaleX, HipsterEngine.Surface.Canvas.Camera.ScaleY);
            Earth.Step();
            Earth.Draw();
            Trees.ForEach(t =>
            {
                t.Step();
                t.Draw();
            });
            //  Robots.ForEach(r =>
            //   {
            //    r.Update(1, 1);
            //    r.Draw(HipsterEngine.Surface.Canvas);
            //  });

            HipsterEngine.Physics.Step(1.0f, 20);
            HipsterEngine.Particles.Draw(HipsterEngine.Surface.Canvas.GetSkiaCanvas());
            HipsterEngine.Surface.Canvas.Restore();
        }
Ejemplo n.º 2
0
        private static void Prefix(IDifficultyBeatmap difficultyBeatmap, ref OverrideEnvironmentSettings overrideEnvironmentSettings)
        {
            if (difficultyBeatmap.beatmapData is CustomBeatmapData customBeatmapData)
            {
                IEnumerable <string> requirements = ((List <object>)Trees.at(customBeatmapData.beatmapCustomData, "_requirements"))?.Cast <string>();
                IEnumerable <string> suggestions  = ((List <object>)Trees.at(customBeatmapData.beatmapCustomData, "_suggestions"))?.Cast <string>();
                bool chromaRequirement            = (requirements?.Contains(Chroma.Plugin.REQUIREMENTNAME) ?? false) || (suggestions?.Contains(Chroma.Plugin.REQUIREMENTNAME) ?? false);

                // please let me remove this shit
                bool legacyOverride = difficultyBeatmap.beatmapData.beatmapEventsData.Any(n => n.value >= LegacyLightHelper.RGB_INT_OFFSET);
                if (legacyOverride)
                {
                    ChromaLogger.Log("Legacy Chroma Detected...", IPA.Logging.Logger.Level.Warning);
                    ChromaLogger.Log("Please do not use Legacy Chroma for new maps as it is deprecated and its functionality in future versions of Chroma cannot be guaranteed", IPA.Logging.Logger.Level.Warning);
                }

                ChromaController.ToggleChromaPatches((chromaRequirement || legacyOverride) && ChromaConfig.Instance.CustomColorEventsEnabled);
                ChromaController.DoColorizerSabers = chromaRequirement && ChromaConfig.Instance.CustomColorEventsEnabled;

                if (chromaRequirement && ChromaConfig.Instance.EnvironmentEnhancementsEnabled && Trees.at(customBeatmapData.beatmapCustomData, "_environmentRemoval") != null)
                {
                    overrideEnvironmentSettings = null;
                }
            }
        }
 private static void ProcessFlipData(List <CustomNoteData> customNotes, bool defaultFlip = true)
 {
     for (int i = customNotes.Count - 1; i >= 0; i--)
     {
         dynamic dynData           = customNotes[i].customData;
         IEnumerable <float?> flip = ((List <object>)Trees.at(dynData, FLIP))?.Select(n => n.ToNullableFloat());
         float?flipX = flip?.ElementAtOrDefault(0);
         float?flipY = flip?.ElementAtOrDefault(1);
         if (flipX.HasValue || flipY.HasValue)
         {
             if (flipX.HasValue)
             {
                 dynData.flipLineIndex = flipX.Value;
             }
             if (flipY.HasValue)
             {
                 dynData.flipYSide = flipY.Value;
             }
             customNotes.Remove(customNotes[i]);
         }
     }
     if (defaultFlip)
     {
         customNotes.ForEach(c => c.customData.flipYSide = 0);
     }
 }
        private static void Prefix(ObstacleData __instance) // prefix because we need to know the lineIndex before it gets mirrored
        {
            if (__instance is CustomObstacleData customData)
            {
                dynamic dynData = customData.customData;
                IEnumerable <float?> position = ((List <object>)Trees.at(dynData, POSITION))?.Select(n => n.ToNullableFloat());
                IEnumerable <float?> scale    = ((List <object>)Trees.at(dynData, SCALE))?.Select(n => n.ToNullableFloat());
                List <float>         localrot = ((List <object>)Trees.at(dynData, LOCALROTATION))?.Select(n => Convert.ToSingle(n)).ToList();
                dynamic rotation = Trees.at(dynData, ROTATION);

                float?startX = position?.ElementAtOrDefault(0);
                float?scaleX = scale?.ElementAtOrDefault(0);

                IDictionary <string, object> dictdata = dynData as IDictionary <string, object>;

                float width = scaleX.GetValueOrDefault(__instance.width);
                if (startX.HasValue)
                {
                    dictdata[POSITION] = new List <object>()
                    {
                        (startX.Value + width) * -1, position.ElementAtOrDefault(1)
                    };
                }
                else if (scaleX.HasValue)
                {
                    float lineIndex = __instance.lineIndex - 2;
                    dictdata[POSITION] = new List <object>()
                    {
                        (lineIndex + width) * -1, position?.ElementAtOrDefault(1) ?? 0
                    };
                }

                if (localrot != null)
                {
                    List <float> rot            = localrot.Select(n => Convert.ToSingle(n)).ToList();
                    Quaternion   modifiedVector = Quaternion.Euler(rot[0], rot[1], rot[2]);
                    Vector3      vector         = new Quaternion(modifiedVector.x, modifiedVector.y * -1, modifiedVector.z * -1, modifiedVector.w).eulerAngles;
                    dictdata[LOCALROTATION] = new List <object> {
                        vector.x, vector.y, vector.z
                    };
                }

                if (rotation != null)
                {
                    if (rotation is List <object> list)
                    {
                        List <float> rot            = list.Select(n => Convert.ToSingle(n)).ToList();
                        Quaternion   modifiedVector = Quaternion.Euler(rot[0], rot[1], rot[2]);
                        Vector3      vector         = new Quaternion(modifiedVector.x, modifiedVector.y * -1, modifiedVector.z * -1, modifiedVector.w).eulerAngles;
                        dictdata[ROTATION] = new List <object> {
                            vector.x, vector.y, vector.z
                        };
                    }
                    else
                    {
                        dictdata[ROTATION] = rotation * -1;
                    }
                }
            }
        }
Ejemplo n.º 5
0
      private void FormatNodes(Graph graph, ITree tree, IList<string> parserRules)
      {
         var node = graph.FindNode(tree.GetHashCode().ToString());
         if (node != null)
         {
            node.LabelText = Trees.GetNodeText(tree, parserRules);

            var ruleFailedAndMatchedNothing = false;

            if (tree is ParserRuleContext context)
               ruleFailedAndMatchedNothing =
                  // ReSharper disable once ComplexConditionExpression
                  context.exception != null &&
                  context.stop != null
                  && context.stop.TokenIndex < context.start.TokenIndex;

            if (tree is IErrorNode || ruleFailedAndMatchedNothing)
               node.Label.FontColor = Color.Red;
            else
               node.Label.FontColor = TextColor ?? Color.Black;

            node.Attr.Color = BorderColor ?? Color.Black;

            if (BackgroundColor.HasValue)
               node.Attr.FillColor = BackgroundColor.Value;

            node.Attr.Color = BorderColor ?? Color.Black;

            node.UserData = tree;
         }

         for (int i = 0; i < tree.ChildCount; i++)
            FormatNodes(graph, tree.GetChild(i), parserRules);
      }
Ejemplo n.º 6
0
        private void mnuNodesReload_Click(object sender, EventArgs e)
        {
            IBaseNode currentNode = TreeNodeAsBaseNode(tvDecisionTree.SelectedNode);

            if (currentNode != null)
            {
                IDecisionTree tree = currentNode.Tree;

                bool CanDelete = false;

                if (tree.IsDirty)
                {
                    CanDelete = App.GetFloatingForm(eFloatReason.NotSet, new ucConfirmDropModel(tree)).ShowDialog() == DialogResult.OK;
                }
                else
                {
                    CanDelete = true;
                }

                if (CanDelete)
                {
                    int           treeIndex = Trees.IndexOf(tree);
                    IDecisionTree newTree   = App.NewDescisionTree();
                    newTree.Load(tree.Persistence.Clone(), tree.FullPath);

                    Trees.Remove(tree);
                    Trees.Insert(treeIndex, newTree);
                    RefreshTree(tvDecisionTree);

                    App.SelectedTree = Trees.Count > 0 ? Trees[0] : null;

                    App.SelectedObject = Trees.Count > 0 ? Trees[0] : null;
                }
            }
        }
Ejemplo n.º 7
0
        protected override void Initialize()
        {
            Textures.LoadTextures(this.Content);

            #region Camera
            Camera           = new Camera(Graphics.GraphicsDevice);
            CameraPosition.X = Graphics.PreferredBackBufferWidth * 1.0f / 2;
            CameraPosition.Y = Graphics.PreferredBackBufferHeight * 1.0f / 2;
            #endregion

            #region Screen Setup
            //ResolutionHandler.resolution = ResolutionHandler.Resolution.Three;

            //ToDo 3 Fix to draw background texture to fill all of the background
            MapSizeX = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            MapSizeY = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

            SpriteBatch = new SpriteBatch(GraphicsDevice);

            Window.Title = "Zeds - Alpha " + versionNumber;
            #endregion

            #region Mouse
            IsMouseVisible     = false;
            MouseCoordinates.X = Graphics.PreferredBackBufferWidth * 1.0f / 2;
            MouseCoordinates.Y = Graphics.PreferredBackBufferWidth * 1.0f / 2;
            KeyBindings.PreviousScrollValue = 0;
            #endregion

            //Initial set up
            HQ.HQSetup();
            HumanNames.PopulateNamesLists();

            HumanSpawner.SpawnHumans();
            GrantStartingItems.PopulateItemList();

            #region Terrain
            GrassTufts.CreateGrassTufts();
            Bushes.CreateBushes();
            Trees.CreateTrees();
            Trees.CreateTreeFoliage();
            #endregion

            #region Build Menu
            BuildingPlacementHandler.SelectedStructure = BuildingSelected.None;

            PopulateBuildMenus.PopulateMenuIconList();
            BuildMenuPane.InitialiseBuildMenuLocation();
            BuildMenuPane.IsBuildMenuWindowVisible = true;
            BuildMenuRollOverText.UpdateRollOverTextPosition();
            #endregion

            DetailsPane.CreateDetailsPane(new Vector2((ScreenWidth / 2) - (Textures.DetailsWindowPane.Width / 2), 10), "");

            base.Initialize();

            ZedController.PopulateZedList();

            Grid.SetUpGrid();
        }
Ejemplo n.º 8
0
        public int FilterByTreeID(List <int> treeIDlist)
        {
            List <MutableTuple <Trees, List <int> > > filteredTrees = new();
            int treesSelected = 0;

            foreach (MutableTuple <Trees, List <int> > treesOfSpecies in this.mTreesInMostRecentlyLoadedStand)
            {
                Trees      trees = treesOfSpecies.Item1;
                List <int>?treeIndicesInSpecies = null;
                foreach (int treeID in treeIDlist)
                {
                    int treeIndex = trees.Tag.IndexOf(treeID);
                    if (treeIndex > -1)
                    {
                        if (treeIndicesInSpecies == null)
                        {
                            treeIndicesInSpecies = new List <int>();
                            filteredTrees.Add(new MutableTuple <Trees, List <int> >(trees, treeIndicesInSpecies));
                        }

                        treeIndicesInSpecies.Add(treeIndex);
                        ++treesSelected;
                    }
                }
            }

            this.mTreesInMostRecentlyLoadedStand = filteredTrees;
            return(treesSelected);
        }
Ejemplo n.º 9
0
        private static void Postfix(ObstacleData obstacleData, ref Vector3 moveStartPos, ref Vector3 moveEndPos, ref Vector3 jumpEndPos, ref float obstacleHeight)
        {
            if (obstacleData is CustomObstacleData customData)
            {
                dynamic dynData = customData.customData;
                IEnumerable <float?> position = ((List <object>)Trees.at(dynData, POSITION))?.Select(n => n.ToNullableFloat());
                IEnumerable <float?> scale    = ((List <object>)Trees.at(dynData, SCALE))?.Select(n => n.ToNullableFloat());
                float?njs         = (float?)Trees.at(dynData, NOTEJUMPSPEED);
                float?spawnoffset = (float?)Trees.at(dynData, SPAWNOFFSET);

                float?startX = position?.ElementAtOrDefault(0);
                float?startY = position?.ElementAtOrDefault(1);

                float?height = scale?.ElementAtOrDefault(1);

                // Actual wall stuff
                if (startX.HasValue || startY.HasValue || njs.HasValue || spawnoffset.HasValue)
                {
                    GetNoteJumpValues(njs, spawnoffset, out float _, out float _, out Vector3 _localMoveStartPos, out Vector3 _localMoveEndPos, out Vector3 _localJumpEndPos);

                    // Ripped from base game
                    Vector3 noteOffset = GetNoteOffset(obstacleData, startX, null);
                    noteOffset.y = startY.HasValue ? _verticalObstaclePosY + startY.GetValueOrDefault(0) * _noteLinesDistance : ((obstacleData.obstacleType == ObstacleType.Top)
                        ? (_topObstaclePosY + _jumpOffsetY) : _verticalObstaclePosY);
                    moveStartPos = _localMoveStartPos + noteOffset;
                    moveEndPos   = _localMoveEndPos + noteOffset;
                    jumpEndPos   = _localJumpEndPos + noteOffset;
                }
                if (height.HasValue)
                {
                    obstacleHeight = height.Value * _noteLinesDistance;
                }
            }
        }
Ejemplo n.º 10
0
        public void AddIngrowth(int year, OrganonStand stand, OrganonStandDensity standDensity)
        {
            List <int> remainingIngrowthYears = this.IngrowthByYear.Keys.Where(key => key > this.yearOfMostRecentIngrowthAdded).ToList();

            if ((remainingIngrowthYears.Count < 1) || (remainingIngrowthYears[0] > year))
            {
                // no ingrowth in this simulation step
                return;
            }
            int ingrowthYear = remainingIngrowthYears[0];

            Debug.Assert((remainingIngrowthYears.Count == 1) || (remainingIngrowthYears[1] > year)); // for now, assume only one ingrowth measurement per simulation timestep

            float fixedPlotExpansionFactor = this.GetTreesPerAcreExpansionFactor();

            foreach (PspTreeMeasurementSeries tree in this.IngrowthByYear[ingrowthYear])
            {
                Trees treesOfSpecies = stand.TreesBySpecies[tree.Species];
                Debug.Assert(treesOfSpecies.Capacity > treesOfSpecies.Count);

                float dbhInInches  = Constant.InchesPerCentimeter * tree.DbhInCentimetersByYear.Values[0];
                float heightInFeet = TestConstant.FeetPerMeter * TreeRecord.EstimateHeightInMeters(tree.Species, dbhInInches);
                treesOfSpecies.Add(tree.Tag, dbhInInches, heightInFeet, tree.EstimateInitialCrownRatio(standDensity), fixedPlotExpansionFactor);
            }

            this.yearOfMostRecentIngrowthAdded = ingrowthYear;
        }
Ejemplo n.º 11
0
        public void Remove(TreeInfo treeInfo)
        {
            var  name = treeInfo.name;
            Tree tree = Trees.Find(t => t.Name == name);

            Trees.Remove(tree);
        }
Ejemplo n.º 12
0
        public override int GetHashCode()
        {
            // stolen from GPNode.  It's a decent algorithm.
            var hash = GetType().GetHashCode();

            return(Trees.Aggregate(hash, (current, t) => (current << 1 | BitShifter.URShift(current, 31)) ^ t.TreeHashCode()));
        }
Ejemplo n.º 13
0
        protected override void LogYear(Model model, SqliteCommand insertRow)
        {
            foreach (MutableTuple <Trees, List <MortalityCause> > removedTreesOfSpecies in this.removedTreesByResourceUnit.Values)
            {
                Trees trees = removedTreesOfSpecies.Item1;
                for (int treeIndex = 0; treeIndex < trees.Count; ++treeIndex)
                {
                    insertRow.Parameters[0].Value  = model.CurrentYear;
                    insertRow.Parameters[1].Value  = trees.RU.ResourceUnitGridIndex;
                    insertRow.Parameters[2].Value  = trees.RU.EnvironmentID;
                    insertRow.Parameters[3].Value  = trees.Species.ID;
                    insertRow.Parameters[4].Value  = trees.Tag[treeIndex];
                    insertRow.Parameters[5].Value  = (int)removedTreesOfSpecies.Item2[treeIndex];
                    insertRow.Parameters[6].Value  = trees.GetCellCenterPoint(treeIndex).X;
                    insertRow.Parameters[7].Value  = trees.GetCellCenterPoint(treeIndex).Y;
                    insertRow.Parameters[8].Value  = trees.Dbh[treeIndex];
                    insertRow.Parameters[9].Value  = trees.Height[treeIndex];
                    insertRow.Parameters[10].Value = trees.GetBasalArea(treeIndex);
                    insertRow.Parameters[11].Value = trees.GetStemVolume(treeIndex);
                    insertRow.Parameters[12].Value = trees.LeafArea[treeIndex];
                    insertRow.Parameters[13].Value = trees.FoliageMass[treeIndex];
                    insertRow.Parameters[14].Value = trees.StemMass[treeIndex];
                    insertRow.Parameters[15].Value = trees.FineRootMass[treeIndex];
                    insertRow.Parameters[16].Value = trees.CoarseRootMass[treeIndex];
                    insertRow.Parameters[17].Value = trees.LightResourceIndex[treeIndex];
                    insertRow.Parameters[18].Value = trees.LightResponse[treeIndex];
                    insertRow.Parameters[19].Value = trees.StressIndex[treeIndex];
                    insertRow.Parameters[20].Value = trees.NppReserve[treeIndex];
                    insertRow.ExecuteNonQuery();
                }
            }

            this.removedTreesByResourceUnit.Clear();
        }
Ejemplo n.º 14
0
        public void insertTree(Trees.QuadTree.QuadTree<Map.Block> tree, Map.Rectangle location)
        {
            MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = String.Format("INSERT INTO `tiles` (`coord`, `image`) VALUES");
            cmd.Connection = connection;
            bool first = true;

            for (int x = 0; x < tiles; x++)
            {
                for (int y = 0; y < tiles; y++)
                {
                    Map.Block block = tree.Get(new Map.Rectangle(x, y, 1));

                    if (block != null)
                    {
                        if (!first)
                        {
                            cmd.CommandText += ",";
                        }
                        else
                        {
                            first = false;
                        }

                        cmd.CommandText += String.Format("({0}, {1})", getPolygonString(x + location.x, y + location.y, block.location.width), block.val);
                    }
                }
            }

            mutex.WaitOne();
            connection.Open();
            cmd.ExecuteNonQuery();
            connection.Close();
            mutex.ReleaseMutex();
        }
        public void SingleRootNodeTest()
        {
            Node  node  = new Node(20);
            Trees testy = new Trees(node);

            Assert.Equal(node, testy.Root);
        }
Ejemplo n.º 16
0
        public bool TryAddTree(Model model, Trees trees, int treeIndex, MortalityCause reason)
        {
            if (this.treeFilter.IsEmpty == false)
            {
                // skip trees if filter is present
                TreeWrapper treeWrapper = new(model)
                {
                    Trees     = trees,
                    TreeIndex = treeIndex
                };
                this.treeFilter.Wrapper = treeWrapper;
                if (this.treeFilter.Execute() == 0.0)
                {
                    return(false);
                }
            }

            if (this.removedTreesByResourceUnit.TryGetValue(trees.RU, out MutableTuple <Trees, List <MortalityCause> >?removedTreesOfSpecies) == false)
            {
                removedTreesOfSpecies = new MutableTuple <Trees, List <MortalityCause> >(new Trees(model.Landscape, trees.RU, trees.Species),
                                                                                         new List <MortalityCause>());
                this.removedTreesByResourceUnit.Add(trees.RU, removedTreesOfSpecies);
            }

            removedTreesOfSpecies.Item1.Add(trees, treeIndex);
            removedTreesOfSpecies.Item2.Add(reason);
            return(true);
        }
Ejemplo n.º 17
0
 public void BasicTest()
 {
     Assert.AreEqual(new List <int>()
     {
         1, 2, 3, 4, 5, 6
     }, Trees.TreeByLevels(new Node(new Node(null, new Node(null, null, 4), 2), new Node(new Node(null, null, 5), new Node(null, null, 6), 3), 1)));
 }
Ejemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        stats                       = GetComponent <Stats>();
        treeList                    = GetComponent <Trees>();
        turnSystem                  = GetComponent <TurnSystem>();
        maxTurnText.text            = maxTurns.ToString();
        co2Force                    = trees.Count;
        gameTurnDuration            = 5f;
        turnCount                   = 0;
        doOnce                      = true;
        doOnce2                     = true;
        buildButtonBool             = true;
        mineMultiplier              = 160f;
        woodMultiplier              = 1.1f;
        happinessIncreaseMultiplier = .25f;
        happinessDecreaseMultiplier = .1f;

        //Resource Variables
        windmillEnergy      = .2f;
        windmillMultiplier  = 2.1f;
        solarEnergy         = 1f;
        solarPower          = .6f;
        factoryPower        = .5f;
        factoriesMultiplier = 1f;
        house2Multiplier    = 1f;
        co2Multiplier       = 1.5f;
    }
Ejemplo n.º 19
0
        private static Quaternion GetWorldRotation(ObstacleData obstacleData, float @default)
        {
            Quaternion worldRotation = Quaternion.Euler(0, @default, 0);

            if (obstacleData is CustomObstacleData customData)
            {
                dynamic dynData  = customData.customData;
                dynamic rotation = Trees.at(dynData, ROTATION);

                if (rotation != null)
                {
                    if (rotation is List <object> list)
                    {
                        IEnumerable <float> rot = list.Select(n => Convert.ToSingle(n));
                        worldRotation = Quaternion.Euler(rot.ElementAt(0), rot.ElementAt(1), rot.ElementAt(2));
                    }
                    else
                    {
                        worldRotation = Quaternion.Euler(0, (float)rotation, 0);
                    }
                }

                dynData.worldRotation = worldRotation;
            }

            return(worldRotation);
        }
Ejemplo n.º 20
0
        public static IEnumerable <Track> GetTrackArray(dynamic customData, string name = TRACK)
        {
            IEnumerable <string> trackNames = ((List <object>)Trees.at(customData, name)).Cast <string>();

            if (trackNames == null)
            {
                return(null);
            }

            HashSet <Track> tracks = new HashSet <Track>();

            foreach (string trackName in trackNames)
            {
                if (Tracks.TryGetValue(trackName, out Track track))
                {
                    tracks.Add(track);
                }
                else
                {
                    NoodleLogger.Log($"Could not find track {trackName}!", IPA.Logging.Logger.Level.Error);
                }
            }

            return(tracks);
        }
Ejemplo n.º 21
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Postfix(Vector3 ____centerPos, ObstacleData obstacleData, ref BeatmapObjectSpawnMovementData.ObstacleSpawnData __result)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (obstacleData is CustomObstacleData customData)
            {
                dynamic dynData = customData.customData;
                IEnumerable <float?> position = ((List <object>)Trees.at(dynData, POSITION))?.Select(n => n.ToNullableFloat());
                IEnumerable <float?> scale    = ((List <object>)Trees.at(dynData, SCALE))?.Select(n => n.ToNullableFloat());
                float?njs         = (float?)Trees.at(dynData, NOTEJUMPSPEED);
                float?spawnoffset = (float?)Trees.at(dynData, NOTESPAWNOFFSET);

                float?startX = position?.ElementAtOrDefault(0);
                float?startY = position?.ElementAtOrDefault(1);

                float?height = scale?.ElementAtOrDefault(1);

                Vector3?finalNoteOffset = null;

                Vector3 moveStartPos   = __result.moveStartPos;
                Vector3 moveEndPos     = __result.moveEndPos;
                Vector3 jumpEndPos     = __result.jumpEndPos;
                float   obstacleHeight = __result.obstacleHeight;
                GetNoteJumpValues(njs, spawnoffset, out float jumpDuration, out float _, out Vector3 _, out Vector3 _, out Vector3 _);

                // Actual wall stuff
                if (startX.HasValue || startY.HasValue || njs.HasValue || spawnoffset.HasValue)
                {
                    GetNoteJumpValues(njs, spawnoffset, out float _, out float _, out Vector3 localMoveStartPos, out Vector3 localMoveEndPos, out Vector3 localJumpEndPos);

                    // Ripped from base game
                    Vector3 noteOffset = GetNoteOffset(obstacleData, startX, null);
                    noteOffset.y = startY.HasValue ? VerticalObstaclePosY + (startY.GetValueOrDefault(0) * NoteLinesDistance) : ((obstacleData.obstacleType == ObstacleType.Top)
                        ? (TopObstaclePosY + JumpOffsetY) : VerticalObstaclePosY);

                    finalNoteOffset = noteOffset;

                    moveStartPos = localMoveStartPos + noteOffset;
                    moveEndPos   = localMoveEndPos + noteOffset;
                    jumpEndPos   = localJumpEndPos + noteOffset;
                }

                if (height.HasValue)
                {
                    obstacleHeight = height.Value * NoteLinesDistance;
                }

                __result = new BeatmapObjectSpawnMovementData.ObstacleSpawnData(moveStartPos, moveEndPos, jumpEndPos, obstacleHeight, __result.moveDuration, jumpDuration, __result.noteLinesDistance);

                if (!finalNoteOffset.HasValue)
                {
                    Vector3 noteOffset = GetNoteOffset(obstacleData, startX, null);
                    noteOffset.y    = (obstacleData.obstacleType == ObstacleType.Top) ? (TopObstaclePosY + JumpOffsetY) : VerticalObstaclePosY;
                    finalNoteOffset = noteOffset;
                }

                dynData.noteOffset = ____centerPos + finalNoteOffset.Value;
                float?width = scale?.ElementAtOrDefault(0);
                dynData.xOffset = ((width.GetValueOrDefault(obstacleData.lineIndex) / 2f) - 0.5f) * NoteLinesDistance;
            }
        }
Ejemplo n.º 22
0
 public void TreeDeath(Trees tree, MortalityCause mortalityCause)
 {
     for (int index = 0; index < mTreeDeath.Count; ++index)
     {
         mTreeDeath[index].TreeDeath(tree, mortalityCause);
     }
 }
Ejemplo n.º 23
0
        private static void Postfix(ObstacleData __instance)
        {
            if (__instance is CustomObstacleData customData)
            {
                dynamic dynData = customData.customData;
                IEnumerable <float?> position = ((List <object>)Trees.at(dynData, POSITION))?.Select(n => n.ToNullableFloat());
                IEnumerable <float?> scale    = ((List <object>)Trees.at(dynData, SCALE))?.Select(n => n.ToNullableFloat());
                List <float>         localrot = ((List <object>)Trees.at(dynData, LOCALROTATION))?.Select(n => Convert.ToSingle(n)).ToList();
                float?rotation = (float?)Trees.at(dynData, ROTATION);

                float?startX = position?.ElementAtOrDefault(0);
                float?scaleX = scale?.ElementAtOrDefault(0);

                IDictionary <string, object> dictdata = dynData as IDictionary <string, object>;

                float width = scaleX.GetValueOrDefault(__instance.width);
                if (startX.HasValue)
                {
                    dictdata[POSITION] = new List <object>()
                    {
                        (startX.Value + width) * -1, position.ElementAtOrDefault(1)
                    }
                }
                ;
                if (localrot != null)
                {
                    dictdata[LOCALROTATION] = localrot.Select(n => n *= 1).Cast <object>().ToList();
                }
                if (rotation.HasValue)
                {
                    dictdata[ROTATION] = rotation * -1;
                }
            }
        }
    }
Ejemplo n.º 24
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Postfix(BeatmapObjectSpawnMovementData __instance, Vector3 ____centerPos, float ____jumpDuration, NoteData noteData, ref BeatmapObjectSpawnMovementData.NoteSpawnData __result)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (noteData is CustomNoteData customData)
            {
                dynamic dynData = customData.customData;
                IEnumerable <float?> position = ((List <object>)Trees.at(dynData, POSITION))?.Select(n => n.ToNullableFloat());
                float?flipLineIndex           = (float?)Trees.at(dynData, "flipLineIndex");
                float?njs            = (float?)Trees.at(dynData, NOTEJUMPSPEED);
                float?spawnoffset    = (float?)Trees.at(dynData, NOTESPAWNOFFSET);
                float?startlinelayer = (float?)Trees.at(dynData, "startNoteLineLayer");

                bool gravityOverride = (bool?)Trees.at(dynData, NOTEGRAVITYDISABLE) ?? false;

                float?startRow    = position?.ElementAtOrDefault(0);
                float?startHeight = position?.ElementAtOrDefault(1);

                float jumpDuration = ____jumpDuration;

                Vector3 moveStartPos = __result.moveStartPos;
                Vector3 moveEndPos   = __result.moveEndPos;
                Vector3 jumpEndPos   = __result.jumpEndPos;
                float   jumpGravity  = __result.jumpGravity;

                Vector3 noteOffset = GetNoteOffset(noteData, startRow, startlinelayer ?? (float)noteData.startNoteLineLayer);

                if (position != null || flipLineIndex != null || njs.HasValue || spawnoffset.HasValue || startlinelayer.HasValue || gravityOverride)
                {
                    GetNoteJumpValues(njs, spawnoffset, out float localJumpDuration, out float localJumpDistance, out Vector3 localMoveStartPos, out Vector3 localMoveEndPos, out Vector3 localJumpEndPos);
                    jumpDuration = localJumpDuration;

                    float localNoteJumpMovementSpeed = njs ?? NoteJumpMovementSpeed;

                    float startLayerLineYPos = LineYPosForLineLayer(noteData, startlinelayer ?? (float)noteData.startNoteLineLayer);
                    float lineYPos           = LineYPosForLineLayer(noteData, startHeight);

                    // Magic numbers below found with linear regression y=mx+b using existing HighestJumpPosYForLineLayer values
                    float highestJump = startHeight.HasValue ? (0.875f * lineYPos) + 0.639583f + JumpOffsetY :
                                        __instance.HighestJumpPosYForLineLayer(noteData.noteLineLayer);
                    jumpGravity = 2f * (highestJump - (gravityOverride ? lineYPos : startLayerLineYPos)) /
                                  Mathf.Pow(localJumpDistance / localNoteJumpMovementSpeed * 0.5f, 2f);

                    jumpEndPos = localJumpEndPos + noteOffset;

                    // IsBasicNote() check is skipped so bombs can flip too
                    Vector3 noteOffset2 = GetNoteOffset(noteData, flipLineIndex ?? startRow, gravityOverride ? startHeight : startlinelayer ?? (float)noteData.startNoteLineLayer);
                    moveStartPos = localMoveStartPos + noteOffset2;
                    moveEndPos   = localMoveEndPos + noteOffset2;

                    __result = new BeatmapObjectSpawnMovementData.NoteSpawnData(moveStartPos, moveEndPos, jumpEndPos, jumpGravity, __result.moveDuration, jumpDuration);
                }

                // DEFINITE POSITION IS WEIRD, OK?
                // ty reaxt
                float startVerticalVelocity = jumpGravity * jumpDuration * 0.5f;
                float num     = jumpDuration * 0.5f;
                float yOffset = (startVerticalVelocity * num) - (jumpGravity * num * num * 0.5f);
                dynData.noteOffset = ____centerPos + noteOffset + new Vector3(0, yOffset, 0);
            }
        }
Ejemplo n.º 25
0
        public static void DeleteTree(CTree pTree)
        {
            if (pTree.treeIndex == 169)
            {
                bool i = true;
            }

            if (!Trees.Contains(pTree))
            {
                CDebug.Error("Trees dont contain " + pTree);
                return;
            }
            pTree.peakDetailField.RemoveTree(pTree);
            pTree.peakNormalField.RemoveTree(pTree);
            foreach (CTreeField field in pTree.detailFields)
            {
                field.RemoveTree(pTree);
            }
            foreach (CTreeField field in pTree.normalFields)
            {
                field.RemoveTree(pTree);
            }
            //shouldnt be neccessary
            //pTree.peakDetailField.RemoveTree(pTree);
            //pTree.peakNormalField.RemoveTree(pTree);
            Trees.Remove(pTree);
            //if(!pTree.treeDetailField.GetDetectedTrees().Contains(pTree))
            //{
            //	CDebug.Error("element " + pTree.treeDetailField + " doesnt contain " + pTree);
            //	return;
            //}
        }
Ejemplo n.º 26
0
        public static void TryMergeAllTrees(bool pOnlyInvalid)
        {
            IsMerging = true;
            DateTime mergeStartTime = DateTime.Now;

            CDebug.WriteLine("TryMergeAllTrees");

            Trees.Sort((a, b) => b.peak.Center.Z.CompareTo(a.peak.Center.Z));

            int treeCountBeforeMerge = Trees.Count;

            if (detectMethod == EDetectionMethod.AddFactor)
            {
                MergeGoodAddFactorTrees(pOnlyInvalid);
            }
            if (detectMethod == EDetectionMethod.Detection2D)
            {
                Merge2DTrees();
            }

            if (pOnlyInvalid)
            {
                CAnalytics.secondMergeDuration = CAnalytics.GetDuration(mergeStartTime);
            }
            else
            {
                CAnalytics.firstMergeDuration = CAnalytics.GetDuration(mergeStartTime);
            }
            IsMerging = false;

            CDebug.Duration("Trees merge", mergeStartTime);
            CDebug.Count("Number of trees merged", treeCountBeforeMerge - Trees.Count);
        }
Ejemplo n.º 27
0
            public override Tree Evaluate(Tree tree, TregexMatcher tregex)
            {
                Tree topNode    = ChildMatcher[0].Evaluate(tree, tregex);
                Tree bottomNode = ChildMatcher[1].Evaluate(tree, tregex);

                if (topNode == tree)
                {
                    if (bottomNode.Children().Length == 1)
                    {
                        return(bottomNode.Children()[0]);
                    }
                    else
                    {
                        return(null);
                    }
                }
                Tree parent = topNode.Parent(tree);
                int  i      = Trees.ObjectEqualityIndexOf(parent, topNode);

                parent.RemoveChild(i);
                foreach (Tree child in bottomNode.Children())
                {
                    parent.AddChild(i, child);
                    i++;
                }
                return(tree);
            }
Ejemplo n.º 28
0
        public override void ClearItems()
        {
            ClearSpawn();

            if (Trees != null)
            {
                List <ShadowguardCypress> list = new List <ShadowguardCypress>(Trees.Where(t => t != null && !t.Deleted));

                foreach (var tree in list)
                {
                    tree.Delete();
                }

                ColUtility.Free(list);

                ColUtility.Free(Trees);
                Trees = null;
            }

            if (Bones != null)
            {
                Bones.Delete();
                Bones = null;
            }
        }
Ejemplo n.º 29
0
        protected override float GetHeightToLargestCrownWidth(FiaCode species, float HT, float CR)
        {
            float B1 = species switch
            {
                // Hann(1999) FS 45: 217-225
                FiaCode.PseudotsugaMenziesii => 0.062000F,
                // Hann and Hanus(2001) FRL Research Contribution 34
                FiaCode.AbiesGrandis => 0.028454F,
                // Hann and Hanus(2001) FRL Research Contribution 34
                FiaCode.TsugaHeterophylla or
                FiaCode.ThujaPlicata or
                FiaCode.TaxusBrevifolia => 0.209806F,
                // Hann and Hanus(2001) FRL Research Contribution 34
                FiaCode.ArbutusMenziesii or
                FiaCode.AcerMacrophyllum or
                FiaCode.QuercusGarryana or
                FiaCode.AlnusRubra or
                FiaCode.CornusNuttallii or
                FiaCode.Salix => 0.0F,
                _ => throw Trees.CreateUnhandledSpeciesException(species),
            };
            float CL   = CR * HT;
            float HLCW = HT - (1.0F - B1) * CL;

            return(HLCW);
        }
Ejemplo n.º 30
0
        public ActionResult Index()
        {
            Trees trees = new Trees();

            trees.read = db.Set <Tree>();
            return(View(trees));
        }
Ejemplo n.º 31
0
 public void attackTree(Trees tree)
 {
     tree.receiveAttack(dmg);
     setCanAttack(false);
     player.clickedCard = null;
     calculateDirection(tree.transform.position, true);
 }
Ejemplo n.º 32
0
        public long CalculateMainLeafId(TreeInfo current, TreeInfo root, Trees trees)
        {
            if (current.LastProgenitorId == current.Id)
                current.MainLeafId = current.Id;
            else
            {
                TreeInfo next = trees.get(current.Id - root.Id + 1);
                current.MainLeafId = CalculateMainLeafId(next, root, trees);

                while(next.LastProgenitorId < current.LastProgenitorId)
                {
                    next = trees.get(next.LastProgenitorId-root.Id+1);
                    CalculateMainLeafId(next, root, trees);
                }
            }
            return current.MainLeafId;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Creates a lambda node in the abstract syntax tree.
        /// </summary>
        /// <param name="v">A tuple with the boolean and a string.</param>
        /// <param name="body">The body of the tree.</param>
        /// <returns>A new tree.</returns>
        private Trees.Absyn.Tree MkELambda(Tuple<bool, string> v, Trees.Absyn.Tree body)
        {
            if (v != null)
            {
                return new Trees.Absyn.Lambda(v.Item2, body);
            }

            return null;
        }
Ejemplo n.º 34
0
 private void saveLog(Trees trees)
 {
     saveLog(form.macroPlayLogT(trees));
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Creates a new application.
 /// </summary>
 /// <param name="f">The first tree.</param>
 /// <param name="x">The second tree.</param>
 /// <returns>An application with both trees.</returns>
 private Trees.Absyn.Tree MkEApp(Trees.Absyn.Tree f, Trees.Absyn.Tree x)
 {
     return new Trees.Absyn.Application(f, x);
 }