Exemple #1
0
        // Token: 0x06002AF8 RID: 11000 RVA: 0x000B4F10 File Offset: 0x000B3110
        public override void OnEnter()
        {
            base.OnEnter();
            Vector3 footPosition = this.GetFootPosition();

            if (base.isAuthority)
            {
                bool      flag        = false;
                NodeGraph groundNodes = SceneInfo.instance.groundNodes;
                if (groundNodes)
                {
                    NodeGraph.NodeIndex nodeIndex = groundNodes.FindClosestNodeWithFlagConditions(base.transform.position, base.characterBody.hullClassification, NodeFlags.None, NodeFlags.None, false);
                    flag = (nodeIndex != NodeGraph.NodeIndex.invalid && groundNodes.GetNodePosition(nodeIndex, out this.targetPosition));
                }
                if (!flag)
                {
                    this.outer.SetNextState(new Fly
                    {
                        activatorSkillSlot = this.activatorSkillSlot
                    });
                    this.duration       = 0f;
                    this.targetPosition = footPosition;
                    return;
                }
            }
            Vector3 vector = this.targetPosition - footPosition;
            float   num    = this.moveSpeedStat * FlyToLand.speedMultiplier;

            this.duration = vector.magnitude / num;
            if (base.characterMotor)
            {
                base.characterMotor.isFlying   = true;
                base.characterMotor.useGravity = false;
            }
        }
Exemple #2
0
        // Token: 0x06002EFC RID: 12028 RVA: 0x000C81F4 File Offset: 0x000C63F4
        private void CalculateBlinkDestination()
        {
            Vector3        vector         = Vector3.zero;
            Ray            aimRay         = base.GetAimRay();
            BullseyeSearch bullseyeSearch = new BullseyeSearch();

            bullseyeSearch.searchOrigin      = aimRay.origin;
            bullseyeSearch.searchDirection   = aimRay.direction;
            bullseyeSearch.maxDistanceFilter = this.blinkDistance;
            bullseyeSearch.teamMaskFilter    = TeamMask.allButNeutral;
            bullseyeSearch.filterByLoS       = false;
            bullseyeSearch.teamMaskFilter.RemoveTeam(TeamComponent.GetObjectTeam(base.gameObject));
            bullseyeSearch.sortMode = BullseyeSearch.SortMode.Angle;
            bullseyeSearch.RefreshCandidates();
            HurtBox hurtBox = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>();

            if (hurtBox)
            {
                vector = hurtBox.transform.position - base.transform.position;
            }
            this.blinkDestination = base.transform.position;
            this.blinkStart       = base.transform.position;
            NodeGraph groundNodes = SceneInfo.instance.groundNodes;

            NodeGraph.NodeIndex nodeIndex = groundNodes.FindClosestNode(base.transform.position + vector, base.characterBody.hullClassification);
            groundNodes.GetNodePosition(nodeIndex, out this.blinkDestination);
            this.blinkDestination          += base.transform.position - base.characterBody.footPosition;
            base.characterDirection.forward = vector;
        }
Exemple #3
0
        // Token: 0x06000DB9 RID: 3513 RVA: 0x000435A4 File Offset: 0x000417A4
        private void GenerateAmbush(Vector3 victimPosition)
        {
            NodeGraph groundNodes = SceneInfo.instance.groundNodes;

            NodeGraph.NodeIndex nodeIndex       = groundNodes.FindClosestNode(victimPosition, HullClassification.Human);
            NodeGraphSpider     nodeGraphSpider = new NodeGraphSpider(groundNodes, HullMask.Human);

            nodeGraphSpider.AddNodeForNextStep(nodeIndex);
            List <NodeGraphSpider.StepInfo> list = new List <NodeGraphSpider.StepInfo>();
            int num = 0;
            List <NodeGraphSpider.StepInfo> collectedSteps = nodeGraphSpider.collectedSteps;

            while (nodeGraphSpider.PerformStep() && num < 8)
            {
                num++;
                for (int i = 0; i < collectedSteps.Count; i++)
                {
                    if (CombatDirector.IsAcceptableAmbushSpiderStep(groundNodes, nodeIndex, collectedSteps[i]))
                    {
                        list.Add(collectedSteps[i]);
                    }
                }
                collectedSteps.Clear();
            }
            for (int j = 0; j < list.Count; j++)
            {
                Vector3 position;
                groundNodes.GetNodePosition(list[j].node, out position);
                Resources.Load <SpawnCard>("SpawnCards/scLemurian").DoSpawn(position, Quaternion.identity);
            }
        }
