Esempio n. 1
0
    // Token: 0x060002F7 RID: 759 RVA: 0x000195B8 File Offset: 0x000177B8
    private void SpawnOnHitTerrain(Vector3 hitPoint, GameObject prefab)
    {
        TerrainModifier componentInChildren = prefab.GetComponentInChildren <TerrainModifier>();

        if (componentInChildren)
        {
            if (!PrivateArea.CheckAccess(hitPoint, componentInChildren.GetRadius(), true, false))
            {
                return;
            }
            if (Location.IsInsideNoBuildLocation(hitPoint))
            {
                return;
            }
        }
        TerrainModifier.SetTriggerOnPlaced(true);
        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(prefab, hitPoint, Quaternion.LookRotation(this.m_character.transform.forward));

        TerrainModifier.SetTriggerOnPlaced(false);
        IProjectile component = gameObject.GetComponent <IProjectile>();

        if (component != null)
        {
            component.Setup(this.m_character, Vector3.zero, this.m_attackHitNoise, null, this.m_weapon);
        }
    }
Esempio n. 2
0
        public void CommonEffect(Player player)
        {
            //Spawn location structure
            var pos = originLocation;
            var rot = Quaternion.LookRotation(originForward) * Quaternion.Euler(0, 90, 0);
            var getLocationMethods = typeof(ZoneSystem).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);
            var method             = (from MethodInfo m in getLocationMethods where m.Name == "GetLocation" && m.GetParameters().Any(param => param.ParameterType == typeof(string)) select m).FirstOrDefault();

            if (method == null)
            {
                throw new NullReferenceException("Could not find ZoneSystem.GetLocation method");
            }
            ZoneSystem.ZoneLocation location = (ZoneSystem.ZoneLocation)method.Invoke(ZoneSystem.instance, new object[] { houseLocationName });
            //m_didZoneTest = true;
            List <GameObject> spawnedGhostObjects = new List <GameObject>();

            typeof(ZoneSystem).GetMethod("SpawnLocation", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(ZoneSystem.instance, new object[] { location, spawnSeed, pos, rot, ZoneSystem.SpawnMode.Full, spawnedGhostObjects });

            //Set up for bed spawning
            var bedPos = originLocation + originForward * commonBedDisplacement;
            var bedRot = rot;

            //Get piece table
            var pieceTableName = "_HammerPieceTable";
            var pieceTable     = (from PieceTable table in Resources.FindObjectsOfTypeAll <PieceTable>() where table.gameObject.name == pieceTableName select table).FirstOrDefault();

            if (pieceTable == null || pieceTable.m_pieces.Count <= 0)
            {
                throw new NullReferenceException("Could not find hammer piece table");
            }
            pieceTable.UpdateAvailable(null, null, false, true); //noPlacementCost set to true - other fields don't matter

            //Select piece
            int        category   = -1;
            Vector2Int pieceIndex = pieceTable.GetPieceIndexVec(bedPieceName, ref category);

            pieceTable.SetCategory(category);
            pieceTable.SetSelected(pieceIndex);

            //Place piece
            var piece = pieceTable.GetSelectedPiece();

            piece.m_description = magicBedDesc;
            TerrainModifier.SetTriggerOnPlaced(trigger: true);
            GameObject gameObject = UnityEngine.Object.Instantiate(piece.gameObject, bedPos, bedRot);

            TerrainModifier.SetTriggerOnPlaced(trigger: false);
            WearNTear wear = gameObject.GetComponent <WearNTear>();

            if ((bool)wear)
            {
                wear.OnPlaced();
            }
            piece.m_description = "";
        }
Esempio n. 3
0
        public static void Flatten(float radiusX, float radiusY)
        {
            if (radiusY <= 0f)
            {
                radiusY = radiusX;
            }
            else if (radiusX <= 0f)
            {
                radiusX = radiusY;
            }
            if (radiusX > 80f)
            {
                radiusX = 80f;
                Plugin.blogWarning("X Length Capped At 80");
            }
            if (radiusY > 80f)
            {
                radiusY = 80f;
                Plugin.blogWarning("Y Length Capped At 80");
            }
            if (radiusX <= 0f)
            {
                radiusX = 1f;
                radiusY = 1f;
                Plugin.blogWarning("Must Be Greater Than Zero");
            }
            Transform transform = Player.m_localPlayer.transform;
            Vector3   position  = transform.position;
            //Log.Message("Attempting To Flatten...");
            GameObject prefab = ZNetScene.instance.GetPrefab("raise");

            if (prefab.GetComponent <Piece>() == null || prefab == null)
            {
                Plugin.blogWarning("Flatten Creation Corrupted : Cancelling!");
                return;
            }
            TerrainModifier.SetTriggerOnPlaced(true);
            int num = 0;

            while ((float)num < radiusX)
            {
                int num2 = 0;
                while ((float)num2 < radiusY)
                {
                    Terrain.SpawnFloor(position + Vector3.down * 0.5f + transform.forward * (float)num + transform.right * (float)num2, transform.rotation, prefab);
                    num2++;
                }
                num++;
            }
            TerrainModifier.SetTriggerOnPlaced(false);
            //Plugin.blogWarning("Flatten Radius Required");
        }
Esempio n. 4
0
        public override void DoMagicAttack(Attack baseAttack)
        {
            var  player        = baseAttack.GetCharacter() as Player;
            bool origPlaceCost = false;

            if (player == null)
            {
                Debug.LogError("Character with home rune not a player");
                return;
            }
            try
            {
                TerrainModifier.SetTriggerOnPlaced(trigger: true);
                switch (_Quality)
                {
                case RuneQuality.Common:
                    CommonEffect(player);
                    break;

                case RuneQuality.Ancient:
                    AncientEffect(player);
                    break;

                case RuneQuality.Dark:
                    DarkEffect(player);
                    break;
                }
                SnapToGround.SnappAll();
                TerrainModifier.SetTriggerOnPlaced(trigger: false);
            }
            catch (Exception e)
            {
                Debug.LogError("Home rune effect failed:\n" + e.ToString());
                player.PickupPrefab(RuneDB.Instance.GetRune("$HomeRune").prefab);
            }
            finally
            {
                typeof(Player).GetMethod("SetPlaceMode", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).Invoke(player, new object[] { null });
                typeof(Player).GetField("m_noPlacementCost", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(player, origPlaceCost);
            }
        }
Esempio n. 5
0
        public static bool Flatten(float radiusX, float radiusY, Transform t)
        {
            if (radiusY <= 0f)
            {
                radiusY = radiusX;
            }
            else if (radiusX <= 0f)
            {
                radiusX = radiusY;
            }
            Transform transform = t;
            Vector3   position  = t.position;

            position = new Vector3(position.x - radiusY / 2, position.y, position.z - radiusY / 2);
            //Log.Message("Attempting To Flatten...");
            GameObject prefab = ZNetScene.instance.GetPrefab("raise");

            if (prefab.GetComponent <Piece>() == null || prefab == null)
            {
                return(false);
            }
            TerrainModifier.SetTriggerOnPlaced(true);
            int num = 0;

            while ((float)num < radiusX)
            {
                int num2 = 0;
                while ((float)num2 < radiusY)
                {
                    Terrain.SpawnFloor(position + Vector3.down * 0.5f + transform.forward * (float)num + transform.right * (float)num2, transform.rotation, prefab);
                    num2++;
                }
                num++;
            }
            TerrainModifier.SetTriggerOnPlaced(false);
            return(true);
        }