Example #1
0
 public static void ResourceSpawned(ResourceTarget target)
 {
     if (OnResourceSpawned != null)
     {
         OnResourceSpawned(target);
     }
 }
Example #2
0
 public GatherEvent(ResourceTarget r, ResourceGivePair gp, int qty)
 {
     this.res      = r;
     this._qty     = qty;
     this._item    = gp.ResourceItemDataBlock.name;
     this._type    = this.res.type.ToString();
     this.Override = false;
 }
Example #3
0
 public static void Resource_TryInitialize(ResourceTarget hook)
 {
     object[] args = new object[]
     {
         hook
     };
     Method.Invoke("RustExtended.RustHook.Resource_TryInitialize", args);
 }
Example #4
0
 public GatherEvent(ResourceTarget r, ItemDataBlock db, int qty)
 {
     this.res      = r;
     this._qty     = qty;
     this._item    = db.name;
     this._type    = "Tree";
     this.Override = false;
 }
Example #5
0
 public static bool Resource_DoGather(ResourceTarget obj, Inventory reciever, float efficiency)
 {
     object[] args = new object[]
     {
         obj,
         reciever,
         efficiency
     };
     return(Method.Invoke("RustExtended.RustHook.Resource_DoGather", args).AsBoolean);
 }
Example #6
0
        /// <summary>
        /// Creates resource instance.
        /// </summary>
        private Resource CreateResourceInstance(string path, ResourceTarget target)
        {
            Func <string, string> normalizePath = s =>
                                                  s.Replace("\\", "/");

            Func <string, string> getExtension = s =>
                                                 s.Substring(s.LastIndexOf(".", StringComparison.Ordinal) + 1)
                                                 .ToLower();

            Func <string, string> getFileName = s =>
            {
                var temp     = s.Substring(s.LastIndexOf("/", StringComparison.Ordinal) + 1);
                var filename = temp.Substring(0, temp.LastIndexOf(".", StringComparison.Ordinal));
                return(filename);
            };

            string extension;

            try
            {
                path = normalizePath(path);
                string   searchingDir = path.Substring(0, path.LastIndexOf("/", StringComparison.Ordinal));             // where to search file
                string   filename     = path.Substring(path.LastIndexOf("/", StringComparison.Ordinal) + 1);            // filename without file extension
                string[] directory    = FS.GetDirectory(searchingDir);                                                  // full directory files with extensions
                extension = directory
                            .Select(normalizePath)
                            .Where(s => getFileName(s) == filename)
                            .Select(getExtension)
                            .FirstOrDefault(s => _resourceConstructors.Keys.Contains(s))
                            ?.ToLower();

                if (extension == null)
                {
                    throw new ArgumentException("These no files with name " + filename);
                }
            }
            catch (Exception e)
            {
                throw new ArgumentException("Can't find directory item by path: " + path, e);
            }
            var resConstructor = _resourceConstructors.GetOrNull(extension);

            Resource result;

            try
            {
                result = resConstructor(path, target, FS);
            }
            catch (Exception e)
            {
                throw new ArgumentException("Can't construct resource item by path: " + path, e);
            }
            return(result);
        }
Example #7
0
        public GatherEvent(ResourceTarget r, ItemDataBlock db, int qty)
        {
            // r can be null here.
            Contract.Requires(db != null);
            Contract.Requires(qty >= 0);

            if (db.name == null)
                throw new InvalidOperationException("ItemDataBlock's name is null.");

            this.res = r;
            this._qty = qty;
            this._item = db.name;
            this._type = "Tree";
            this.Override = false;
        }
Example #8
0
        public static void PlayerGatherWood(IMeleeWeaponItem rec, ResourceTarget rt, ref ItemDataBlock db, ref int amount, ref string name)
        {
            Magma.Player player = Magma.Player.FindByNetworkPlayer(rec.inventory.networkView.owner);
            GatherEvent  ge     = new GatherEvent(rt, db, amount)
            {
                Item = "Wood"
            };

            if (OnPlayerGathering != null)
            {
                OnPlayerGathering(player, ge);
            }
            db     = Magma.Server.GetServer().Items.Find(ge.Item);
            amount = ge.Quantity;
            name   = ge.Item;
        }