Exemple #4
0
 // Token: 0x06000E7B RID: 3707 RVA: 0x000474C0 File Offset: 0x000456C0
 private void AddOccupiedNode(NodeGraph nodeGraph, NodeGraph.NodeIndex nodeIndex)
 {
     Array.Resize <DirectorCore.NodeReference>(ref this.occupiedNodes, this.occupiedNodes.Length + 1);
     this.occupiedNodes[this.occupiedNodes.Length - 1] = new DirectorCore.NodeReference
     {
         nodeGraph = nodeGraph,
         nodeIndex = nodeIndex
     };
 }
Exemple #5
0
        private void CalculateBlinkDestination()
        {
            Vector3 vector = inputBank.moveVector * blinkDistance;
            Ray     aimRay = GetAimRay();

            blinkDestination = transform.position;
            blinkStart       = transform.position;
            NodeGraph airNodes = SceneInfo.instance.airNodes;

            NodeGraph.NodeIndex nodeIndex = airNodes.FindClosestNode(transform.position + vector, characterBody.hullClassification, float.PositiveInfinity);
            airNodes.GetNodePosition(nodeIndex, out blinkDestination);
        }
        // Token: 0x060015D9 RID: 5593 RVA: 0x00068BA8 File Offset: 0x00066DA8
        private Vector3 SampleNodeGraphForSpawnPosition()
        {
            Vector3   zero          = Vector3.zero;
            NodeGraph groundNodes   = SceneInfo.instance.groundNodes;
            NodeFlags requiredFlags = this.usePod ? NodeFlags.NoCeiling : NodeFlags.None;
            List <NodeGraph.NodeIndex> activeNodesForHullMaskWithFlagConditions = groundNodes.GetActiveNodesForHullMaskWithFlagConditions(HullMask.BeetleQueen, requiredFlags, NodeFlags.None);

            if (activeNodesForHullMaskWithFlagConditions.Count < 0)
            {
                Debug.LogWarning("No spawn points available in scene!");
                return(Vector3.zero);
            }
            NodeGraph.NodeIndex nodeIndex = activeNodesForHullMaskWithFlagConditions[Run.instance.spawnRng.RangeInt(0, activeNodesForHullMaskWithFlagConditions.Count)];
            groundNodes.GetNodePosition(nodeIndex, out zero);
            return(zero);
        }
        private void DoTeleport()
        {
            Ray aimRay = base.GetAimRay();

            this.enemyFinder = new BullseyeSearch();
            this.enemyFinder.maxDistanceFilter = PortalJump.skillDistance;
            this.enemyFinder.searchOrigin      = aimRay.origin;
            this.enemyFinder.searchDirection   = aimRay.direction;
            this.enemyFinder.filterByLoS       = false;
            this.enemyFinder.sortMode          = BullseyeSearch.SortMode.Distance;
            this.enemyFinder.teamMaskFilter    = TeamMask.allButNeutral;
            if (base.teamComponent)
            {
                this.enemyFinder.teamMaskFilter.RemoveTeam(base.teamComponent.teamIndex);
            }
            this.enemyFinder.RefreshCandidates();
            this.foundBullseye  = this.enemyFinder.GetResults().LastOrDefault <HurtBox>();
            this.modelTransform = base.GetModelTransform();
            if (this.characterModel)
            {
                this.characterModel.invisibilityCount++;
            }
            if (this.hurtboxGroup)
            {
                HurtBoxGroup hurtBoxGroup = this.hurtboxGroup;
                int          hurtBoxesDeactivatorCounter = hurtBoxGroup.hurtBoxesDeactivatorCounter + 1;
                hurtBoxGroup.hurtBoxesDeactivatorCounter = hurtBoxesDeactivatorCounter;
            }
            if (base.characterMotor)
            {
                base.characterMotor.enabled = false;
            }
            Vector3 b = base.inputBank.moveVector * PortalJump.skillDistance;

            this.destinationPressence = base.transform.position;
            this.startPressence       = base.transform.position;
            NodeGraph groundNodes = SceneInfo.instance.groundNodes;
            Vector3   position    = this.startPressence + b;

            if (this.foundBullseye)
            {
                position = this.foundBullseye.transform.position;
            }
            NodeGraph.NodeIndex nodeIndex = groundNodes.FindClosestNode(position, base.characterBody.hullClassification);
            groundNodes.GetNodePosition(nodeIndex, out this.destinationPressence);
            this.destinationPressence += base.transform.position - base.characterBody.footPosition;
        }
