コード例 #1
0
        private void UndoSpawn()
        {
            Debug.Log("Easyspawner: Undo spawn action");

            if (spawnActions.Count <= 0)
            {
                return;
            }

            List <GameObject> spawnedGameObjects = spawnActions.Pop();

            Debug.Log("Easyspawner: Destroying " + spawnedGameObjects.Count + " objects");
            string objectName = "objects";

            foreach (GameObject GO in spawnedGameObjects)
            {
                if (GO != null)
                {
                    objectName = GO.name.Remove(GO.name.Length - 7);
                    ZNetView zNetV = GO.GetComponent <ZNetView>();
                    if (zNetV && zNetV.IsValid() && zNetV.IsOwner())
                    {
                        zNetV.Destroy();
                    }
                }
            }

            Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Undo spawn of " + spawnedGameObjects.Count + " " + objectName);
            Debug.Log("Easyspawner: Spawn undone");
        }
コード例 #2
0
 private static void RemoveAllDrops()
 {
     ItemDrop[] itemDrops = UnityEngine.Object.FindObjectsOfType <ItemDrop>();
     foreach (ItemDrop itemDrop in itemDrops)
     {
         ZNetView component = itemDrop.GetComponent <ZNetView>();
         if (component)
         {
             component.Destroy();
         }
     }
 }
コード例 #3
0
        private void Update()
        {
            if (ID == "")
            {
                return;
            }
            var m_task = QuestManager.instance.GetQuest(ID);

            if (m_task == null)
            {
                DBG.blogInfo("Cant find task,Destroy Hunt Target" + ID);
                Traverse.Create(m_cDrop).Field <bool>("m_dropsEnabled").Value = false;
                m_nview.Destroy();
                return;
            }
        }
コード例 #4
0
 // Token: 0x060003E3 RID: 995 RVA: 0x00020838 File Offset: 0x0001EA38
 private void RemoveStartEffects()
 {
     if (this.m_startEffectInstances != null && ZNetScene.instance != null)
     {
         foreach (GameObject gameObject in this.m_startEffectInstances)
         {
             if (gameObject)
             {
                 ZNetView component = gameObject.GetComponent <ZNetView>();
                 if (component.IsValid())
                 {
                     component.ClaimOwnership();
                     component.Destroy();
                 }
             }
         }
         this.m_startEffectInstances = null;
     }
 }
