Пример #1
0
 void FixedUpdate()
 {
     if (Time.realtimeSinceStartup - lastTick > 0.2f)
     {
         toremovedoors.Clear();
         foreach (BasicDoor door in doors)
         {
             toremovedoors.Add(door);
         }
         foreach (Collider collider in Physics.OverlapSphere(playerclient.lastKnownPosition, 3f, doorLayer))
         {
             if (!collider.GetComponent <BasicDoor>())
             {
                 continue;
             }
             cachedDoor = collider.GetComponent <BasicDoor>();
             if (toremovedoors.Contains(cachedDoor))
             {
                 toremovedoors.Remove(cachedDoor);
             }
             if (!doors.Contains(cachedDoor))
             {
                 OnDoorEntry(cachedDoor);
             }
         }
         foreach (BasicDoor door in toremovedoors)
         {
             OnDoorLeave(door);
         }
         lastTick = Time.realtimeSinceStartup;
     }
 }
Пример #2
0
 void OnDoorEntry(BasicDoor door)
 {
     doors.Add(door);
     if (doorstate.GetValue(door).ToString() == "Closed" || doorstate.GetValue(door).ToString() == "Closing")
     {
         togglestateserver.Invoke(door, new object[] { playerclient.lastKnownPosition, NetCull.timeInMillis, null });
     }
 }
Пример #3
0
 object OnDoorToggle(BasicDoor door, ulong timestamp, Controllable controllable)
 {
     if (controllable == null) return null;
     if (controllable.playerClient == null) return null;
     if (door.GetComponent<DeployableObject>() == null) return null;
     cachedValue = Interface.CallHook("isSharing", door.GetComponent<DeployableObject>().ownerID.ToString(), controllable.playerClient.userID.ToString());
     if (cachedValue is bool && (bool)cachedValue) return toggledoor.Invoke(door, new object[] { controllable.playerClient.lastKnownPosition, timestamp, null });
     return null;
 }
Пример #4
0
 public static bool BasicDoor_ToggleStateServer(BasicDoor hook, ulong timestamp, Controllable controllable)
 {
     object[] args = new object[]
     {
         hook,
         timestamp,
         controllable
     };
     return(Method.Invoke("RustExtended.RustHook.BasicDoor_ToggleStateServer", args).AsBoolean);
 }
Пример #5
0
        public void OnDoorUse(Fougerite.Player p, DoorEvent de)
        {
            BasicDoor door = (from collider in Physics.OverlapSphere(p.Location, 3f, doorLayer) where collider.GetComponent <BasicDoor>() select collider.GetComponent <BasicDoor>()).FirstOrDefault();

            if (DataStore.GetInstance().Get("AutoCloser", p.UID) != null && door != null)
            {
                if (door.state.ToString() != "Closed")
                {
                    return;
                }
                int i    = (int)DataStore.GetInstance().Get("AutoCloser", p.UID);
                var dict = new Dictionary <string, object>();
                dict["Loc"]  = p.Location;
                dict["Door"] = door;
                var c = 1000 * i;
                CreateParallelTimer(c, dict).Start();
            }
        }
Пример #6
0
 object OnDoorToggle(BasicDoor door, ulong timestamp, Controllable controllable)
 {
     if (controllable == null)
     {
         return(null);
     }
     if (controllable.playerClient == null)
     {
         return(null);
     }
     if (door.GetComponent <DeployableObject>() == null)
     {
         return(null);
     }
     cachedValue = Interface.CallHook("isSharing", door.GetComponent <DeployableObject>().ownerID.ToString(), controllable.playerClient.userID.ToString());
     if (cachedValue is bool && (bool)cachedValue)
     {
         return(toggledoor.Invoke(door, new object[] { controllable.playerClient.lastKnownPosition, timestamp, null }));
     }
     return(null);
 }