Example #9
0
        public GatherEvent(ResourceTarget r, ResourceGivePair gp, int qty)
        {
            Contract.Requires(r != null);
            Contract.Requires(gp != null);
            Contract.Requires(qty >= 0);

            if (gp.ResourceItemDataBlock == null)
                throw new InvalidOperationException("ResourceGivePair's ResourceItemDataBlock property is null.");
            if (gp.ResourceItemDataBlock.name == null)
                throw new InvalidOperationException("ResourceItemDataBlock's name is null.");

            this.res = r;
            this._qty = qty;
            this._item = gp.ResourceItemDataBlock.name;
            this._type = this.res.type.ToString();
            this.Override = false;
        }
Example #10
0
        public GatherEvent(ResourceTarget r, ItemDataBlock db, int qty)
        {
            // r can be null here.
            Contract.Requires(db != null);
            Contract.Requires(qty >= 0);

            if (db.name == null)
            {
                throw new InvalidOperationException("ItemDataBlock's name is null.");
            }

            this.res      = r;
            this._qty     = qty;
            this._item    = db.name;
            this._type    = "Tree";
            this.Override = false;
        }
Example #11
0
        public static void PlayerGather(Inventory rec, ResourceTarget rt, ResourceGivePair rg, ref int amount)
        {
            Magma.Player player = Magma.Player.FindByNetworkPlayer(rec.networkView.owner);
            GatherEvent  ge     = new GatherEvent(rt, rg, amount);

            if (OnPlayerGathering != null)
            {
                OnPlayerGathering(player, ge);
            }
            amount = ge.Quantity;
            if (!ge.Override)
            {
                amount = Mathf.Min(amount, rg.AmountLeft());
            }
            rg._resourceItemDatablock = ge.Item;
            rg.ResourceItemName       = ge.Item;
        }
