Exemple #1
0
    public void CloseLootPanel()
    {
        if (lootedObject == null)
        {
            for (int i = 0; i < slots.Length; i++)
            {
                slots[i].ClearSlot();
            }
            gameObject.SetActive(false);
            return;
        }

        for (int i = 0; i < slots.Length; i++)
        {
            if (slots[i].HasItem())
            {
                lootedObject.AddLoot(slots[i].GetItem());
            }
            slots[i].ClearSlot();
        }

        if (lootedObject.destroyOnLooted && lootedObject.GetNumItemsInLoot() <= 0)
        {
            lootedObject.DestroyLootedObject();
        }

        UIManager.Instance.PlayCloseMenuSound();
        lootedObject = null;
        gameObject.SetActive(false);
    }
Exemple #2
0
            private static GameObject smethod_183(Spawns.SpawnerLootable spawnerLootable_0)
            {
                GameObject result;

                if (spawnerLootable_0.SpawnedObject == null && spawnerLootable_0.vector3_0 != Vector3.zero && spawnerLootable_0.List.Count > 0)
                {
                    string text = spawnerLootable_0.method_0();
                    if (text != null)
                    {
                        Vector3 vector;
                        Vector3 vector2;
                        TransformHelpers.GetGroundInfo(spawnerLootable_0.vector3_0, out vector, out vector2);
                        if (text == "BoxLoot")
                        {
                            vector.y += 0.35f;
                        }
                        Quaternion     quaternion = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f);
                        GameObject     gameObject = NetCull.InstantiateStatic(text, vector, quaternion);
                        LootableObject component  = gameObject.GetComponent <LootableObject>();
                        if (component != null)
                        {
                            component.LootCycle = spawnerLootable_0.List[text].LootCycle;
                            component.lifeTime  = spawnerLootable_0.List[text].LifeTime;
                            component.ResetInvokes();
                        }
                        result = gameObject;
                        return(result);
                    }
                }
                result = spawnerLootable_0.SpawnedObject;
                return(result);
            }
    public void DamageBlock(string stringDamage)
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 10f, 1))
        {
            GameObject go = hit.transform.gameObject;

            if (!InventoryManager.inventory.isFull() || !InventoryManager.actionBar.isFull())
            {
                int    damage  = int.Parse(stringDamage);
                Health _health = go.GetComponent <Health>();
                _health.health -= damage;

                if (_health.health <= 0)
                {
                    LootableObject lo = _health.GetComponent <LootableObject>();

                    InventoryElement ie = new InventoryElement(InventoryDatabase.GetElement(lo.elementID));

                    if (!InventoryManager.inventory.isFull())
                    {
                        InventoryManager.inventory.AddItem(ref ie, false);
                    }
                    else if (!InventoryManager.actionBar.isFull())
                    {
                        InventoryManager.actionBar.AddItem(ref ie, false);
                    }

                    Destroy(go);
                }
            }
        }
    }
    public void DropLootBag()
    {
        if (droppedLootBag == null)
        {
            Debug.Log("No lootbag found! Add one in the inspector!");
            return;
        }

        GenerateItemList();

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

        GameObject     lootBag        = Instantiate(droppedLootBag, new Vector3(transform.position.x, transform.position.y + 0.05f, transform.position.z), Quaternion.identity);
        LootableObject lootableObject = lootBag.GetComponent <LootableObject>();

        lootableObject.SetLootList(itemList);
        lootableObject.SetStackedItems(stackedItems);

        if (goldAmount > 0)
        {
            lootableObject.SetGoldAmount(goldAmount);
        }
    }