コード例 #5
0
 public static void Reset(Vector3 centerLocation, float radius)
 {
     radius = Mathf.Clamp(radius, 2f, 50f);
     try
     {
         foreach (TerrainModifier terrainModifier in TerrainModifier.GetAllInstances())
         {
             if (terrainModifier != null && Utils.DistanceXZ(Player.m_localPlayer.transform.position, terrainModifier.transform.position) < radius)
             {
                 ZNetView component = terrainModifier.GetComponent <ZNetView>();
                 if (component != null && component.IsValid())
                 {
                     component.ClaimOwnership();
                     component.Destroy();
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #6
0
ファイル: Dungeons.cs プロジェクト: T3kla/ValMods
        public static void Reset(DungeonGenerator dungeon, Bounds?bounds = null)
        {
            Bounds b = bounds ?? new Bounds(dungeon.transform.position, dungeon.m_zoneSize * 2f);

            foreach (var go in SceneManager.GetActiveScene().GetRootGameObjects())
            {
                if (go.transform.position.y < 4000f ||
                    !b.Contains(go.transform.position) ||
                    go.GetComponent <Player>() ||
                    go.GetComponent <TombStone>() ||
                    go == dungeon.gameObject)
                {
                    continue;
                }

                Piece piece = go.GetComponent <Piece>();
                if ((piece != null ? piece.GetCreator() : 0L) != 0L)
                {
                    continue;
                }

                ZNetView netView = go.GetComponent <ZNetView>();
                if (netView != null)
                {
                    netView.GetZDO()?.SetOwner(ZDOMan.instance.GetMyID());
                    netView.Destroy();
                }
                else
                {
                    ZNetScene.instance.Destroy(go);
                }
            }
            dungeon.Generate(ZoneSystem.SpawnMode.Full);
            dungeon.SetLastReset(DateTimeOffset.Now);
            Main.Log.LogInfo($"Dungeon '{dungeon.GetCleanName()}' was regenerated successfully!\n");
        }
コード例 #7
0
        public static void InputCMD(string inCommand)
        {
            if (inCommand.Length > 0)

            {
                if (inCommand.StartsWith(" "))
                {
                    inCommand = inCommand.Remove(0, 1);
                }
                #region env
                if (inCommand.StartsWith("/env"))
                {
                    inCommand = inCommand.Remove(0, 5);
                    //float num1;
                    //if (!float.TryParse(inCommand, NumberStyles.Float, CultureInfo.InvariantCulture, out num1))
                    //{
                    //cprt("Wrong Number");
                    //return;
                    //}
                    if (inCommand == "list")
                    {
                        string wl = "pick from these ones,list: ";
                        foreach (var w in WeatherList)
                        {
                            wl += w;
                            wl += ",";
                        }
                        cprt(wl);
                        return;
                    }
                    if (EnvMan.instance)
                    {
                        if (WeatherList.Contains(inCommand))
                        {
                            if (inCommand == "reset")
                            {
                                EnvMan.instance.m_debugEnv = "";
                                cprt("reset enviroment");
                                return;
                            }
                            EnvMan.instance.m_debugEnv = inCommand;
                            cprt("set enviroment to " + inCommand);
                            return;
                        }
                        else
                        {
                            cprt("Wrong Word,Try /env list");
                        }
                    }
                    blogWarning("EnvMan is null");
                    return;
                }
                #endregion
                #region admin
                if (inCommand == "/amd")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    //isAdmin = true;
                    SetAdmin(true);
                }
                if (inCommand == "/oadm")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    //isAdmin = false;
                    SetAdmin(false);
                }
                if (inCommand == "/gst")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    SetGhost();
                }
                if (inCommand == "/rds")
                {
                    ItemDrop[] array2 = UnityEngine.Object.FindObjectsOfType <ItemDrop>();
                    int        num    = 0;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        ZNetView component = array2[i].GetComponent <ZNetView>();
                        if (component && component.IsValid() && component.IsOwner())
                        {
                            component.Destroy();
                            num++;
                        }
                    }
                    InfoTL("Destoyed " + num.ToString() + " items");
                }
                if (inCommand == "/cam")
                {
                    GameCamera.instance.ToggleFreeFly();
                }
                #region noclip
                if (inCommand == "/noclip")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    SetClip();
                }
                #endregion

                #endregion
                #region Terrain
                if (inCommand.StartsWith("/tf"))
                {
                    inCommand = inCommand.Remove(0, 4);
                    string[] arg = inCommand.Split(new char[] { ',' });
                    if (arg.Length > 2 || arg.Length < 2 || !inCommand.Contains(","))
                    {
                        cprt("/tf syntax wrong");
                        return;
                    }
                    try
                    {
                        float x = float.Parse(arg[0]);
                        float y = float.Parse(arg[1]);
                        Terrain.Flatten(x, y);
                    }
                    catch (Exception e)
                    {
                        blogWarning("/tf failed :" + e);
                    }
                }
                if (inCommand.StartsWith("/trf"))
                {
                    inCommand = inCommand.Remove(0, 5);
                    cprt(inCommand);
                    try
                    {
                        Terrain.RemoveFlora(float.Parse(inCommand));
                    }
                    catch (Exception e)
                    {
                        blogWarning("/trf failed:" + e);
                    }
                }
                if (inCommand.StartsWith("/trst"))
                {
                    inCommand = inCommand.Remove(0, 6);
                    cprt(inCommand);
                    try
                    {
                        Terrain.Reset(Player.m_localPlayer.transform.position, float.Parse(inCommand));
                    }
                    catch (Exception e)
                    {
                        blogWarning("/trst failed:" + e);
                    }
                }
                #endregion
                #region tod
                if (inCommand.StartsWith("/tod"))
                {
                    float a = 0;
                    inCommand = inCommand.Remove(0, 5);
                    try { a = float.Parse(inCommand); }
                    catch (Exception)
                    {
                        cprt("Wrong Number");
                    }
                    if (a <= 0 || a >= 1)
                    {
                        EnvMan.instance.m_debugTimeOfDay = false;
                        return;
                    }
                    EnvMan.instance.m_debugTimeOfDay = true;
                    EnvMan.instance.m_debugTime      = a;
                }
                #endregion
                #region tame
                if (inCommand == "/tame")
                {
                    Tameable.TameAllInArea(Player.m_localPlayer.transform.position, 30f);
                }
                #endregion
                #region list
                if (inCommand.StartsWith("/listi"))
                {
                    inCommand = inCommand.Remove(0, 7);
                    if (inCommand.Length > 0)
                    {
                        string list = "Result: ";
                        if (inCommand.StartsWith("?"))
                        {
                            foreach (GameObject g in ObjectDB.instance.m_items)
                            {
                                ItemDrop component = g.GetComponent <ItemDrop>();
                                list += component.name;
                                list += ",";
                                list  = LimitLog(list);
                            }
                            list = LimitLog(list);
                            if (list != "")
                            {
                                Traverse.Create(MessageHud.instance).Method("AddLog", new object[] { list }).GetValue();
                                cprt(list);
                                cprt("Check your Message Log");
                                list = "";
                                return;
                            }
                            return;
                        }
                        using (List <GameObject> .Enumerator enumerator3 = ObjectDB.instance.m_items.GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                GameObject g2 = enumerator3.Current;
                                ItemDrop   c2 = g2.GetComponent <ItemDrop>();
                                if (c2.name.ToLower().Contains(inCommand.ToLower()))
                                {
                                    list += c2.name;
                                    list += ",";
                                    list  = LimitLog(list);
                                }
                            }
                            list = LimitLog(list);
                            if (list != "")
                            {
                                Traverse.Create(MessageHud.instance).Method("AddLog", new object[] { list }).GetValue();
                                cprt(list);
                                cprt("Check your Message Log");
                                list = "";
                                return;
                            }
                            return;
                        }
                    }
                    return;
                }
                #endregion
                #region trader
                if (inCommand == "/trader")
                {
                    Game.instance.DiscoverClosestLocation("Vendor_BlackForest", Player.m_localPlayer.transform.position, "Merchant", 8);
                    Minimap.PinData pinData = Enumerable.First <Minimap.PinData>((List <Minimap.PinData>)Traverse.Create(Minimap.instance).Field("m_pins").GetValue(), (Minimap.PinData p) => p.m_type == Minimap.PinType.None && p.m_name == "");
                    return;
                }
                #endregion
                #region spi
                if (inCommand.StartsWith("/spi"))
                {
                    inCommand = inCommand.Remove(0, 5);
                    string[] c = inCommand.Split(new char[] { ' ' });
                    if (c.Length == 1)
                    {
                        FT.SpawnPrefab(c[0], Player.m_localPlayer);
                        return;
                    }
                    if (c.Length == 2)
                    {
                        int amt = 1;
                        if (!int.TryParse(c[1], out amt))
                        {
                            cprt("Wrong Syntax");
                            return;
                        }
                        FT.SpawnPrefab(c[0], Player.m_localPlayer, amt);
                    }
                    else
                    {
                        cprt("Wrong Syntax");
                        return;
                    }
                }
                #endregion
                //end
            }
        }