Example #12
0
 public static void PlayerGatherWood(IMeleeWeaponItem rec, ResourceTarget rt, ref ItemDataBlock db, ref int amount, ref string name)
 {
     try
     {
         Fougerite.Player player = Fougerite.Player.FindByNetworkPlayer(rec.inventory.networkView.owner);
         //Fougerite.Player player = Fougerite.Server.Cache[rec.inventory.networkView.owner.id];
         GatherEvent ge = new GatherEvent(rt, db, amount);
         ge.Item = "Wood";
         if (OnPlayerGathering != null)
         {
             OnPlayerGathering(player, ge);
         }
         db     = Fougerite.Server.GetServer().Items.Find(ge.Item);
         amount = ge.Quantity;
         name   = ge.Item;
     }
     catch { }
 }
        public void OnGUI()
        {
            GUILayout.BeginHorizontal();
            audioConfig.forceToMono = GUILayout.Toggle(audioConfig.forceToMono, "Force To Mono");
            bForceToMono            = GUILayout.Toggle(bForceToMono, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            audioConfig.loadInBackground = GUILayout.Toggle(audioConfig.loadInBackground, "Load In Background");
            bLoadInBackground            = GUILayout.Toggle(bLoadInBackground, "");
            GUILayout.EndHorizontal();

            target = (ResourceTarget)EditorGUILayout.EnumPopup("Target Platform", target);

            GUILayout.BeginHorizontal();
            audioConfig.defaultAudioSettings.compressionFormat = (AudioCompressionFormat)EditorGUILayout.EnumPopup("Compression Format", audioConfig.defaultAudioSettings.compressionFormat);
            bAudioCompressionFormat = GUILayout.Toggle(bAudioCompressionFormat, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Quality:");
            quality = EditorGUILayout.IntSlider(quality, 1, 100);
            audioConfig.defaultAudioSettings.quality = quality / 100.0f;
            bQuality = GUILayout.Toggle(bQuality, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            audioConfig.defaultAudioSettings.loadType = (AudioClipLoadType)EditorGUILayout.EnumPopup("LoadType", audioConfig.defaultAudioSettings.loadType);
            bAudioLoadType = GUILayout.Toggle(bAudioLoadType, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            audioConfig.defaultAudioSettings.sampleRateSetting = (AudioSampleRateSetting)EditorGUILayout.EnumPopup("Sample Rate Setting", audioConfig.defaultAudioSettings.sampleRateSetting);
            bAudioSampleRateSetting = GUILayout.Toggle(bAudioSampleRateSetting, "");
            GUILayout.EndHorizontal();

            if (GUILayout.Button("SetAudioBatch"))
            {
                SetAudioClipBatch();
            }
            ShowList();
        }
Example #14
0
        void OnResourceNodeLoaded(ResourceTarget resource)
        {
            cachedGather    = 1;
            cachedAmount    = 1;
            cachedMinAmount = 1;
            switch (resource.type)
            {
            case ResourceTarget.ResourceTargetType.Animal:
                cachedGather = GatheranimalMultiplier;
                break;

            case ResourceTarget.ResourceTargetType.Rock2:
                cachedGather = GathermetalOreMultiplier;
                break;

            case ResourceTarget.ResourceTargetType.Rock3:
                cachedGather = GatherstonesMultiplier;
                break;

            case ResourceTarget.ResourceTargetType.Rock1:
                cachedGather = GathersulfurOreMultiplier;
                break;

            case ResourceTarget.ResourceTargetType.WoodPile:
                cachedGather = GatherwoodpileMultiplier;
                break;

            default:
                break;
            }
            foreach (ResourceGivePair resourceavaible in resource.resourcesAvailable)
            {
                if (resourceMultiplier.ContainsKey(resourceavaible.ResourceItemName))
                {
                    resourceavaible.amountMin *= (int)resourceMultiplier[resourceavaible.ResourceItemName];
                    resourceavaible.amountMax *= (int)resourceMultiplier[resourceavaible.ResourceItemName];
                    resourceavaible.CalcAmount();
                }
            }
            resource.gatherEfficiencyMultiplier = cachedGather;
            startingtotal.SetValue(resource, resource.GetTotalResLeft());
        }
Example #15
0
        public GatherEvent(ResourceTarget r, ResourceGivePair gp, int qty)
        {
            Contract.Requires(r != null);
            Contract.Requires(gp != null);
            Contract.Requires(qty >= 0);

            if (gp.ResourceItemDataBlock == null)
            {
                throw new InvalidOperationException("ResourceGivePair's ResourceItemDataBlock property is null.");
            }
            if (gp.ResourceItemDataBlock.name == null)
            {
                throw new InvalidOperationException("ResourceItemDataBlock's name is null.");
            }

            this.res      = r;
            this._qty     = qty;
            this._item    = gp.ResourceItemDataBlock.name;
            this._type    = this.res.type.ToString();
            this.Override = false;
        }
Example #16
0
        /// <summary>
        /// Returns resource which is automatically loading from <paramref name="path"/>.
        /// File extention should be missed.
        /// </summary>
        /// <example>
        /// this["Meshes/Wpn/ak_47"]; // returns Mesh object from "mesh/Wpn/ak_47.obj"
        /// </example>
        public object this[string path, ResourceTarget target]
        {
            get
            {
                if (Resources.ContainsKey(path))
                {
                    return(Resources[path].RC);
                }

                Resource resource;
                try
                {
                    resource = CreateResourceInstance(path, target);
                }
                catch (Exception e)
                {
                    throw                   new ArgumentException($"Error during load resorce by path: \"{path}\".", e);
                }
                Resources.Add(path, resource);

                return(resource.RC);
            }
        }
Example #17
0
        public override string ToString()
        {
            string result = TypeDescription;

            if (Header.OpcodeType == OpcodeType.Sync)
            {
                result += SyncFlags.GetDescription();
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.SampleControls))
            {
                result += "_aoffimmi";
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.ResourceDim))
            {
                result += "_indexable";
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.SampleControls))
            {
                result += string.Format("({0},{1},{2})", SampleOffsets[0], SampleOffsets[1], SampleOffsets[2]);
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.ResourceDim))
            {
                result += string.Format("({0}", ResourceTarget.GetDescription());
                if (ResourceStride != 0)
                {
                    result += string.Format(", stride={0}", ResourceStride);
                }
                result += ")";
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.ResourceReturnType))
            {
                result += string.Format("({0},{1},{2},{3})",
                                        ResourceReturnTypes[0].GetDescription(),
                                        ResourceReturnTypes[1].GetDescription(),
                                        ResourceReturnTypes[2].GetDescription(),
                                        ResourceReturnTypes[3].GetDescription());
            }

            if (Header.OpcodeType == OpcodeType.Resinfo && ResInfoReturnType != ResInfoReturnType.Float)
            {
                result += string.Format("_{0}", ResInfoReturnType.GetDescription().ToLower());
            }

            if (Header.OpcodeType.IsConditionalInstruction())
            {
                result += "_" + TestBoolean.GetDescription();
            }

            if (Saturate)
            {
                result += "_sat";
            }
            result += " ";

            if (Header.OpcodeType == OpcodeType.InterfaceCall)
            {
                result += string.Format("fp{0}[{1}][{2}]",
                                        Operands[0].Indices[0].Value,
                                        Operands[0].Indices[1],
                                        FunctionIndex);
            }
            else
            {
                for (int i = 0; i < Operands.Count; i++)
                {
                    var operandString = Operands[i].ToString();
                    if (i > 0 && !string.IsNullOrEmpty(operandString))
                    {
                        result += ", ";
                    }
                    result += operandString;
                }
            }

            return(result);
        }
