Exemple #1
0
            // Token: 0x06001D8C RID: 7564 RVA: 0x00089F6C File Offset: 0x0008816C
            public void SetHull(HullClassification hullClassification)
            {
                HullDef hullDef = HullDef.Find(hullClassification);

                this.testCharacterController.radius = hullDef.radius;
                this.testCharacterController.height = hullDef.height;
            }
Exemple #2
0
 public InteractableTemplate(GameObject interactablePrefab, Category interactableCategory, int selectionWeight = 3, bool sendOverNetwork = true, HullClassification hullSize = HullClassification.Golem, MapNodeGroup.GraphType nodeGraphType = MapNodeGroup.GraphType.Ground, int directorCreditCost = 15, bool occupyPosition = true, SpawnCard.EliteRules eliteRules = SpawnCard.EliteRules.Default, bool orientToFloor = true, bool slightlyRandomizeOrientation = false, bool skipSpawnWhenSacrificeArtifactEnabled = false, NodeFlags requiredFlags = NodeFlags.None, NodeFlags forbiddenFlags = NodeFlags.None, DirectorCore.MonsterSpawnDistance spawnDistance = DirectorCore.MonsterSpawnDistance.Standard, bool allowAmbushSpawn = true, bool preventOverhead = false, int minimumStageCompletions = 0, UnlockableDef requiredUnlockableDef = null, UnlockableDef forbiddenUnlockableDef = null, bool multiplayerOnly = false, int minimumCount = 0)
 {
     this.interactablePrefab                    = interactablePrefab;
     this.interactableCategory                  = interactableCategory;
     this.selectionWeight                       = selectionWeight;
     this.minimumCount                          = minimumCount;
     this.sendOverNetwork                       = sendOverNetwork;
     this.hullSize                              = hullSize;
     this.nodeGraphType                         = nodeGraphType;
     this.directorCreditCost                    = directorCreditCost;
     this.occupyPosition                        = occupyPosition;
     this.eliteRules                            = eliteRules;
     this.orientToFloor                         = orientToFloor;
     this.slightlyRandomizeOrientation          = slightlyRandomizeOrientation;
     this.skipSpawnWhenSacrificeArtifactEnabled = skipSpawnWhenSacrificeArtifactEnabled;
     this.requiredFlags                         = requiredFlags;
     this.forbiddenFlags                        = forbiddenFlags;
     this.spawnDistance                         = spawnDistance;
     this.allowAmbushSpawn                      = allowAmbushSpawn;
     this.preventOverhead                       = preventOverhead;
     this.minimumStageCompletions               = minimumStageCompletions;
     this.requiredUnlockableDef                 = requiredUnlockableDef;
     this.forbiddenUnlockableDef                = forbiddenUnlockableDef;
     this.multiplayerOnly                       = multiplayerOnly;
 }
        /// <summary>
        /// Finds a node on the node graph that is closest to the specified position on the specified HullClassification.
        /// </summary>
        /// <param name="position">Where we want to go.</param>
        /// <param name="hullClassification">What hullclassification we want to use to check the node graph.</param>
        /// <param name="checkAirNodes">Should we use air nodes? If not, we use the ground nodes instead.</param>
        /// <returns>The position of a node closest to our desired destination, else a Vector3(0, 0, 0).</returns>
        public static Vector3 FindClosestNodeToPosition(Vector3 position, HullClassification hullClassification, bool checkAirNodes = false)
        {
            Vector3 ResultPosition;

            NodeGraph nodesToCheck = checkAirNodes ? SceneInfo.instance.airNodes : SceneInfo.instance.groundNodes;

            var closestNode = nodesToCheck.FindClosestNode(position, hullClassification);

            if (closestNode != NodeGraph.NodeIndex.invalid)
            {
                nodesToCheck.GetNodePosition(closestNode, out ResultPosition);
                return(ResultPosition);
            }

            Main.ModLogger.LogInfo($"No closest node to be found for XYZ: {position}, returning 0,0,0");
            return(Vector3.zero);
        }