Exemple #8
0
        public override void OnEnter()
        {
            base.OnEnter();
            Util.PlaySound(LoomingPresence.beginSoundString, base.gameObject);
            this.modelTransform = base.GetModelTransform();

            if (this.modelTransform)
            {
                this.characterModel = this.modelTransform.GetComponent <CharacterModel>();
                this.hurtboxGroup   = this.modelTransform.GetComponent <HurtBoxGroup>();
            }

            if (this.characterModel)
            {
                this.characterModel.invisibilityCount++;
            }

            if (this.hurtboxGroup)
            {
                HurtBoxGroup hurtBoxGroup = this.hurtboxGroup;
                int          hurtBoxesDeactivatorCounter = hurtBoxGroup.hurtBoxesDeactivatorCounter + 1;
                hurtBoxGroup.hurtBoxesDeactivatorCounter = hurtBoxesDeactivatorCounter;
            }

            if (base.characterMotor)
            {
                base.characterMotor.enabled = false;
            }

            if (base.isAuthority)
            {
                Vector3 vector = base.inputBank.aimDirection * LoomingPresence.blinkDistance;
                this.blinkDestination = base.transform.position;
                this.blinkStart       = base.transform.position;

                NodeGraph           groundNodes = SceneInfo.instance.groundNodes;
                NodeGraph.NodeIndex nodeIndex   = groundNodes.FindClosestNode(base.transform.position + vector, base.characterBody.hullClassification);

                groundNodes.GetNodePosition(nodeIndex, out this.blinkDestination);

                this.blinkDestination += base.transform.position - base.characterBody.footPosition;
                vector = this.blinkDestination - this.blinkStart;

                this.CreateBlinkEffect(Util.GetCorePosition(base.gameObject), vector);
            }
        }
        // Token: 0x06000425 RID: 1061 RVA: 0x00011344 File Offset: 0x0000F544
        public override void OnEnter()
        {
            base.OnEnter();
            this.duration = EndRain.baseDuration / this.attackSpeedStat;
            if (base.rigidbodyMotor)
            {
                base.rigidbodyMotor.moveVector = Vector3.zero;
            }
            base.PlayAnimation("Body", "EndRain", "EndRain.playbackRate", this.duration);
            NodeGraph airNodes = SceneInfo.instance.airNodes;

            NodeGraph.NodeIndex nodeIndex = airNodes.FindClosestNode(base.transform.position, base.characterBody.hullClassification);
            Vector3             position;

            airNodes.GetNodePosition(nodeIndex, out position);
            base.transform.position = position;
        }
        // Token: 0x06000A24 RID: 2596 RVA: 0x0002C358 File Offset: 0x0002A558
        private bool CheckPositionFree(NodeGraph nodeGraph, NodeGraph.NodeIndex nodeIndex, SpawnCard spawnCard)
        {
            DirectorCore.NodeReference value = new DirectorCore.NodeReference(nodeGraph, nodeIndex);
            if (Array.IndexOf <DirectorCore.NodeReference>(this.occupiedNodes, value) != -1)
            {
                return(false);
            }
            float   num = HullDef.Find(spawnCard.hullSize).radius * 0.7f;
            Vector3 vector;

            nodeGraph.GetNodePosition(nodeIndex, out vector);
            if (spawnCard.nodeGraphType == MapNodeGroup.GraphType.Ground)
            {
                vector += Vector3.up * (num + 0.25f);
            }
            return(Physics.OverlapSphere(vector, num, LayerIndex.world.mask | LayerIndex.defaultLayer.mask | LayerIndex.fakeActor.mask).Length == 0);
        }