Example #18
0
 public ConfigResource(string path, ResourceTarget target, VFS.IFileSystem fs)
     : base(path, target, fs)
 {
 }
Example #19
0
        static void OnPlayerGathering(Fougerite.Player player, GatherEvent ge)
        {
            string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player);

            if (!UserIsLogged(player))
            {
                char ch = '☢';
                player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f);
                ge.Quantity = 0;
                return;
            }
            User           user     = Data.Globals.usersOnline.Find(x => x.Name == player.Name);
            ResourceTarget resource = ge.ResourceTarget;
            int            quantity = ge.Quantity;

            if (resource != null)
            {
                if (resource.type == ResourceTarget.ResourceTargetType.WoodPile)
                {
                    if (player.Inventory.FreeSlots > 0)
                    {
                        int clanCommision = 0;
                        if (user.ClanID != -1)
                        {
                            clanCommision   = (((quantity * user.LumberjackLevel - 1) / 2) * 10) / 100;
                            user.Clan.Mats += clanCommision;
                        }
                        quantity = ((quantity * user.LumberjackLevel - 1) / 2) - clanCommision;
                        player.Inventory.AddItem(ge.Item, quantity);
                        player.InventoryNotice($"{quantity} x {ge.Item}");

                        user.AddWoodExp(quantity);
                    }
                    else
                    {
                        player.SendClientMessage($"[color red]<!>[/color] No tienes espacio en el inventario para recibir [color orange]{ge.Item}[/color]");
                    }
                }
                else if (resource.type == ResourceTarget.ResourceTargetType.Rock1 || resource.type == ResourceTarget.ResourceTargetType.Rock2 || resource.type == ResourceTarget.ResourceTargetType.Rock3)
                {
                    if (player.Inventory.FreeSlots > 0)
                    {
                        int clanCommision = 0;

                        quantity = (quantity * user.MinerLevel - 1) / 2;
                        if (user.ClanID != -1)
                        {
                            clanCommision   = (quantity * 10) / 100;
                            user.Clan.Mats += clanCommision;
                        }
                        quantity -= clanCommision;
                        player.Inventory.AddItem(ge.Item, quantity);
                        player.InventoryNotice($"{quantity} x {ge.Item}");

                        if (ge.Item == "Metal Ore")
                        {
                            user.AddMetalExp(quantity);
                        }
                        else if (ge.Item == "Sulfur Ore")
                        {
                            user.AddSulfureExp(quantity);
                        }
                    }
                    else
                    {
                        player.SendClientMessage($"[color red]<!>[/color] No tienes espacio en el inventario para recibir [color orange]{ge.Item}[/color]");
                    }
                }
            }
        }
Example #20
0
 private object IOnTreeGather(IMeleeWeaponItem weapon, ResourceTarget resourceNode, int amount)
 {
     var value = Interface.CallHook("OnGather", weapon.inventory, resourceNode, null, amount);
     if (value is int)
         return value;
     return null;
 }
Example #21
0
 private void NGC_OnInstantiate(NGCView view)
 {
     this.myID     = NetEntityID.Get((UnityEngine.MonoBehaviour) this);
     this._resTarg = base.GetComponent <ResourceTarget>();
 }