Exemple #4
0
        // Token: 0x06001DDB RID: 7643 RVA: 0x0007FED8 File Offset: 0x0007E0D8
        public Mesh GenerateLinkDebugMesh(HullClassification hull)
        {
            Mesh result;

            using (WireMeshBuilder wireMeshBuilder = new WireMeshBuilder())
            {
                int num = 1 << (int)hull;
                foreach (NodeGraph.Link link in this.links)
                {
                    if ((link.hullMask & num) != 0)
                    {
                        Vector3 position  = this.nodes[link.nodeIndexA.nodeIndex].position;
                        Vector3 position2 = this.nodes[link.nodeIndexB.nodeIndex].position;
                        Vector3 vector    = (position + position2) * 0.5f;
                        bool    flag      = (link.jumpHullMask & num) != 0;
                        Color   color     = flag ? Color.cyan : Color.green;
                        if (flag)
                        {
                            Vector3 apexPos = vector;
                            apexPos.y = position.y + link.minJumpHeight;
                            int     num2 = 8;
                            Vector3 p    = position;
                            for (int j = 1; j <= num2; j++)
                            {
                                if (j > num2 / 2)
                                {
                                    color.a = 0.1f;
                                }
                                Vector3 quadraticCoordinates = this.GetQuadraticCoordinates((float)j / (float)num2, position, apexPos, position2);
                                wireMeshBuilder.AddLine(p, color, quadraticCoordinates, color);
                                p = quadraticCoordinates;
                            }
                        }
                        else
                        {
                            Color c = color;
                            c.a = 0.1f;
                            wireMeshBuilder.AddLine(position, color, position2, c);
                        }
                    }
                }
                result = wireMeshBuilder.GenerateMesh();
            }
            return(result);
        }
Exemple #5
0
 public InteractableTemplate()
 {
     this.minimumCount            = 0;
     this.selectionWeight         = 3;
     this.spawnDistance           = DirectorCore.MonsterSpawnDistance.Standard;
     this.allowAmbushSpawn        = true;
     this.preventOverhead         = false;
     this.minimumStageCompletions = 0;
     this.sendOverNetwork         = true;
     this.hullSize                              = HullClassification.Golem;
     this.nodeGraphType                         = MapNodeGroup.GraphType.Ground;
     this.requiredFlags                         = NodeFlags.None;
     this.forbiddenFlags                        = NodeFlags.None;
     this.directorCreditCost                    = 15;
     this.occupyPosition                        = true;
     this.eliteRules                            = SpawnCard.EliteRules.Default;
     this.orientToFloor                         = true;
     this.slightlyRandomizeOrientation          = false;
     this.skipSpawnWhenSacrificeArtifactEnabled = false;
     this.multiplayerOnly                       = false;
 }
Exemple #6
0
        // Token: 0x06001DDC RID: 7644 RVA: 0x00080054 File Offset: 0x0007E254
        public void DebugDrawLinks(HullClassification hull)
        {
            int num = 1 << (int)hull;

            foreach (NodeGraph.Link link in this.links)
            {
                if ((link.hullMask & num) != 0)
                {
                    Vector3 position  = this.nodes[link.nodeIndexA.nodeIndex].position;
                    Vector3 position2 = this.nodes[link.nodeIndexB.nodeIndex].position;
                    Vector3 vector    = (position + position2) * 0.5f;
                    bool    flag      = (link.jumpHullMask & num) != 0;
                    Color   color     = flag ? Color.cyan : Color.green;
                    if (flag)
                    {
                        Vector3 apexPos = vector;
                        apexPos.y = position.y + link.minJumpHeight;
                        int     num2  = 8;
                        Vector3 start = position;
                        for (int j = 1; j <= num2; j++)
                        {
                            if (j > num2 / 2)
                            {
                                color.a = 0.1f;
                            }
                            Vector3 quadraticCoordinates = this.GetQuadraticCoordinates((float)j / (float)num2, position, apexPos, position2);
                            Debug.DrawLine(start, quadraticCoordinates, color, 10f);
                            start = quadraticCoordinates;
                        }
                    }
                    else
                    {
                        Debug.DrawLine(position, vector, color, 10f, false);
                        Color color2 = color;
                        color2.a = 0.1f;
                        Debug.DrawLine(vector, position2, color2, 10f, false);
                    }
                }
            }
        }
Exemple #7
0
        // Token: 0x06001DED RID: 7661 RVA: 0x00080930 File Offset: 0x0007EB30
        public NodeGraph.NodeIndex FindClosestNode(Vector3 position, HullClassification hullClassification)
        {
            float num = float.PositiveInfinity;

            NodeGraph.NodeIndex invalid = NodeGraph.NodeIndex.invalid;
            int num2 = 1 << (int)hullClassification;

            for (int i = 0; i < this.nodes.Length; i++)
            {
                NodeGraph.Node node = this.nodes[i];
                if ((node.forbiddenHulls & (HullMask)num2) == HullMask.None && (node.gateIndex == 0 || this.openGates[(int)node.gateIndex]))
                {
                    float sqrMagnitude = (node.position - position).sqrMagnitude;
                    if (sqrMagnitude < num)
                    {
                        num     = sqrMagnitude;
                        invalid = new NodeGraph.NodeIndex(i);
                    }
                }
            }
            return(invalid);
        }