コード例 #8
0
        private static int ResetTerrain(Vector3 center, float radius)
        {
            int resets            = 0;
            List <Heightmap> list = new List <Heightmap>();


            Heightmap.FindHeightmap(center, radius + 100, list);


            List <TerrainModifier> allInstances = TerrainModifier.GetAllInstances();

            foreach (TerrainModifier terrainModifier in allInstances)
            {
                Vector3  position = terrainModifier.transform.position;
                ZNetView nview    = terrainModifier.GetComponent <ZNetView>();
                if (nview != null && nview.IsValid() && nview.IsOwner() && Utils.DistanceXZ(position, center) <= radius)
                {
                    //Dbgl($"TerrainModifier {position}, player {playerPos}, distance: {Utils.DistanceXZ(position, playerPos)}");
                    resets++;
                    foreach (Heightmap heightmap in list)
                    {
                        if (heightmap.TerrainVSModifier(terrainModifier))
                        {
                            heightmap.Poke(true);
                        }
                    }
                    nview.Destroy();
                }
            }
            Dbgl($"Reset {resets} mod edits");

            using (List <Heightmap> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    TerrainComp terrainComp = TerrainComp.FindTerrainCompiler(enumerator.Current.transform.position);
                    if (!terrainComp)
                    {
                        continue;
                    }
                    Traverse traverse = Traverse.Create(terrainComp);

                    if (!traverse.Field("m_initialized").GetValue <bool>())
                    {
                        continue;
                    }

                    enumerator.Current.WorldToVertex(center, out int x, out int y);

                    bool[]  m_modifiedHeight = traverse.Field("m_modifiedHeight").GetValue <bool[]>();
                    float[] m_levelDelta     = traverse.Field("m_levelDelta").GetValue <float[]>();
                    float[] m_smoothDelta    = traverse.Field("m_smoothDelta").GetValue <float[]>();
                    bool[]  m_modifiedPaint  = traverse.Field("m_modifiedPaint").GetValue <bool[]>();
                    Color[] m_paintMask      = traverse.Field("m_paintMask").GetValue <Color[]>();

                    int m_width = traverse.Field("m_width").GetValue <int>();

                    Dbgl($"Checking heightmap at {terrainComp.transform.position}");
                    int  thisResets = 0;
                    bool thisReset  = false;
                    int  num        = m_width + 1;
                    for (int h = 0; h < num; h++)
                    {
                        for (int w = 0; w < num; w++)
                        {
                            int idx = h * num + w;

                            if (!m_modifiedHeight[idx])
                            {
                                continue;
                            }

                            //Dbgl($"Player coord {x},{y} coord {w},{h}, distance {CoordDistance(x, y, w, h)} has edits. ");

                            if (CoordDistance(x, y, w, h) > radius)
                            {
                                continue;
                            }

                            //Dbgl("In range, resetting");

                            resets++;
                            thisResets++;
                            thisReset = true;

                            m_modifiedHeight[idx] = false;
                            m_levelDelta[idx]     = 0;
                            m_smoothDelta[idx]    = 0;
                        }
                    }

                    num = m_width;
                    for (int h = 0; h < num; h++)
                    {
                        for (int w = 0; w < num; w++)
                        {
                            int idx = h * num + w;

                            if (!m_modifiedPaint[idx])
                            {
                                continue;
                            }

                            if (CoordDistance(x, y, w, h) > radius)
                            {
                                continue;
                            }

                            thisReset            = true;
                            m_modifiedPaint[idx] = false;
                            m_paintMask[idx]     = Color.clear;
                        }
                    }

                    if (thisReset)
                    {
                        Dbgl($"\tReset {thisResets} comp edits");

                        traverse.Field("m_modifiedHeight").SetValue(m_modifiedHeight);
                        traverse.Field("m_levelDelta").SetValue(m_levelDelta);
                        traverse.Field("m_smoothDelta").SetValue(m_smoothDelta);
                        traverse.Field("m_modifiedPaint").SetValue(m_modifiedPaint);
                        traverse.Field("m_paintMask").SetValue(m_paintMask);

                        traverse.Method("Save").GetValue();
                        enumerator.Current.Poke(true);
                    }
                }
            }

            if (resets > 0 && ClutterSystem.instance)
            {
                ClutterSystem.instance.ResetGrass(center, radius);
            }

            return(resets);
        }