Exemple #11
0
        // Token: 0x06000E7C RID: 3708 RVA: 0x00047510 File Offset: 0x00045710
        private bool CheckPositionFree(NodeGraph nodeGraph, NodeGraph.NodeIndex nodeIndex, SpawnCard spawnCard)
        {
            for (int i = 0; i < this.occupiedNodes.Length; i++)
            {
                if (this.occupiedNodes[i].nodeGraph == nodeGraph && this.occupiedNodes[i].nodeIndex == nodeIndex)
                {
                    return(false);
                }
            }
            float   num = HullDef.Find(spawnCard.hullSize).radius * 0.7f;
            Vector3 vector;

            nodeGraph.GetNodePosition(nodeIndex, out vector);
            if (spawnCard.nodeGraphType == MapNodeGroup.GraphType.Ground)
            {
                vector += Vector3.up * (num + 0.25f);
            }
            return(Physics.OverlapSphere(vector, num, LayerIndex.world.mask | LayerIndex.defaultLayer.mask | LayerIndex.fakeActor.mask).Length == 0);
        }
Exemple #12
0
        // Token: 0x06000DBA RID: 3514 RVA: 0x0004367C File Offset: 0x0004187C
        private static bool IsAcceptableAmbushSpiderStep(NodeGraph nodeGraph, NodeGraph.NodeIndex startNode, NodeGraphSpider.StepInfo stepInfo)
        {
            int num = 0;

            while (stepInfo.previousStep != null)
            {
                if (nodeGraph.TestNodeLineOfSight(startNode, stepInfo.node))
                {
                    return(false);
                }
                stepInfo = stepInfo.previousStep;
                num++;
                if (num > 2)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #13
0
        // Token: 0x0600190F RID: 6415 RVA: 0x000785A8 File Offset: 0x000767A8
        public void PushWaypointToFront(NodeGraph.NodeIndex nodeIndex, float minJumpHeight)
        {
            if (this.waypointsCount + 1 >= this.waypointsBuffer.Length)
            {
                Path.Waypoint[] array = this.waypointsBuffer;
                this.waypointsBuffer = new Path.Waypoint[this.waypointsCount + 32];
                Array.Copy(array, 0, this.waypointsBuffer, this.waypointsBuffer.Length - array.Length, array.Length);
                Path.FreeWaypointsBuffer(array);
            }
            int num  = this.waypointsBuffer.Length;
            int num2 = this.waypointsCount + 1;

            this.waypointsCount     = num2;
            this.firstWaypointIndex = num - num2;
            this.waypointsBuffer[this.firstWaypointIndex] = new Path.Waypoint
            {
                nodeIndex     = nodeIndex,
                minJumpHeight = minJumpHeight
            };
        }
        // Token: 0x06002AC0 RID: 10944 RVA: 0x000B4154 File Offset: 0x000B2354
        public override void OnEnter()
        {
            base.OnEnter();
            this.duration = ChargeRain.baseDuration / this.attackSpeedStat;
            if (base.rigidbodyMotor)
            {
                base.rigidbodyMotor.moveVector = Vector3.zero;
            }
            base.PlayAnimation("Body", "ChargeRain", "ChargeRain.playbackRate", this.duration);
            RaycastHit raycastHit;

            if (Physics.Raycast(base.transform.position, Vector3.down, out raycastHit, 999f, LayerIndex.world.mask))
            {
                NodeGraph           groundNodes = SceneInfo.instance.groundNodes;
                NodeGraph.NodeIndex nodeIndex   = groundNodes.FindClosestNode(raycastHit.point, HullClassification.BeetleQueen);
                Vector3             a;
                groundNodes.GetNodePosition(nodeIndex, out a);
                base.transform.position = a + Vector3.up * 2f;
            }
        }
Exemple #15
0
        // Token: 0x060013BE RID: 5054 RVA: 0x00054754 File Offset: 0x00052954
        public unsafe static void AddSpawnPoint(NodeGraph nodeGraph, NodeGraph.NodeIndex nodeIndex, Xoroshiro128Plus rng)
        {
            Vector3 vector;

            nodeGraph.GetNodePosition(nodeIndex, out vector);
            NodeGraph.LinkIndex[] activeNodeLinks = nodeGraph.GetActiveNodeLinks(nodeIndex);
            Quaternion            rotation;

            if (activeNodeLinks.Length != 0)
            {
                NodeGraph.LinkIndex linkIndex = *rng.NextElementUniform <NodeGraph.LinkIndex>(activeNodeLinks);
                Vector3             a;
                nodeGraph.GetNodePosition(nodeGraph.GetLinkEndNode(linkIndex), out a);
                rotation = Util.QuaternionSafeLookRotation(a - vector);
            }
            else
            {
                rotation = Quaternion.Euler(0f, rng.nextNormalizedFloat * 360f, 0f);
            }
            SpawnPoint.AddSpawnPoint(vector, rotation);
        }
 // Token: 0x0600097C RID: 2428 RVA: 0x0002FBD8 File Offset: 0x0002DDD8
 public override void OnEnter()
 {
     base.OnEnter();
     if (base.ai && base.body)
     {
         this.targetPosition = base.bodyTransform.position;
         NodeGraph       nodeGraph       = base.ai.GetNodeGraph();
         NodeGraphSpider nodeGraphSpider = new NodeGraphSpider(nodeGraph, (HullMask)(1 << (int)base.body.hullClassification));
         nodeGraphSpider.AddNodeForNextStep(nodeGraph.FindClosestNode(base.bodyTransform.position, base.body.hullClassification));
         for (int i = 0; i < 6; i++)
         {
             nodeGraphSpider.PerformStep();
         }
         List <NodeGraphSpider.StepInfo> collectedSteps = nodeGraphSpider.collectedSteps;
         if (collectedSteps.Count > 0)
         {
             int index = UnityEngine.Random.Range(0, collectedSteps.Count);
             NodeGraph.NodeIndex node = collectedSteps[index].node;
             nodeGraph.GetNodePosition(node, out this.targetPosition);
             base.ai.pathFollower.targetPosition = this.targetPosition;
         }
         this.PickNewTargetLookPosition();
     }
 }
        // Token: 0x0600128F RID: 4751 RVA: 0x0004FBA8 File Offset: 0x0004DDA8
        private static bool IsNodeSuitableForPod(NodeGraph nodeGraph, NodeGraph.NodeIndex nodeIndex)
        {
            NodeFlags nodeFlags;

            return(nodeGraph.GetNodeFlags(nodeIndex, out nodeFlags) && (nodeFlags & NodeFlags.NoCeiling) != NodeFlags.None);
        }
Exemple #18
0
        // Token: 0x0600150E RID: 5390 RVA: 0x00064F0C File Offset: 0x0006310C
        private void PlacePlayerSpawnsViaNodegraph()
        {
            bool      usePod      = Stage.instance.usePod;
            NodeGraph groundNodes = SceneInfo.instance.groundNodes;
            List <NodeGraph.NodeIndex> activeNodesForHullMask = groundNodes.GetActiveNodesForHullMask(HullMask.Golem);

            if (usePod)
            {
                for (int i = activeNodesForHullMask.Count - 1; i >= 0; i--)
                {
                    if (!SceneDirector.IsNodeSuitableForPod(groundNodes, activeNodesForHullMask[i]))
                    {
                        activeNodesForHullMask.RemoveAt(i);
                    }
                }
            }
            NodeGraph.NodeIndex nodeIndex;
            if (this.teleporterInstance)
            {
                Vector3 position = this.teleporterInstance.transform.position;
                List <SceneDirector.NodeDistanceSqrPair> list = new List <SceneDirector.NodeDistanceSqrPair>();
                for (int j = 0; j < activeNodesForHullMask.Count; j++)
                {
                    Vector3 b2;
                    groundNodes.GetNodePosition(activeNodesForHullMask[j], out b2);
                    list.Add(new SceneDirector.NodeDistanceSqrPair
                    {
                        nodeIndex   = activeNodesForHullMask[j],
                        distanceSqr = (position - b2).sqrMagnitude
                    });
                }
                list.Sort((SceneDirector.NodeDistanceSqrPair a, SceneDirector.NodeDistanceSqrPair b) => a.distanceSqr.CompareTo(b.distanceSqr));
                int index = this.rng.RangeInt(list.Count * 3 / 4, list.Count);
                nodeIndex = list[index].nodeIndex;
            }
            else
            {
                nodeIndex = activeNodesForHullMask[this.rng.RangeInt(0, activeNodesForHullMask.Count)];
            }
            NodeGraphSpider nodeGraphSpider = new NodeGraphSpider(groundNodes, HullMask.Human);

            nodeGraphSpider.AddNodeForNextStep(nodeIndex);
            while (nodeGraphSpider.PerformStep())
            {
                List <NodeGraphSpider.StepInfo> collectedSteps = nodeGraphSpider.collectedSteps;
                if (usePod)
                {
                    for (int k = collectedSteps.Count - 1; k >= 0; k--)
                    {
                        if (!SceneDirector.IsNodeSuitableForPod(groundNodes, collectedSteps[k].node))
                        {
                            collectedSteps.RemoveAt(k);
                        }
                    }
                }
                if (collectedSteps.Count >= RoR2Application.maxPlayers)
                {
                    break;
                }
            }
            List <NodeGraphSpider.StepInfo> collectedSteps2 = nodeGraphSpider.collectedSteps;

            Util.ShuffleList <NodeGraphSpider.StepInfo>(collectedSteps2, Run.instance.stageRng);
            int num = Math.Min(nodeGraphSpider.collectedSteps.Count, RoR2Application.maxPlayers);

            for (int l = 0; l < num; l++)
            {
                NodeGraph.NodeIndex node = collectedSteps2[l].node;
                Vector3             vector;
                groundNodes.GetNodePosition(node, out vector);
                NodeGraph.LinkIndex[] activeNodeLinks = groundNodes.GetActiveNodeLinks(node);
                Quaternion            rotation;
                if (activeNodeLinks.Length != 0)
                {
                    int num2 = this.rng.RangeInt(0, activeNodeLinks.Length);
                    NodeGraph.LinkIndex linkIndex = activeNodeLinks[num2];
                    Vector3             a2;
                    groundNodes.GetNodePosition(groundNodes.GetLinkEndNode(linkIndex), out a2);
                    rotation = Util.QuaternionSafeLookRotation(a2 - vector);
                }
                else
                {
                    rotation = Quaternion.Euler(0f, this.rng.nextNormalizedFloat * 360f, 0f);
                }
                UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/SpawnPoint"), vector, rotation);
            }
        }
 // Token: 0x06000A28 RID: 2600 RVA: 0x0002C725 File Offset: 0x0002A925
 public NodeReference(NodeGraph nodeGraph, NodeGraph.NodeIndex nodeIndex)
 {
     this.nodeGraph = nodeGraph;
     this.nodeIndex = nodeIndex;
 }
        // Token: 0x06000A25 RID: 2597 RVA: 0x0002C404 File Offset: 0x0002A604
        public GameObject TrySpawnObject([NotNull] DirectorSpawnRequest directorSpawnRequest)
        {
            SpawnCard             spawnCard     = directorSpawnRequest.spawnCard;
            DirectorPlacementRule placementRule = directorSpawnRequest.placementRule;
            Xoroshiro128Plus      rng           = directorSpawnRequest.rng;
            NodeGraph             nodeGraph     = SceneInfo.instance.GetNodeGraph(spawnCard.nodeGraphType);
            GameObject            result        = null;

            switch (placementRule.placementMode)
            {
            case DirectorPlacementRule.PlacementMode.Direct:
                result = spawnCard.DoSpawn(placementRule.spawnOnTarget ? placementRule.spawnOnTarget.position : directorSpawnRequest.placementRule.position, Quaternion.identity, directorSpawnRequest);
                break;

            case DirectorPlacementRule.PlacementMode.Approximate:
            {
                List <NodeGraph.NodeIndex> list = nodeGraph.FindNodesInRangeWithFlagConditions(placementRule.targetPosition, placementRule.minDistance, placementRule.maxDistance, (HullMask)(1 << (int)spawnCard.hullSize), spawnCard.requiredFlags, spawnCard.forbiddenFlags, placementRule.preventOverhead);
                while (list.Count > 0)
                {
                    int index = rng.RangeInt(0, list.Count);
                    NodeGraph.NodeIndex nodeIndex = list[index];
                    Vector3             position;
                    nodeGraph.GetNodePosition(nodeIndex, out position);
                    if (this.CheckPositionFree(nodeGraph, nodeIndex, spawnCard))
                    {
                        result = spawnCard.DoSpawn(position, Quaternion.identity, directorSpawnRequest);
                        if (spawnCard.occupyPosition)
                        {
                            this.AddOccupiedNode(nodeGraph, nodeIndex);
                            break;
                        }
                        break;
                    }
                    else
                    {
                        list.RemoveAt(index);
                    }
                }
                break;
            }

            case DirectorPlacementRule.PlacementMode.ApproximateSimple:
            {
                NodeGraph.NodeIndex nodeIndex2 = nodeGraph.FindClosestNodeWithFlagConditions(placementRule.targetPosition, spawnCard.hullSize, spawnCard.requiredFlags, spawnCard.forbiddenFlags, placementRule.preventOverhead);
                Vector3             position2;
                if (nodeGraph.GetNodePosition(nodeIndex2, out position2))
                {
                    if (this.CheckPositionFree(nodeGraph, nodeIndex2, spawnCard))
                    {
                        result = spawnCard.DoSpawn(position2, Quaternion.identity, directorSpawnRequest);
                        if (spawnCard.occupyPosition)
                        {
                            this.AddOccupiedNode(nodeGraph, nodeIndex2);
                        }
                    }
                    else
                    {
                        Debug.Log("Position not free.");
                    }
                }
                else
                {
                    Debug.Log("Could not find node.");
                }
                break;
            }

            case DirectorPlacementRule.PlacementMode.NearestNode:
            {
                NodeGraph.NodeIndex nodeIndex3 = nodeGraph.FindClosestNodeWithFlagConditions(placementRule.targetPosition, spawnCard.hullSize, spawnCard.requiredFlags, spawnCard.forbiddenFlags, placementRule.preventOverhead);
                Vector3             position3;
                if (nodeGraph.GetNodePosition(nodeIndex3, out position3))
                {
                    result = spawnCard.DoSpawn(position3, Quaternion.identity, directorSpawnRequest);
                    if (spawnCard.occupyPosition)
                    {
                        this.AddOccupiedNode(nodeGraph, nodeIndex3);
                    }
                }
                break;
            }

            case DirectorPlacementRule.PlacementMode.Random:
            {
                List <NodeGraph.NodeIndex> activeNodesForHullMaskWithFlagConditions = nodeGraph.GetActiveNodesForHullMaskWithFlagConditions((HullMask)(1 << (int)spawnCard.hullSize), spawnCard.requiredFlags, spawnCard.forbiddenFlags);
                while (activeNodesForHullMaskWithFlagConditions.Count > 0)
                {
                    int index2 = rng.RangeInt(0, activeNodesForHullMaskWithFlagConditions.Count);
                    NodeGraph.NodeIndex nodeIndex4 = activeNodesForHullMaskWithFlagConditions[index2];
                    Vector3             position4;
                    if (nodeGraph.GetNodePosition(nodeIndex4, out position4) && this.CheckPositionFree(nodeGraph, nodeIndex4, spawnCard))
                    {
                        result = spawnCard.DoSpawn(position4, Quaternion.identity, directorSpawnRequest);
                        if (spawnCard.occupyPosition)
                        {
                            this.AddOccupiedNode(nodeGraph, nodeIndex4);
                            break;
                        }
                        break;
                    }
                    else
                    {
                        activeNodesForHullMaskWithFlagConditions.RemoveAt(index2);
                    }
                }
                break;
            }
            }
            return(result);
        }
Exemple #21
0
        /// <summary>
        /// Removes a node from a NodeGraph. See the NodeOccupationInfo component.
        /// </summary>
        /// <param name="self">The DirectorCore to perform NodeGraph operations with.</param>
        /// <param name="nodeGraph">The NodeGraph to remove nodes from.</param>
        /// <param name="nodeIndex">The NodeIndex within the given NodeGraph to remove.</param>
        /// <returns>True on successful removals; false otherwise.</returns>
        public static bool RemoveOccupiedNode(this DirectorCore self, NodeGraph nodeGraph, NodeGraph.NodeIndex nodeIndex)
        {
            var oldLen = self.occupiedNodes.Length;

            self.occupiedNodes = self.occupiedNodes.Where(x => x.nodeGraph != nodeGraph || x.nodeIndex != nodeIndex).ToArray();

            if (oldLen == self.occupiedNodes.Length)
            {
                TILER2Plugin._logger.LogWarning("RemoveOccupiedNode was passed an already-removed or otherwise nonexistent node");
                return(false);
            }
            return(true);
        }
 // Token: 0x060010DE RID: 4318 RVA: 0x00049EE0 File Offset: 0x000480E0
 private void FixedUpdate()
 {
     this.UpdateNodeAndLinkInfo();
     if (this.inputBank)
     {
         bool value = false;
         if (this.inputMoveVector.sqrMagnitude > 0f)
         {
             value = true;
             this.characterDirection.moveVector = this.linkVector;
             if (this.linkLerp == 0f || this.linkLerp == 1f)
             {
                 NodeGraph.NodeIndex nodeIndex;
                 if (this.linkLerp == 0f)
                 {
                     nodeIndex = this.nodeA;
                 }
                 else
                 {
                     nodeIndex = this.nodeB;
                 }
                 NodeGraph.LinkIndex[] activeNodeLinks = this.railGraph.GetActiveNodeLinks(nodeIndex);
                 float num = -1f;
                 NodeGraph.LinkIndex lhs = this.currentLink;
                 Debug.DrawRay(base.transform.position, this.inputMoveVector, Color.green);
                 foreach (NodeGraph.LinkIndex linkIndex in activeNodeLinks)
                 {
                     NodeGraph.NodeIndex linkStartNode = this.railGraph.GetLinkStartNode(linkIndex);
                     NodeGraph.NodeIndex linkEndNode   = this.railGraph.GetLinkEndNode(linkIndex);
                     if (!(linkStartNode != nodeIndex))
                     {
                         Vector3 vector;
                         this.railGraph.GetNodePosition(linkStartNode, out vector);
                         Vector3 a;
                         this.railGraph.GetNodePosition(linkEndNode, out a);
                         Vector3 vector2 = a - vector;
                         Vector3 rhs     = new Vector3(vector2.x, 0f, vector2.z);
                         Debug.DrawRay(vector, vector2, Color.red);
                         float num2 = Vector3.Dot(this.inputMoveVector, rhs);
                         if (num2 > num)
                         {
                             num = num2;
                             lhs = linkIndex;
                         }
                     }
                 }
                 if (lhs != this.currentLink)
                 {
                     this.currentLink = lhs;
                     this.UpdateNodeAndLinkInfo();
                     this.linkLerp = 0f;
                 }
             }
         }
         this.modelAnimator.SetBool("isMoving", value);
         if (this.useRootMotion)
         {
             this.TravelLink();
         }
         else
         {
             this.TravelLink();
         }
     }
     base.transform.position = Vector3.Lerp(this.nodeAPosition, this.nodeBPosition, this.linkLerp);
 }