public static void ResourceSpawned(ResourceTarget target) { if (OnResourceSpawned != null) { OnResourceSpawned(target); } }
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; }
public static void Resource_TryInitialize(ResourceTarget hook) { object[] args = new object[] { hook }; Method.Invoke("RustExtended.RustHook.Resource_TryInitialize", args); }
public GatherEvent(ResourceTarget r, ItemDataBlock db, int qty) { this.res = r; this._qty = qty; this._item = db.name; this._type = "Tree"; this.Override = false; }
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); }
/// <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); }
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; }
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; }
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; }
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; }
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; }
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(); }
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()); }
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; }
/// <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); } }
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); }
public ConfigResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
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]"); } } } }
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; }
private void NGC_OnInstantiate(NGCView view) { this.myID = NetEntityID.Get((UnityEngine.MonoBehaviour) this); this._resTarg = base.GetComponent <ResourceTarget>(); }
public LuaScriptResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
public BezierCurveResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
/// <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]); }
private void OnResourceNodeLoaded(ResourceTarget resource) { HookCalled("OnResourceNodeLoaded"); // Print resource if (ResourceCounter <= 10) { Puts(resource.name + " loaded at " + resource.transform.position.ToString()); ResourceCounter++; } }
private void NGC_OnInstantiate(NGCView view) { this.myID = NetEntityID.Get(this); this._resTarg = base.GetComponent<ResourceTarget>(); }
private void NGC_OnInstantiate(NGCView view) { this.myID = NetEntityID.Get(this); this._resTarg = base.GetComponent <ResourceTarget>(); }
public MeshesResourceBin(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }
protected Resource(string path, ResourceTarget target, VFS.IFileSystem fs) { Target = target; RC = Load(path, fs); }
public void OnResourceSpawned(ResourceTarget t) { Invoke("On_ResourceSpawn", t); }
private void ResourceSpawn(ResourceTarget resource) { // Calls the resource hook at Gather.cs RustEssentials.Plugins.Gather.ResourceNode(resource); }
/// <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); }
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); } }
public float ResourceEfficiencyForType(ResourceTarget.ResourceTargetType type) { return 0f; }
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); } }
public void OnResourceSpawned(ResourceTarget t) { this.Invoke("On_ResourceSpawn", new object[] { t }); }
public TexturePngResource(string path, ResourceTarget target, VFS.IFileSystem fs) : base(path, target, fs) { }