Example #22
0
 public LuaScriptResource(string path, ResourceTarget target, VFS.IFileSystem fs)
     : base(path, target, fs)
 {
 }
Example #23
0
 public BezierCurveResource(string path, ResourceTarget target, VFS.IFileSystem fs)
     : base(path, target, fs)
 {
 }
Example #24
0
 /// <summary>
 /// Alias to the indexer method.
 /// Returns resource which is automatically loading from <paramref name="path"/>.
 /// File extention should be missed.
 /// </summary>
 /// <typeparam name="TData">The type of the data to return (just static cast).</typeparam>
 public TData Get <TData>(string path, ResourceTarget target)
 {
     return((TData)this[path, target]);
 }
Example #25
0
 private void OnResourceNodeLoaded(ResourceTarget resource)
 {
     HookCalled("OnResourceNodeLoaded");
     // Print resource
     if (ResourceCounter <= 10)
     {
         Puts(resource.name + " loaded at " + resource.transform.position.ToString());
         ResourceCounter++;
     }
 }
Example #26
0
 private void NGC_OnInstantiate(NGCView view)
 {
     this.myID = NetEntityID.Get(this);
     this._resTarg = base.GetComponent<ResourceTarget>();
 }
Example #27
0
 private void NGC_OnInstantiate(NGCView view)
 {
     this.myID     = NetEntityID.Get(this);
     this._resTarg = base.GetComponent <ResourceTarget>();
 }
Example #28
0
 public MeshesResourceBin(string path, ResourceTarget target, VFS.IFileSystem fs)
     : base(path, target, fs)
 {
 }
Example #29
0
 protected Resource(string path, ResourceTarget target, VFS.IFileSystem fs)
 {
     Target = target;
     RC     = Load(path, fs);
 }
Example #30
0
 public void OnResourceSpawned(ResourceTarget t)
 {
     Invoke("On_ResourceSpawn", t);
 }
Example #31
0
 private void ResourceSpawn(ResourceTarget resource)
 {
     // Calls the resource hook at Gather.cs
     RustEssentials.Plugins.Gather.ResourceNode(resource);
 }
Example #32
0
        /// <summary>
        /// Checks if the object is a ResourceTarget
        /// </summary>
        /// <returns>Returns true if it is.</returns>
        public bool IsResourceTarget()
        {
            ResourceTarget str = this.Object as ResourceTarget;

            return(str != null);
        }
Example #33
0
 public static void PlayerGather(Inventory rec, ResourceTarget rt, ResourceGivePair rg, ref int amount)
 {
     try
     {
         Fougerite.Player player = Fougerite.Player.FindByNetworkPlayer(rec.networkView.owner);
         GatherEvent ge = new GatherEvent(rt, rg, amount);
         if (OnPlayerGathering != null)
         {
             OnPlayerGathering(player, ge);
         }
         amount = ge.Quantity;
         if (!ge.Override)
         {
             amount = Mathf.Min(amount, rg.AmountLeft());
         }
         rg._resourceItemDatablock = ge.Item;
         rg.ResourceItemName = ge.Item;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Example #34
0
 public float ResourceEfficiencyForType(ResourceTarget.ResourceTargetType type)
 {
     return 0f;
 }
Example #35
0
 public static void PlayerGatherWood(IMeleeWeaponItem rec, ResourceTarget rt, ref ItemDataBlock db, ref int amount, ref string name)
 {
     try
     {
         Fougerite.Player player = Fougerite.Player.FindByNetworkPlayer(rec.inventory.networkView.owner);
         GatherEvent ge = new GatherEvent(rt, db, amount);
         ge.Item = "Wood";
         if (OnPlayerGathering != null)
         {
             OnPlayerGathering(player, ge);
         }
         db = Fougerite.Server.GetServer().Items.Find(ge.Item);
         amount = ge.Quantity;
         name = ge.Item;
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Example #36
0
 public void OnResourceSpawned(ResourceTarget t)
 {
     this.Invoke("On_ResourceSpawn", new object[] { t });
 }
Example #37
0
 public TexturePngResource(string path, ResourceTarget target, VFS.IFileSystem fs)
     : base(path, target, fs)
 {
 }