コード例 #9
0
ファイル: Console.cs プロジェクト: ingvard/valheim-jserver
    // Token: 0x060004D0 RID: 1232 RVA: 0x00026ED4 File Offset: 0x000250D4
    private void InputText()
    {
        string text = this.m_input.text;

        this.AddString(text);
        string[] array = text.Split(new char[]
        {
            ' '
        });
        if (text.StartsWith("help"))
        {
            this.AddString("kick [name/ip/userID] - kick user");
            this.AddString("ban [name/ip/userID] - ban user");
            this.AddString("unban [ip/userID] - unban user");
            this.AddString("banned - list banned users");
            this.AddString("ping - ping server");
            this.AddString("lodbias - set distance lod bias");
            this.AddString("info - print system info");
            this.AddString("save - force saving of world");
            if (this.IsCheatsEnabled())
            {
                this.AddString("genloc - regenerate all locations.");
                this.AddString("debugmode - fly mode");
                this.AddString("spawn [amount] [level] - spawn something");
                this.AddString("pos - print current player position");
                this.AddString("goto [x,z]- teleport");
                this.AddString("exploremap - explore entire map");
                this.AddString("resetmap - reset map exploration");
                this.AddString("killall - kill nearby enemies");
                this.AddString("tame - tame all nearby tameable creatures");
                this.AddString("hair");
                this.AddString("beard");
                this.AddString("location - spawn location");
                this.AddString("raiseskill [skill] [amount]");
                this.AddString("resetskill [skill]");
                this.AddString("freefly - freefly photo mode");
                this.AddString("ffsmooth - freefly smoothness");
                this.AddString("tod -1 OR [0-1]");
                this.AddString("env [env]");
                this.AddString("resetenv");
                this.AddString("wind [angle] [intensity]");
                this.AddString("resetwind");
                this.AddString("god");
                this.AddString("event [name] - start event");
                this.AddString("stopevent - stop current event");
                this.AddString("randomevent");
                this.AddString("resetcharacter - reset character data");
                this.AddString("removedrops - remove all item-drops in area");
                this.AddString("setkey [name]");
                this.AddString("resetkeys [name]");
                this.AddString("listkeys");
                this.AddString("players [nr] - force diffuculty scale ( 0 = reset)");
                this.AddString("dpsdebug - toggle dps debug print");
            }
        }
        if (array[0] == "devcommands")
        {
            this.m_cheat = !this.m_cheat;
            this.AddString("Dev commands: " + this.m_cheat.ToString());
            this.AddString("WARNING: using any dev commands is not recommended and is done on your own risk.");
            Gogan.LogEvent("Cheat", "CheatsEnabled", this.m_cheat.ToString(), 0L);
            return;
        }
        if (array[0] == "hidebetatext" && Hud.instance)
        {
            Hud.instance.ToggleBetaTextVisible();
        }
        if (array[0] == "ping")
        {
            if (Game.instance)
            {
                Game.instance.Ping();
            }
            return;
        }
        if (array[0] == "dpsdebug")
        {
            Character.SetDPSDebug(!Character.IsDPSDebugEnabled());
            this.AddString("DPS debug " + Character.IsDPSDebugEnabled().ToString());
        }
        if (!(array[0] == "lodbias"))
        {
            if (array[0] == "info")
            {
                this.Print("Render threading mode:" + SystemInfo.renderingThreadingMode);
                long totalMemory = GC.GetTotalMemory(false);
                this.Print("Total allocated mem: " + (totalMemory / 1048576L).ToString("0") + "mb");
            }
            if (array[0] == "gc")
            {
                long totalMemory2 = GC.GetTotalMemory(false);
                GC.Collect();
                long totalMemory3 = GC.GetTotalMemory(true);
                long num          = totalMemory3 - totalMemory2;
                this.Print(string.Concat(new string[]
                {
                    "GC collect, Delta: ",
                    (num / 1048576L).ToString("0"),
                    "mb   Total left:",
                    (totalMemory3 / 1048576L).ToString("0"),
                    "mb"
                }));
            }
            if (array[0] == "fov")
            {
                Camera mainCamera = Utils.GetMainCamera();
                if (mainCamera)
                {
                    float num2;
                    if (array.Length == 1)
                    {
                        this.Print("Fov:" + mainCamera.fieldOfView);
                    }
                    else if (float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out num2) && num2 > 5f)
                    {
                        this.Print("Setting fov to " + num2);
                        Camera[] componentsInChildren = mainCamera.GetComponentsInChildren <Camera>();
                        for (int i = 0; i < componentsInChildren.Length; i++)
                        {
                            componentsInChildren[i].fieldOfView = num2;
                        }
                    }
                }
            }
            if (ZNet.instance)
            {
                if (text.StartsWith("kick "))
                {
                    string user = text.Substring(5);
                    ZNet.instance.Kick(user);
                    return;
                }
                if (text.StartsWith("ban "))
                {
                    string user2 = text.Substring(4);
                    ZNet.instance.Ban(user2);
                    return;
                }
                if (text.StartsWith("unban "))
                {
                    string user3 = text.Substring(6);
                    ZNet.instance.Unban(user3);
                    return;
                }
                if (text.StartsWith("banned"))
                {
                    ZNet.instance.PrintBanned();
                    return;
                }
                if (array.Length != 0 && array[0] == "save")
                {
                    ZNet.instance.ConsoleSave();
                }
            }
            if (ZNet.instance && ZNet.instance.IsServer() && Player.m_localPlayer && this.IsCheatsEnabled())
            {
                if (array[0] == "genloc")
                {
                    ZoneSystem.instance.GenerateLocations();
                    return;
                }
                if (array[0] == "players" && array.Length >= 2)
                {
                    int num3;
                    if (int.TryParse(array[1], out num3))
                    {
                        Game.instance.SetForcePlayerDifficulty(num3);
                        this.Print("Setting players to " + num3);
                    }
                    return;
                }
                if (array[0] == "setkey")
                {
                    if (array.Length >= 2)
                    {
                        ZoneSystem.instance.SetGlobalKey(array[1]);
                        this.Print("Setting global key " + array[1]);
                    }
                    else
                    {
                        this.Print("Syntax: setkey [key]");
                    }
                }
                if (array[0] == "resetkeys")
                {
                    ZoneSystem.instance.ResetGlobalKeys();
                    this.Print("Global keys cleared");
                }
                if (array[0] == "listkeys")
                {
                    List <string> globalKeys = ZoneSystem.instance.GetGlobalKeys();
                    this.Print("Keys " + globalKeys.Count);
                    foreach (string text2 in globalKeys)
                    {
                        this.Print(text2);
                    }
                }
                if (array[0] == "debugmode")
                {
                    Player.m_debugMode = !Player.m_debugMode;
                    this.Print("Debugmode " + Player.m_debugMode.ToString());
                }
                if (array[0] == "raiseskill")
                {
                    if (array.Length > 2)
                    {
                        string name = array[1];
                        int    num4 = int.Parse(array[2]);
                        Player.m_localPlayer.GetSkills().CheatRaiseSkill(name, (float)num4);
                        return;
                    }
                    this.Print("Syntax: raiseskill [skill] [amount]");
                    return;
                }
                else if (array[0] == "resetskill")
                {
                    if (array.Length > 1)
                    {
                        string name2 = array[1];
                        Player.m_localPlayer.GetSkills().CheatResetSkill(name2);
                        return;
                    }
                    this.Print("Syntax: resetskill [skill]");
                    return;
                }
                else
                {
                    if (text == "sleep")
                    {
                        EnvMan.instance.SkipToMorning();
                        return;
                    }
                    if (array[0] == "skiptime")
                    {
                        double num5 = ZNet.instance.GetTimeSeconds();
                        float  num6 = 240f;
                        if (array.Length > 1)
                        {
                            num6 = float.Parse(array[1]);
                        }
                        num5 += (double)num6;
                        ZNet.instance.SetNetTime(num5);
                        this.Print(string.Concat(new object[]
                        {
                            "Skipping ",
                            num6.ToString("0"),
                            "s , Day:",
                            EnvMan.instance.GetDay(num5)
                        }));
                        return;
                    }
                    if (text == "resetcharacter")
                    {
                        this.AddString("Reseting character");
                        Player.m_localPlayer.ResetCharacter();
                        return;
                    }
                    if (array[0] == "randomevent")
                    {
                        RandEventSystem.instance.StartRandomEvent();
                    }
                    if (text.StartsWith("event "))
                    {
                        if (array.Length <= 1)
                        {
                            return;
                        }
                        string text3 = text.Substring(6);
                        if (!RandEventSystem.instance.HaveEvent(text3))
                        {
                            this.Print("Random event not found:" + text3);
                            return;
                        }
                        RandEventSystem.instance.SetRandomEventByName(text3, Player.m_localPlayer.transform.position);
                        return;
                    }
                    else
                    {
                        if (array[0] == "stopevent")
                        {
                            RandEventSystem.instance.ResetRandomEvent();
                            return;
                        }
                        if (text.StartsWith("removedrops"))
                        {
                            this.AddString("Removing item drops");
                            ItemDrop[] array2 = UnityEngine.Object.FindObjectsOfType <ItemDrop>();
                            for (int i = 0; i < array2.Length; i++)
                            {
                                ZNetView component = array2[i].GetComponent <ZNetView>();
                                if (component && component.IsValid() && component.IsOwner())
                                {
                                    component.Destroy();
                                }
                            }
                        }
                        if (text.StartsWith("freefly"))
                        {
                            this.Print("Toggling free fly camera");
                            GameCamera.instance.ToggleFreeFly();
                            return;
                        }
                        if (array[0] == "ffsmooth")
                        {
                            if (array.Length <= 1)
                            {
                                this.Print(GameCamera.instance.GetFreeFlySmoothness().ToString());
                                return;
                            }
                            float num7;
                            if (!float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out num7))
                            {
                                this.Print("syntax error");
                                return;
                            }
                            this.Print("Setting free fly camera smoothing:" + num7);
                            GameCamera.instance.SetFreeFlySmoothness(num7);
                            return;
                        }
                        else
                        {
                            if (text.StartsWith("location "))
                            {
                                if (array.Length <= 1)
                                {
                                    return;
                                }
                                string  name3 = text.Substring(9);
                                Vector3 pos   = Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 10f;
                                ZoneSystem.instance.TestSpawnLocation(name3, pos);
                            }
                            if (array[0] == "spawn")
                            {
                                if (array.Length <= 1)
                                {
                                    return;
                                }
                                string     text4  = array[1];
                                int        num8   = (array.Length >= 3) ? int.Parse(array[2]) : 1;
                                int        num9   = (array.Length >= 4) ? int.Parse(array[3]) : 1;
                                GameObject prefab = ZNetScene.instance.GetPrefab(text4);
                                if (!prefab)
                                {
                                    Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Missing object " + text4, 0, null);
                                    return;
                                }
                                DateTime now = DateTime.Now;
                                if (num8 == 1)
                                {
                                    Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                                    Character component2 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up, Quaternion.identity).GetComponent <Character>();
                                    if (component2 & num9 > 1)
                                    {
                                        component2.SetLevel(num9);
                                    }
                                }
                                else
                                {
                                    for (int j = 0; j < num8; j++)
                                    {
                                        Vector3 b = UnityEngine.Random.insideUnitSphere * 0.5f;
                                        Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                                        Character component3 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up + b, Quaternion.identity).GetComponent <Character>();
                                        if (component3 & num9 > 1)
                                        {
                                            component3.SetLevel(num9);
                                        }
                                    }
                                }
                                ZLog.Log("Spawn time :" + (DateTime.Now - now).TotalMilliseconds + " ms");
                                Gogan.LogEvent("Cheat", "Spawn", text4, (long)num8);
                                return;
                            }
                            else
                            {
                                if (array[0] == "pos")
                                {
                                    Player localPlayer = Player.m_localPlayer;
                                    if (localPlayer)
                                    {
                                        this.AddString("Player position (X,Y,Z):" + localPlayer.transform.position.ToString("F0"));
                                    }
                                }
                                if (text.StartsWith("goto "))
                                {
                                    string text5     = text.Substring(5);
                                    char[] separator = new char[]
                                    {
                                        ',',
                                        ' '
                                    };
                                    string[] array3 = text5.Split(separator);
                                    if (array3.Length < 2)
                                    {
                                        this.AddString("Syntax /goto x,y");
                                        return;
                                    }
                                    try
                                    {
                                        float  x            = float.Parse(array3[0]);
                                        float  z            = float.Parse(array3[1]);
                                        Player localPlayer2 = Player.m_localPlayer;
                                        if (localPlayer2)
                                        {
                                            Vector3 pos2 = new Vector3(x, localPlayer2.transform.position.y, z);
                                            localPlayer2.TeleportTo(pos2, localPlayer2.transform.rotation, true);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        ZLog.Log("parse error:" + ex.ToString() + "  " + text5);
                                    }
                                    Gogan.LogEvent("Cheat", "Goto", "", 0L);
                                    return;
                                }
                                else
                                {
                                    if (text.StartsWith("exploremap"))
                                    {
                                        Minimap.instance.ExploreAll();
                                        return;
                                    }
                                    if (text.StartsWith("resetmap"))
                                    {
                                        Minimap.instance.Reset();
                                        return;
                                    }
                                    if (text.StartsWith("puke") && Player.m_localPlayer)
                                    {
                                        Player.m_localPlayer.ClearFood();
                                    }
                                    if (text.StartsWith("tame"))
                                    {
                                        Tameable.TameAllInArea(Player.m_localPlayer.transform.position, 20f);
                                    }
                                    if (text.StartsWith("killall"))
                                    {
                                        foreach (Character character in Character.GetAllCharacters())
                                        {
                                            if (!character.IsPlayer())
                                            {
                                                HitData hitData = new HitData();
                                                hitData.m_damage.m_damage = 1E+10f;
                                                character.Damage(hitData);
                                            }
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("heal"))
                                    {
                                        Player.m_localPlayer.Heal(Player.m_localPlayer.GetMaxHealth(), true);
                                        return;
                                    }
                                    if (text.StartsWith("god"))
                                    {
                                        Player.m_localPlayer.SetGodMode(!Player.m_localPlayer.InGodMode());
                                        this.Print("God mode:" + Player.m_localPlayer.InGodMode().ToString());
                                        Gogan.LogEvent("Cheat", "God", Player.m_localPlayer.InGodMode().ToString(), 0L);
                                    }
                                    if (text.StartsWith("ghost"))
                                    {
                                        Player.m_localPlayer.SetGhostMode(!Player.m_localPlayer.InGhostMode());
                                        this.Print("Ghost mode:" + Player.m_localPlayer.InGhostMode().ToString());
                                        Gogan.LogEvent("Cheat", "Ghost", Player.m_localPlayer.InGhostMode().ToString(), 0L);
                                    }
                                    if (text.StartsWith("beard"))
                                    {
                                        string beard = (text.Length >= 6) ? text.Substring(6) : "";
                                        if (Player.m_localPlayer)
                                        {
                                            Player.m_localPlayer.SetBeard(beard);
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("hair"))
                                    {
                                        string hair = (text.Length >= 5) ? text.Substring(5) : "";
                                        if (Player.m_localPlayer)
                                        {
                                            Player.m_localPlayer.SetHair(hair);
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("model "))
                                    {
                                        string s = text.Substring(6);
                                        int    playerModel;
                                        if (Player.m_localPlayer && int.TryParse(s, out playerModel))
                                        {
                                            Player.m_localPlayer.SetPlayerModel(playerModel);
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("tod "))
                                    {
                                        float num10;
                                        if (!float.TryParse(text.Substring(4), NumberStyles.Float, CultureInfo.InvariantCulture, out num10))
                                        {
                                            return;
                                        }
                                        this.Print("Setting time of day:" + num10);
                                        if (num10 < 0f)
                                        {
                                            EnvMan.instance.m_debugTimeOfDay = false;
                                        }
                                        else
                                        {
                                            EnvMan.instance.m_debugTimeOfDay = true;
                                            EnvMan.instance.m_debugTime      = Mathf.Clamp01(num10);
                                        }
                                    }
                                    if (array[0] == "env" && array.Length > 1)
                                    {
                                        string text6 = text.Substring(4);
                                        this.Print("Setting debug enviornment:" + text6);
                                        EnvMan.instance.m_debugEnv = text6;
                                        return;
                                    }
                                    if (text.StartsWith("resetenv"))
                                    {
                                        this.Print("Reseting debug enviornment");
                                        EnvMan.instance.m_debugEnv = "";
                                        return;
                                    }
                                    if (array[0] == "wind" && array.Length == 3)
                                    {
                                        float angle     = float.Parse(array[1]);
                                        float intensity = float.Parse(array[2]);
                                        EnvMan.instance.SetDebugWind(angle, intensity);
                                    }
                                    if (array[0] == "resetwind")
                                    {
                                        EnvMan.instance.ResetDebugWind();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return;
        }
        if (array.Length == 1)
        {
            this.Print("Lod bias:" + QualitySettings.lodBias);
            return;
        }
        float num11;

        if (float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out num11))
        {
            this.Print("Setting lod bias:" + num11);
            QualitySettings.lodBias = num11;
        }
    }
コード例 #10
0
        static void Postfix(Console __instance)
        {
            string text = __instance.m_input.text;

            string[] array = text.Split(new char[]
                                        { ' ' });

            // do not enable unless we are on dedicated server
            if (__instance.IsCheatsEnabled() && !ZNet_Patch.m_isServer)
            {
                if (array[0] == "debugmode")
                {
                    Player.m_debugMode = !Player.m_debugMode;
                    __instance.Print("Debugmode " + Player.m_debugMode.ToString());
                }

                if (text.StartsWith("god"))
                {
                    Player.m_localPlayer.SetGodMode(!Player.m_localPlayer.InGodMode());
                    __instance.Print("God mode:" + Player.m_localPlayer.InGodMode().ToString());
                    Gogan.LogEvent("Cheat", "God", Player.m_localPlayer.InGodMode().ToString(), 0L);
                }

                if (array[0] == "raiseskill")
                {
                    if (array.Length > 2)
                    {
                        string name = array[1];
                        int    num4 = int.Parse(array[2]);
                        Player.m_localPlayer.GetSkills().CheatRaiseSkill(name, (float)num4);
                        return;
                    }
                    __instance.Print("Syntax: raiseskill [skill] [amount]");
                    return;
                }
                else if (array[0] == "resetskill")
                {
                    if (array.Length > 1)
                    {
                        string name2 = array[1];
                        Player.m_localPlayer.GetSkills().CheatResetSkill(name2);
                        return;
                    }
                    __instance.Print("Syntax: resetskill [skill]");
                    return;
                }

                if (text.StartsWith("exploremap"))
                {
                    Minimap.instance.ExploreAll();
                    return;
                }
                if (text.StartsWith("resetmap"))
                {
                    Minimap.instance.Reset();
                    return;
                }
                if (text.StartsWith("puke") && Player.m_localPlayer)
                {
                    Player.m_localPlayer.ClearFood();
                }
                if (text.StartsWith("tame"))
                {
                    Tameable.TameAllInArea(Player.m_localPlayer.transform.position, 20f);
                }
                if (text.StartsWith("killall"))
                {
                    foreach (Character character in Character.GetAllCharacters())
                    {
                        if (!character.IsPlayer())
                        {
                            HitData hitData = new HitData();
                            hitData.m_damage.m_damage = 1E+10f;
                            character.Damage(hitData);
                        }
                    }
                    return;
                }
                if (text.StartsWith("heal"))
                {
                    Player.m_localPlayer.Heal(Player.m_localPlayer.GetMaxHealth(), true);
                    return;
                }

                if (text.StartsWith("ghost"))
                {
                    Player.m_localPlayer.SetGhostMode(!Player.m_localPlayer.InGhostMode());
                    __instance.Print("Ghost mode:" + Player.m_localPlayer.InGhostMode().ToString());
                    Gogan.LogEvent("Cheat", "Ghost", Player.m_localPlayer.InGhostMode().ToString(), 0L);
                }

                if (text.StartsWith("removedrops"))
                {
                    __instance.Print("Removing item drops");
                    ItemDrop[] array2 = UnityEngine.Object.FindObjectsOfType <ItemDrop>();
                    for (int j = 0; j < array2.Length; j++)
                    {
                        ZNetView component = array2[j].GetComponent <ZNetView>();
                        if (component && component.IsValid() && component.IsOwner())
                        {
                            component.Destroy();
                        }
                    }
                }

                if (array[0] == "spawn")
                {
                    if (array.Length <= 1)
                    {
                        return;
                    }
                    string     text4  = array[1];
                    int        num8   = (array.Length >= 3) ? int.Parse(array[2]) : 1;
                    int        num9   = (array.Length >= 4) ? int.Parse(array[3]) : 1;
                    GameObject prefab = ZNetScene.instance.GetPrefab(text4);
                    if (!prefab)
                    {
                        Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Missing object " + text4, 0, null);
                        return;
                    }
                    DateTime now = DateTime.Now;
                    if (num8 == 1)
                    {
                        Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                        Character component2 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up, Quaternion.identity).GetComponent <Character>();
                        if (component2 & num9 > 1)
                        {
                            component2.SetLevel(num9);
                        }
                    }
                    else
                    {
                        for (int j = 0; j < num8; j++)
                        {
                            Vector3 vector = Random.insideUnitSphere * 0.5f;
                            Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                            Character component3 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up + vector, Quaternion.identity).GetComponent <Character>();
                            if (component3 & num9 > 1)
                            {
                                component3.SetLevel(num9);
                            }
                        }
                    }
                    Gogan.LogEvent("Cheat", "Spawn", text4, (long)num8);
                    return;
                }
            }

            return;
        }