Пример #7
0
        private void OnCommand(Fougerite.Player player, string cmd, string[] args)
        {
            switch (cmd)
            {
            case "record":
            {
                if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.record"))
                {
                    if (args.Length == 0)
                    {
                        player.MessageFrom("Recorder", "Usage: /record name");
                        return;
                    }

                    object state = DataStore.GetInstance().Get("Recorder", player.UID);
                    if (state != null)
                    {
                        player.MessageFrom("Recorder", "Already Recording!");
                        return;
                    }

                    string name = string.Join("_", args).ToLower();
                    DataStore.GetInstance().Flush("RecordedData" + player.UID);
                    DataStore.GetInstance().Add("Recorder", player.UID, 1);
                    DataStore.GetInstance().Add("Recorder_Name", player.UID, name);
                    player.MessageFrom("Recorder", "Recording " + name + ".ini (/rstop to finish!)");
                }

                break;
            }

            case "rspawn":
                if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rspawn"))
                {
                    if (args.Length != 2)
                    {
                        player.MessageFrom("Recorder", "Usage: /rspawn name.ini distance");
                        return;
                    }

                    float distance = 0f;
                    bool  success  = float.TryParse(args[1], out distance);
                    if (!success)
                    {
                        player.MessageFrom("Recorder", "Usage: /rspawn name.ini distance");
                        return;
                    }

                    if (!File.Exists(Path.Combine(ModuleFolder, "Buildings\\" + args[0])))
                    {
                        player.MessageFrom("Recorder", "Building not found!");
                        return;
                    }

                    IniParser file = new IniParser(Path.Combine(ModuleFolder, "Buildings\\" + args[0]));

                    DataStore.GetInstance().Flush("SpawnedData" + player.UID);
                    DataStore.GetInstance().Remove("RecorderSMs", player.UID);

                    Vector3 playerFront    = Util.GetUtil().Infront(player, distance);
                    float   groundposition = World.GetWorld().GetGround(playerFront.x, playerFront.z);
                    //playerFront.y = World.GetGround(playerFront.x, playerFront.z);

                    List <string> sections = file.Sections.Where(x => x != "Init").ToList();

                    StructureMaster master   = null;
                    int             failures = 0;
                    for (int i = 0; i < sections.Count; i++)
                    {
                        Vector3 entPos = Util.GetUtil().CreateVector(float.Parse(file.GetSetting("Part" + i, "PosX")),
                                                                     float.Parse(file.GetSetting("Part" + i, "PosY")),
                                                                     float.Parse(file.GetSetting("Part" + i, "PosZ")));


                        Vector3 spawnPos = Util.GetUtil().CreateVector(entPos.x + playerFront.x, entPos.y + groundposition,
                                                                       entPos.z + playerFront.z);

                        Quaternion spawnRot = Util.GetUtil().CreateQuat(float.Parse(file.GetSetting("Part" + i, "RotX")),
                                                                        float.Parse(file.GetSetting("Part" + i, "RotY")),
                                                                        float.Parse(file.GetSetting("Part" + i, "RotZ")),
                                                                        float.Parse(file.GetSetting("Part" + i, "RotW")));


                        if (master == null)
                        {
                            master = World.GetWorld()
                                     .CreateSM(player, spawnPos.x, spawnPos.y, spawnPos.z, spawnRot);
                        }

                        Entity go = null;
                        try
                        {
                            go = World.GetWorld().SpawnEntity(file.GetSetting("Part" + i, "Prefab"), spawnPos,
                                                              spawnRot);
                        }
                        catch
                        {
                            failures++;
                            // Ignore.
                            continue;
                        }

                        try
                        {
                            if (go.IsLootableObject())
                            {
                                LootableObject lootableObject = (LootableObject)go.Object;
                                go.ChangeOwner(player);
                                DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part" + i,
                                                            lootableObject.gameObject);
                            }
                            else if (go.IsDeployableObject())
                            {
                                go.ChangeOwner(player);
                                DeployableObject deployableObject = (DeployableObject)go.Object;

                                DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part" + i,
                                                            deployableObject.gameObject);
                            }
                            else if (go.IsBasicDoor())
                            {
                                BasicDoor door = (BasicDoor)go.Object;
                                go.ChangeOwner(player);
                                DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part",
                                                            door.gameObject);
                            }
                            else if (go.IsStructure())
                            {
                                StructureComponent structureComponent = (StructureComponent)go.Object;

                                master.AddStructureComponent(structureComponent);
                                DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part" + i,
                                                            structureComponent.gameObject);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("[Recorder] Error: " + ex);
                            Logger.LogError("At prefab: " + file.GetSetting("Part" + i, "Prefab"));
                        }
                    }

                    player.MessageFrom("Recorder", args[0] + " was spawned !");
                    if (failures > 0)
                    {
                        player.MessageFrom("Recorder", failures + " amount of failures happened. This file might have wrong values!");
                    }
                }
                break;

            case "rlist":
                if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rlist"))
                {
                    string[] files = Directory.GetFiles(Path.Combine(ModuleFolder, "Buildings\\"), "*.ini");

                    for (int i = 0; i < files.Length; i++)
                    {
                        files[i] = Path.GetFileName(files[i]);
                    }

                    player.MessageFrom("Recorder", "=== Files ===");
                    player.MessageFrom("Recorder", string.Join(", ", files));
                }

                break;

            case "rcancel":
                if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rcancel"))
                {
                    int cpt = DataStore.GetInstance().Count("SpawnedData" + player.UID);
                    for (int i = 0; i < cpt; i++)
                    {
                        GameObject ent = DataStore.GetInstance().Get("SpawnedData" + player.UID, "Part" + i) as GameObject;
                        if (ent != null)
                        {
                            Util.GetUtil().DestroyObject(ent);
                        }
                        DataStore.GetInstance().Remove("Recorder", player.UID);
                        DataStore.GetInstance().Flush("RecordedData" + player.UID);
                        DataStore.GetInstance().Flush("SpawnedData" + player.UID);
                        DataStore.GetInstance().Remove("RecorderInit", player.UID);
                        DataStore.GetInstance().Remove("RecorderSMs", player.UID);
                    }

                    DataStore.GetInstance().Flush("SpawnedData" + player.UID);
                    player.Message("Cancelled recording");
                }
                break;

            case "rstop":
                if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rstop"))
                {
                    string name = (string)DataStore.GetInstance().Get("Recorder_Name", player.UID);
                    if (File.Exists(Path.Combine(ModuleFolder, "Buildings\\" + name)))
                    {
                        var rnd  = new Random();
                        int rnd2 = rnd.Next(0, 500000);
                        player.Message(name + ".ini already exists ! renaming..");
                        name = name + rnd2;
                    }

                    name = name + ".ini";

                    Vector3 loc            = (Vector3)DataStore.GetInstance().Get("RecorderInit", player.UID);
                    float   groundposition = World.GetWorld().GetGround(loc.x, loc.z);
                    //loc.y = World.GetGround(loc.x, loc.z)

                    int cpt = DataStore.GetInstance().Count("RecordedData" + player.UID);
                    if (cpt == 0)
                    {
                        DataStore.GetInstance().Flush("RecordedData" + player.UID);
                        return;
                    }

                    if (!File.Exists(Path.Combine(ModuleFolder, "Buildings\\" + name)))
                    {
                        File.Create(Path.Combine(ModuleFolder, "Buildings\\" + name)).Dispose();
                    }
                    IniParser rfile = new IniParser(Path.Combine(ModuleFolder, "Buildings\\" + name));

                    for (int i = 0; i < cpt; i++)
                    {
                        Entity  ent    = (Entity)DataStore.GetInstance().Get("RecordedData" + player.UID, "Part" + i);
                        Vector3 entPos = new Vector3((ent.X - loc.x), (ent.Y - groundposition),
                                                     (ent.Z - loc.z));
                        Quaternion spawnRot = ent.Rotation;

                        rfile.AddSetting("Part" + i, "Prefab", Prefabs[ent.Name]);
                        rfile.AddSetting("Part" + i, "PosX", entPos.x.ToString(CultureInfo.CurrentCulture));
                        rfile.AddSetting("Part" + i, "PosY", entPos.y.ToString(CultureInfo.CurrentCulture));
                        rfile.AddSetting("Part" + i, "PosZ", entPos.z.ToString(CultureInfo.CurrentCulture));
                        rfile.AddSetting("Part" + i, "RotX", spawnRot.x.ToString(CultureInfo.CurrentCulture));
                        rfile.AddSetting("Part" + i, "RotY", spawnRot.y.ToString(CultureInfo.CurrentCulture));
                        rfile.AddSetting("Part" + i, "RotZ", spawnRot.z.ToString(CultureInfo.CurrentCulture));
                        rfile.AddSetting("Part" + i, "RotW", spawnRot.w.ToString(CultureInfo.CurrentCulture));
                    }

                    DataStore.GetInstance().Remove("Recorder", player.UID);
                    DataStore.GetInstance().Flush("RecordedData" + player.UID);
                    DataStore.GetInstance().Flush("SpawnedData" + player.UID);
                    DataStore.GetInstance().Remove("RecorderInit", player.UID);
                    DataStore.GetInstance().Remove("RecorderSMs", player.UID);
                    DataStore.GetInstance().Flush("SpawnedData" + player.UID);
                    rfile.Save();
                    player.MessageFrom("Recorder", name + " was saved !");
                }
                break;
            }
        }