Exemple #5
0
    public void LoadItems(List <Item> items, Dictionary <Item, int> stackedItems, LootableObject objectLooted) //items is passed by reference from the looted object. Clearing it here will clear it in the lootable object class too.
    {
        CloseLootPanel();                                                                                      //Reset loot panel just in case.
        UIManager.Instance.PlayOpenMenuSound();
        UIManager.Instance.HideToolTip();
        gameObject.SetActive(true);
        lootedObject = objectLooted;

        for (int i = 0; i < items.Count; i++)
        {
            if (slots[i] != null)
            {
                if (items[i] is Gold)
                {
                    items[i].sellValue = objectLooted.GetGoldAmount();
                }

                if (items[i].stackable && stackedItems.ContainsKey(items[i]))
                {
                    slots[i].AddItem(items[i], stackedItems[items[i]]);
                }
                else
                {
                    slots[i].AddItem(items[i], 1);
                }
            }
            filledSlots = 1 + i;
        }
        items.Clear();
    }
    public override void OnInspectorGUI()
    {
        LootableObject lo = target as LootableObject;

        EditorGUILayout.PropertyField(serializedObject.FindProperty("elementID"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("stack"));
    }
 private void FillWithItems(LootableObject lootableObject, List <Item> items)
 {
     foreach (var item in items)
     {
         lootableObject._inventory.AddItem(DatablockDictionary.GetByName(item.ItemName),
                                           Inventory.Slot.Preference.Define(Inventory.Slot.Kind.Default),
                                           Inventory.Uses.Quantity.Manual(item.Amount));
     }
 }
Exemple #8
0
    // Update is called once per frame
    void Update()
    {
        if (cameraComponent != null)
        {
            if (Physics.Raycast(transform.position, cameraComponent.transform.forward, out hit, distance, layerMask))
            {
                if (hit.transform.gameObject != null)
                {
                    GameObject possibleItem = hit.transform.gameObject;

                    if (possibleItem.GetComponent <LootableObject>() != null)
                    {
                        if (Input.GetKeyDown(lootKey))
                        {
                            if (lootableObject != possibleItem.GetComponent <LootableObject>())
                            {
                                lootableObject = possibleItem.GetComponent <LootableObject>();

                                InventoryElement invElem = InventoryDatabase.GetElement(lootableObject.elementID);

                                temp = new InventoryElement(invElem);
                            }
                            else
                            {
                                lootableObject.stack = temp.stack;
                            }

                            if (temp != null)
                            {
                                temp.stack = lootableObject.stack;

                                if (priority.Count > 0)
                                {
                                    foreach (InventoryObject invOb in priority)
                                    {
                                        if (invOb != null)
                                        {
                                            if (invOb.AddItem(ref temp, false))
                                            {
                                                Destroy(lootableObject.gameObject);
                                            }

                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    Debug.Log("Set up the priority system in FirstPersonLooting!");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #9
0
 public static bool LootableObject_ContextRespond_OpenLoot(LootableObject loot, Controllable controllable, ulong timestamp)
 {
     object[] args = new object[]
     {
         loot,
         controllable,
         timestamp
     };
     return(Method.Invoke("RustExtended.RustHook.LootableObject_ContextRespond_OpenLoot", args).AsBoolean);
 }
Exemple #10
0
 private void Start()
 {
     if (GetComponentInChildren <LootableObject>())
     {
         LootableObject node = GetComponentInChildren <LootableObject>();
         node.OnFinishedLooting += StartSpawnCoroutine;
         spawnedNode             = node.gameObject;
     }
     else
     {
         Spawn();
     }
 }
 void DestroySack(LootableObject sack)
 {
     if (sack != null)
     {
         if (dontremoveiflooted && ((uLink.NetworkPlayer)usingPlayer.GetValue(sack) != uLink.NetworkPlayer.unassigned))
         {
             timer.Once(1f, () => DestroySack(sack));
         }
         else
         {
             NetCull.Destroy(sack.gameObject);
         }
     }
 }
    void Loot()
    {
        if (hit.transform.gameObject != null)
        {
            GameObject possibleItem = hit.transform.gameObject;

            LootableObject cache = possibleItem.GetComponent <LootableObject>();

            if (cache != null)
            {
                InventoryElement invElem = InventoryDatabase.GetElement(cache.elementID);

                temp = new InventoryElement(invElem);

                if (temp != null)
                {
                    temp.stack = cache.stack;

                    if (priority.Count > 0)
                    {
                        foreach (InventoryObject invOb in priority)
                        {
                            if (invOb != null)
                            {
                                if (temp.stack > 0)
                                {
                                    invOb.AddItem(ref temp, false);
                                }

                                if (temp.stack == 0)
                                {
                                    Destroy(cache.gameObject);
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.Log("Set up the priority system in FirstPersonLooting!");
                    }
                }
            }
        }
    }
 public LootStartEvent(LootableObject lo, Fougerite.Player player, Useable use, uLink.NetworkPlayer nplayer)
 {
     _lo     = lo;
     _ue     = use;
     _player = player;
     _np     = nplayer;
     foreach (Collider collider in Physics.OverlapSphere(lo._inventory.transform.position, 1.2f))
     {
         if (collider.GetComponent <DeployableObject>() != null)
         {
             _entity   = new Entity(collider.GetComponent <DeployableObject>());
             _isobject = true;
             break;
         }
         if (collider.GetComponent <LootableObject>() != null)
         {
             _entity   = new Entity(collider.GetComponent <LootableObject>());
             _isobject = false;
             break;
         }
     }
 }
Exemple #14
0
    private void Start()
    {
        goldObject     = GameManager.Instance.GetItemFromDatabase(0) as Gold;
        droppedLootBag = ObjectPooler.Instance.GetLootBag();

        if (maxGoldDrop > 0)
        {
            goldAmount = Random.Range(minGoldDrop, maxGoldDrop + 1);
        }

        if (GetComponent <LootableObject>())
        {
            GenerateItemList();
            LootableObject lootableObject = GetComponent <LootableObject>();
            lootableObject.SetLootList(itemList);
            lootableObject.SetStackedItems(stackedItems);
            if (goldAmount > 0)
            {
                GetComponent <LootableObject>().SetGoldAmount(goldAmount);
            }
        }
    }
 private void DrawLoot()
 {
     if (!CVars.ESP.DrawLoot)
     {
         return;
     }
     UnityEngine.Object[] lootableObjects = HackLocal.LootableObjects;
     for (int i = 0; i < lootableObjects.Length; i++)
     {
         UnityEngine.Object @object = lootableObjects[i];
         if (!(@object == null))
         {
             LootableObject lootableObject = (LootableObject)@object;
             if (lootableObject.name.Contains("BoxLoot") || lootableObject.name.Contains("LootBox") || lootableObject.name.Contains("SupplyCrate") || lootableObject.name.Contains("LootSack"))
             {
                 Color color = Color.white;
                 if (lootableObject.name.Contains("LootSack"))
                 {
                     color = Color.cyan;
                 }
                 else
                 {
                     if (lootableObject.name.Contains("SupplyCrate"))
                     {
                         color = Color.magenta;
                     }
                 }
                 Vector3 vector = Camera.main.WorldToScreenPoint(lootableObject.transform.position);
                 if (vector.z > 0f)
                 {
                     string arg = lootableObject.name.Replace("(Clone)", "");
                     vector.y = (float)Screen.height - (vector.y + 1f);
                     Canvas.DrawString(new Vector2(vector.x, vector.y), color, Canvas.TextFlags.TEXT_FLAG_DROPSHADOW, string.Format("{0} [{1}]", arg, (int)vector.z));
                 }
             }
         }
     }
 }
 void FindSack(Vector3 position)
 {
     cachedSack = null;
     foreach (Collider collider in Physics.OverlapSphere(position, 1f))
     {
         if (collider.gameObject.name == "LootSack(Clone)")
         {
             cachedSack = collider.GetComponent <LootableObject>();
         }
     }
     if (cachedSack == null)
     {
         return;
     }
     if (timeToRemove == 0)
     {
         DestroySack(cachedSack);
     }
     else
     {
         timer.Once(timeToRemove, () => DestroySack(cachedSack));
     }
 }
Exemple #17
0
        void PasteDeployables(List <object> deployablesData, Vector3 targetPoint, float targetRot, float heightAdjustment, NetUser player)
        {
            Vector3    OriginRotation = new Vector3(0f, targetRot, 0f);
            Quaternion OriginRot      = Quaternion.EulerRotation(OriginRotation);

            foreach (Dictionary <string, object> deployable in deployablesData)
            {
                Dictionary <string, object> structPos = deployable["pos"] as Dictionary <string, object>;
                Dictionary <string, object> structRot = deployable["rot"] as Dictionary <string, object>;
                string prefabname = (string)deployable["prefabname"];

                Quaternion       newAngles = Quaternion.EulerRotation((new Vector3(Convert.ToSingle(structRot["x"]), Convert.ToSingle(structRot["y"]), Convert.ToSingle(structRot["z"]))) + OriginRotation);
                Vector3          TempPos   = OriginRot * (new Vector3(Convert.ToSingle(structPos["x"]), Convert.ToSingle(structPos["y"]), Convert.ToSingle(structPos["z"])));
                Vector3          NewPos    = TempPos + targetPoint;
                DeployableObject block     = SpawnDeployable(prefabname, NewPos, newAngles);
                if (block != null)
                {
                    block.SetupCreator(player.playerClient.controllable);
                    block.GrabCarrier();
                    LootableObject lootobject = block.GetComponent <LootableObject>();
                    if (lootobject == null)
                    {
                        continue;
                    }
                    List <object> itemlist = deployable["items"] as List <object>;
                    if (itemlist == null || itemlist.Count == 0)
                    {
                        continue;
                    }
                    foreach (Dictionary <string, object> item in itemlist)
                    {
                        lootobject._inventory.AddItemAmount(displaynameToDataBlock[item["name"].ToString()], (displaynameToDataBlock[item["name"].ToString()])._splittable? Convert.ToInt32(item["amount"]) : 1);
                    }
                }
            }
        }
 public override void OnReset()
 {
     chest = null;
     open  = false;
 }
Exemple #19
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;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Checks if the object is a LootableObject
        /// </summary>
        /// <returns></returns>
        public bool IsLootableObject()
        {
            LootableObject str = this.Object as LootableObject;

            return(str != null);
        }
Exemple #21
0
 public override void OnReset()
 {
     chest = null;
 }
    void Update()
    {
        mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);

        if(Input.GetButtonDown("Fire1")){
            Physics.Raycast (mouseRay, out rayHit);
            if (rayHit.collider.transform.tag == "LootableObject")
            {
                lootObject = rayHit.collider.gameObject.GetComponent<LootableObject>();
                lootDictionary = lootObject.lootDictionary;				// set the individual item to display
                lootDictionaryAmount = lootObject.lootDictionaryAmount; // set the individual item amount to display
                showInventory = true;
            }
        }

        // close loot window
        if (Input.GetKey(KeyCode.Mouse1))
        {
            Debug.Log ("Close LootableObjec window");
            showInventory = false;
        }
    }
        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;
                        }
                    }
                }
            }
        }
 public override void OnReset()
 {
     items = null;
     chest = null;
 }
Exemple #25
0
 public virtual void SetLootable(LootableObject lootable, bool doInit)
 {
     this.myLootable = lootable;
     this.Initialize();
 }
Exemple #26
0
 public virtual void SetLootable(LootableObject lootable, bool doInit)
 {
     this.myLootable = lootable;
     this.Initialize();
 }
 public override void SetLootable(LootableObject lootable, bool doInit)
 {
     base.SetLootable(lootable, doInit);
     this._bench = lootable.GetComponent<RepairBench>();
 }
 public override void SetLootable(LootableObject lootable, bool doInit)
 {
     base.SetLootable(lootable, doInit);
     this._bench = lootable.GetComponent <RepairBench>();
 }
Exemple #29
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;
            }
        }
Exemple #30
0
        private void DrawLoot()
        {
            if (CVars.ESP.DrawLoot)
            {
                foreach (UnityEngine.Object obj2 in ESP_UpdateOBJs.LootableOBJs)
                {
                    if (obj2 == null)
                    {
                        continue;
                    }
                    LootableObject obj3   = (LootableObject)obj2;
                    Vector3        vector = Camera.main.WorldToScreenPoint(obj3.transform.position);
                    if (vector.z > 0f)
                    {
                        string str = "";
                        vector.y = Screen.height - (vector.y + 1f);
                        switch (obj3.name.Replace("(Clone)", ""))
                        {
                        case "WoodBoxLarge":
                            if (Lootlargebox)
                            {
                                str = string.Format("Large Box [{0}]", (int)vector.z);
                            }
                            break;

                        case "WoodBox":
                            if (Lootsmallbox)
                            {
                                str = string.Format("Small Box [{0}]", (int)vector.z);
                            }
                            break;

                        case "LootSack":
                            if (Lootplayerbag)
                            {
                                str = string.Format("Player Bag [{0}]", (int)vector.z);
                            }
                            break;

                        case "SmallStash":
                            if (Lootstash)
                            {
                                str = string.Format("Stash [{0}]", (int)vector.z);
                            }
                            break;

                        case "RepairBench":
                            if (Lootrepairbench)
                            {
                                str = string.Format("Repair Bench [{0}]", (int)vector.z);
                            }
                            break;

                        case "Furnace":
                            if (Lootfurnace)
                            {
                                str = string.Format("Furnace [{0}]", (int)vector.z);
                            }
                            break;

                        case "Campfire":
                            if (Lootcampfire)
                            {
                                str = string.Format("Campfire [{0}]", (int)vector.z);
                            }
                            break;

                        case "BoxLoot":
                            if (Lootboxloot)
                            {
                                str = string.Format("Box Loot [{0}]", (int)vector.z);
                            }
                            break;

                        case "AmmoLootBox":
                            if (Lootammoloot)
                            {
                                str = string.Format("Ammo Loot [{0}]", (int)vector.z);
                            }
                            break;

                        case "MedicalLootBox":
                            if (Lootmedicalloot)
                            {
                                str = string.Format("Medical Loot [{0}]", (int)vector.z);
                            }
                            break;

                        case "WeaponLootBox":
                            if (Lootweaponloot)
                            {
                                str = string.Format("Weapon Loot [{0}]", (int)vector.z);
                            }
                            break;

                        case "SupplyCrate":
                            if (Lootsupplycrate)
                            {
                                Canvas.DrawString(new Vector2(vector.x, vector.y), Color.magenta, Canvas.TextFlags.TEXT_FLAG_DROPSHADOW, string.Format("Supply Crate [{0}]", (int)vector.z));
                            }
                            break;
                        }
                        if (str != "")
                        {
                            Canvas.DrawString(new Vector2(vector.x, vector.y), Color.cyan, Canvas.TextFlags.TEXT_FLAG_DROPSHADOW, string.Format("{0}", str));
                        }
                    }
                }
            }
        }