Exemple #8
0
        // Token: 0x06001D81 RID: 7553 RVA: 0x00089754 File Offset: 0x00087954
        private void AddLink(MapNode nodeB, float distanceScore, float minJumpHeight, HullClassification hullClassification)
        {
            int num = this.links.FindIndex((MapNode.Link item) => item.nodeB == nodeB);

            if (num == -1)
            {
                this.links.Add(new MapNode.Link
                {
                    nodeB = nodeB
                });
                num = this.links.Count - 1;
            }
            MapNode.Link link = this.links[num];
            link.distanceScore = Mathf.Max(link.distanceScore, distanceScore);
            link.minJumpHeight = Mathf.Max(link.minJumpHeight, minJumpHeight);
            link.hullMask     |= 1 << (int)hullClassification;
            if (minJumpHeight > 0f)
            {
                link.jumpHullMask |= 1 << (int)hullClassification;
            }
            if (string.IsNullOrEmpty(link.gateName))
            {
                link.gateName = nodeB.gateName;
            }
            this.links[num] = link;
        }
 // Token: 0x06001673 RID: 5747 RVA: 0x000609A0 File Offset: 0x0005EBA0
 public static HullDef Find(HullClassification hullClassification)
 {
     return(HullDef.hullDefs[(int)hullClassification]);
 }
        /// <summary>
        /// Teleports a body to another GameObject using the director system.
        /// </summary>
        /// <param name="characterBody">The body to teleport.</param>
        /// <param name="target">The GameObject we should teleport to.</param>
        /// <param name="teleportEffect">The teleportation effect we should use upon arrival.</param>
        /// <param name="hullClassification">The hullclassification we should use for traversing the nodegraph.</param>
        /// <param name="rng">The random that we should use to position the body randomly around our target.</param>
        /// <param name="minDistance">How close to the target can we get?</param>
        /// <param name="maxDistance">How far out from the target can we get?</param>
        /// <param name="teleportAir">Should we use the air nodes?</param>
        /// <returns>A bool representing if the teleportation was successful or not.</returns>
        public static bool TeleportBody(CharacterBody characterBody, GameObject target, GameObject teleportEffect, HullClassification hullClassification, Xoroshiro128Plus rng, float minDistance = 20, float maxDistance = 45, bool teleportAir = false)
        {
            if (!characterBody)
            {
                return(false);
            }

            SpawnCard spawnCard = ScriptableObject.CreateInstance <SpawnCard>();

            spawnCard.hullSize      = hullClassification;
            spawnCard.nodeGraphType = teleportAir ? MapNodeGroup.GraphType.Air : MapNodeGroup.GraphType.Ground;
            spawnCard.prefab        = Resources.Load <GameObject>("SpawnCards/HelperPrefab");
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, new DirectorPlacementRule
            {
                placementMode = DirectorPlacementRule.PlacementMode.Approximate,
                position      = target.transform.position,
                minDistance   = minDistance,
                maxDistance   = maxDistance
            }, rng));

            if (gameObject)
            {
                TeleportHelper.TeleportBody(characterBody, gameObject.transform.position);
                GameObject teleportEffectPrefab = teleportEffect;
                if (teleportEffectPrefab)
                {
                    EffectManager.SimpleEffect(teleportEffectPrefab, gameObject.transform.position, Quaternion.identity, true);
                }
                UnityEngine.Object.Destroy(gameObject);
                UnityEngine.Object.Destroy(spawnCard);
                return(true);
            }
            else
            {
                UnityEngine.Object.Destroy(spawnCard);
                return(false);
            }
        }