Пример #8
0
        private void DrawRaidESP()
        {
            Character localCharacter = HackLocal.LocalCharacter;

            if (HackLocal.DoorObjects != null)
            {
                UnityEngine.Object[] doorObjects = HackLocal.DoorObjects;
                for (int i = 0; i < doorObjects.Length; i++)
                {
                    UnityEngine.Object @object = doorObjects[i];
                    if (!(@object == null))
                    {
                        BasicDoor basicDoor = (BasicDoor)@object;
                        float     num       = Vector3.Distance(basicDoor.transform.position, localCharacter.transform.position);
                        if (CVars.ESP.DrawRaid && num < 200f)
                        {
                            basicDoor.gameObject.renderer.material.shader = this.shader;
                        }
                        else
                        {
                            if (basicDoor.name.Contains("Metal"))
                            {
                                if (this.shaderStandart1 == null)
                                {
                                    this.shaderStandart1 = basicDoor.gameObject.renderer.material.shader;
                                }
                                basicDoor.gameObject.renderer.material.shader = this.shaderStandart1;
                            }
                            else
                            {
                                if (basicDoor.name.Contains("Wooden"))
                                {
                                    if (this.shaderStandart == null)
                                    {
                                        this.shaderStandart = basicDoor.gameObject.renderer.material.shader;
                                    }
                                    basicDoor.gameObject.renderer.material.shader = this.shaderStandart;
                                }
                                else
                                {
                                    if (this.shaderStandart2 == null)
                                    {
                                        this.shaderStandart2 = basicDoor.gameObject.renderer.material.shader;
                                    }
                                    basicDoor.gameObject.renderer.material.shader = this.shaderStandart2;
                                }
                            }
                        }
                    }
                }
            }
            if (HackLocal.LootableObjects != null)
            {
                UnityEngine.Object[] lootableObjects = HackLocal.LootableObjects;
                for (int j = 0; j < lootableObjects.Length; j++)
                {
                    UnityEngine.Object object2 = lootableObjects[j];
                    if (!(object2 == null))
                    {
                        LootableObject lootableObject = (LootableObject)object2;
                        float          num2           = Vector3.Distance(lootableObject.transform.position, localCharacter.transform.position);
                        if (lootableObject.name.Contains("WoodBox") || lootableObject.name.Contains("Stash"))
                        {
                            if (CVars.ESP.DrawRaid && num2 < 200f)
                            {
                                lootableObject.gameObject.renderer.material.shader = this.shader;
                            }
                            else
                            {
                                if (lootableObject.name.Contains("Stash"))
                                {
                                    lootableObject.gameObject.renderer.material.shader = this.shaderStandart1;
                                }
                                else
                                {
                                    lootableObject.gameObject.renderer.material.shader = this.shaderStandart;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Checks if the object is a BasicDoor
        /// </summary>
        /// <returns></returns>
        public bool IsBasicDoor()
        {
            BasicDoor str = this.Object as BasicDoor;

            return(str != null);
        }
Пример #10
0
 private void OnDoorToggle(BasicDoor door, ulong timestamp, Controllable Controllable)
 {
     HookCalled("OnDoorToggle");
 }
Пример #11
0
 private void OnDoorToggle(BasicDoor door, ulong timestamp, Controllable controllable)
 {
     HookCalled("OnDoorToggle");
     // Print door used
     Puts(controllable.netUser.displayName + " used the door " + door.GetInstanceID() + " owned by the player with SteamID " + door.GetComponent<DeployableObject>().ownerID);
 }
Пример #12
0
        private void DrawRaidESP()
        {
            Character localCharacter = ESP_UpdateOBJs.LocalCharacter;

            if (ESP_UpdateOBJs.DoorOBJs != null)
            {
                foreach (UnityEngine.Object obj2 in ESP_UpdateOBJs.DoorOBJs)
                {
                    if (obj2 != null)
                    {
                        BasicDoor door = (BasicDoor)obj2;
                        float     num  = Vector3.Distance(door.transform.position, localCharacter.transform.position);
                        if (CVars.ESP.DrawRaid && (num < 200f))
                        {
                            door.gameObject.renderer.material.shader = this.shader;
                        }
                        else if (door.name.Contains("Metal"))
                        {
                            if (this.shaderStandart1 == null)
                            {
                                this.shaderStandart1 = door.gameObject.renderer.material.shader;
                            }
                            door.gameObject.renderer.material.shader = this.shaderStandart1;
                        }
                        else if (door.name.Contains("Wooden"))
                        {
                            if (this.shaderStandart == null)
                            {
                                this.shaderStandart = door.gameObject.renderer.material.shader;
                            }
                            door.gameObject.renderer.material.shader = this.shaderStandart;
                        }
                        else
                        {
                            if (this.shaderStandart2 == null)
                            {
                                this.shaderStandart2 = door.gameObject.renderer.material.shader;
                            }
                            door.gameObject.renderer.material.shader = this.shaderStandart2;
                        }
                    }
                }
            }
            if (ESP_UpdateOBJs.LootableOBJs != null)
            {
                foreach (UnityEngine.Object obj3 in ESP_UpdateOBJs.LootableOBJs)
                {
                    if (obj3 != null)
                    {
                        LootableObject obj4 = (LootableObject)obj3;
                        float          num2 = Vector3.Distance(obj4.transform.position, localCharacter.transform.position);
                        if (CVars.ESP.DrawRaid)
                        {
                            if (obj4.name.Contains("WoodBoxLarge") || obj4.name.Contains("Stash"))
                            {
                                if (num2 < 200f)
                                {
                                    obj4.gameObject.renderer.material.shader = this.shader;
                                }
                                else if (obj4.name.Contains("Stash"))
                                {
                                    obj4.gameObject.renderer.material.shader = this.shaderStandart1;
                                }
                            }
                        }
                        else
                        {
                            obj4.gameObject.renderer.material.shader = this.shaderStandart2;
                        }
                    }
                }
            }
        }
Пример #13
0
 private void OnDoorToggle(BasicDoor door, ulong timestamp, Controllable Controllable)
 {
     HookCalled("OnDoorToggle");
 }