Exemple #11
0
        // Token: 0x06001DEE RID: 7662 RVA: 0x000809C0 File Offset: 0x0007EBC0
        public NodeGraph.NodeIndex FindClosestNodeWithFlagConditions(Vector3 position, HullClassification hullClassification, NodeFlags requiredFlags, NodeFlags forbiddenFlags, bool preventOverhead)
        {
            float num = float.PositiveInfinity;

            NodeGraph.NodeIndex invalid = NodeGraph.NodeIndex.invalid;
            int num2 = 1 << (int)hullClassification;

            for (int i = 0; i < this.nodes.Length; i++)
            {
                NodeFlags flags = this.nodes[i].flags;
                if ((flags & forbiddenFlags) == NodeFlags.None && (flags & requiredFlags) == requiredFlags && (this.nodes[i].forbiddenHulls & (HullMask)num2) == HullMask.None && (this.nodes[i].gateIndex == 0 || this.openGates[(int)this.nodes[i].gateIndex]))
                {
                    Vector3 a            = this.nodes[i].position - position;
                    float   sqrMagnitude = a.sqrMagnitude;
                    if (sqrMagnitude < num && (!preventOverhead || Vector3.Dot(a / Mathf.Sqrt(sqrMagnitude), Vector3.up) <= 0.70710677f))
                    {
                        num     = sqrMagnitude;
                        invalid = new NodeGraph.NodeIndex(i);
                    }
                }
            }
            return(invalid);
        }
Exemple #12
0
 // Token: 0x06001DE9 RID: 7657 RVA: 0x000807B4 File Offset: 0x0007E9B4
 public bool IsLinkSuitableForHull(NodeGraph.LinkIndex linkIndex, HullClassification hullClassification)
 {
     return(linkIndex != NodeGraph.LinkIndex.invalid && linkIndex.linkIndex < this.links.Length && (this.links[linkIndex.linkIndex].hullMask & 1 << (int)hullClassification) != 0 && (this.links[linkIndex.linkIndex].gateIndex == 0 || this.openGates[(int)this.links[linkIndex.linkIndex].gateIndex]));
 }
Exemple #13
0
        // Token: 0x06001DD9 RID: 7641 RVA: 0x0007FC08 File Offset: 0x0007DE08
        public void SetNodes(ReadOnlyCollection <MapNode> mapNodes, ReadOnlyCollection <SerializableBitArray> lineOfSightMasks)
        {
            this.Clear();
            Dictionary <MapNode, NodeGraph.NodeIndex> dictionary = new Dictionary <MapNode, NodeGraph.NodeIndex>();
            List <NodeGraph.Node> list  = new List <NodeGraph.Node>();
            List <NodeGraph.Link> list2 = new List <NodeGraph.Link>();

            for (int i = 0; i < mapNodes.Count; i++)
            {
                MapNode key = mapNodes[i];
                dictionary[key] = new NodeGraph.NodeIndex(i);
            }
            for (int j = 0; j < mapNodes.Count; j++)
            {
                MapNode             mapNode    = mapNodes[j];
                NodeGraph.NodeIndex nodeIndexA = dictionary[mapNode];
                int count = list2.Count;
                for (int k = 0; k < mapNode.links.Count; k++)
                {
                    MapNode.Link link = mapNode.links[k];
                    if (!dictionary.ContainsKey(link.nodeB))
                    {
                        Debug.LogErrorFormat(link.nodeB, "[{0}] Node {1} was not registered.", new object[]
                        {
                            k,
                            link.nodeB
                        });
                    }
                    list2.Add(new NodeGraph.Link
                    {
                        nodeIndexA    = nodeIndexA,
                        nodeIndexB    = dictionary[link.nodeB],
                        distanceScore = link.distanceScore,
                        minJumpHeight = link.minJumpHeight,
                        hullMask      = link.hullMask,
                        jumpHullMask  = link.jumpHullMask,
                        gateIndex     = this.RegisterGateName(link.gateName)
                    });
                }
                HullMask hullMask = mapNode.forbiddenHulls;
                for (HullClassification hullClassification = HullClassification.Human; hullClassification < HullClassification.Count; hullClassification++)
                {
                    bool flag = false;
                    int  num  = 1 << (int)hullClassification;
                    List <MapNode.Link> list3 = mapNode.links;
                    for (int l = 0; l < list3.Count; l++)
                    {
                        if ((list3[l].hullMask & num) != 0)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        hullMask |= (HullMask)num;
                    }
                }
                list.Add(new NodeGraph.Node
                {
                    position      = mapNode.transform.position,
                    linkListIndex = new NodeGraph.LinkListIndex
                    {
                        index = count,
                        size  = (uint)mapNode.links.Count
                    },
                    forbiddenHulls  = hullMask,
                    flags           = mapNode.flags,
                    lineOfSightMask = new SerializableBitArray(lineOfSightMasks[j]),
                    gateIndex       = this.RegisterGateName(mapNode.gateName)
                });
            }
            this.nodes = list.ToArray();
            this.links = list2.ToArray();
        }