public static void TryInitialize() { if (!DatablockDictionary.initializedAtLeastOnce) { DatablockDictionary.Initialize(); } }
void cmdInvisible(NetUser netUser, string command, string[] args) { ulong netUserID = netUser.userID; if (!(netUser.CanAdmin() || permission.UserHasPermission(netUserID.ToString(), permissionCanSpawnInvisibleSuit))) { rust.Notice(netUser, lang.GetMessage("NoPermission", this), lang.GetMessage("FailureIcon", this)); return; } ItemDataBlock helmet = DatablockDictionary.GetByName("Invisible Helmet"); ItemDataBlock vest = DatablockDictionary.GetByName("Invisible Vest"); ItemDataBlock pants = DatablockDictionary.GetByName("Invisible Pants"); ItemDataBlock boots = DatablockDictionary.GetByName("Invisible Boots"); Inventory inventory = netUser.playerClient.rootControllable.idMain.GetComponent <Inventory>(); inventory.AddItemAmount(helmet, 1); inventory.AddItemAmount(vest, 1); inventory.AddItemAmount(pants, 1); inventory.AddItemAmount(boots, 1); rust.Notice(netUser, lang.GetMessage("SuccessInvisibleNotice", this), lang.GetMessage("SuccessIcon", this)); Puts($"{netUser.displayName} {lang.GetMessage("SuccessInvisibleBroadcast", this)}"); return; }
private void Confirm() { Datablock refValue; switch ((this.type_f & 0x7f)) { case 1: refValue = (Datablock)this.refValue; break; case 2: refValue = ((InventoryItem)this.refValue).datablock; break; case 3: refValue = DatablockDictionary.GetByName((string)this.refValue); break; case 4: refValue = DatablockDictionary.GetByUniqueID(this.uid); break; default: this = new Datablock.Ident(); return; } if (refValue != null) { this = new Datablock.Ident(refValue, refValue.uniqueID, 1); } else { this = new Datablock.Ident(); } }
private void Start() { SteamClient.Create(); ConsoleSystem.Run("config.load", false); ConsoleSystem.Run("serverfavourite.load", false); HudEnabled.Disable(); DatablockDictionary.Initialize(); Application.LoadLevelAdditive("GameUI"); FeedbackLog.Start(FeedbackLog.TYPE.HardwareInfo); FeedbackLog.Writer.Write(SystemInfo.deviceModel); FeedbackLog.Writer.Write(SystemInfo.deviceName); FeedbackLog.Writer.Write(SystemInfo.graphicsDeviceName); FeedbackLog.Writer.Write(SystemInfo.graphicsDeviceVendor); FeedbackLog.Writer.Write(SystemInfo.graphicsDeviceVersion); FeedbackLog.Writer.Write(SystemInfo.graphicsMemorySize); FeedbackLog.Writer.Write(SystemInfo.graphicsShaderLevel); FeedbackLog.Writer.Write(SystemInfo.operatingSystem); FeedbackLog.Writer.Write(SystemInfo.processorCount); FeedbackLog.Writer.Write(SystemInfo.processorType); FeedbackLog.Writer.Write(SystemInfo.supportedRenderTargetCount); FeedbackLog.Writer.Write(SystemInfo.supportsComputeShaders); FeedbackLog.Writer.Write(SystemInfo.supportsImageEffects); FeedbackLog.Writer.Write(SystemInfo.supportsInstancing); FeedbackLog.Writer.Write(SystemInfo.supportsRenderTextures); FeedbackLog.Writer.Write(SystemInfo.supportsRenderToCubemap); FeedbackLog.Writer.Write(SystemInfo.supportsShadows); FeedbackLog.Writer.Write(SystemInfo.supportsStencil); FeedbackLog.Writer.Write(SystemInfo.systemMemorySize); FeedbackLog.End(FeedbackLog.TYPE.HardwareInfo); Connection.GameLoaded(); }
public void LoadConfig() { if (!File.Exists(Path.Combine(ModuleFolder, "Config.ini"))) { File.Create(Path.Combine(ModuleFolder, "Config.ini")).Dispose(); config = new IniParser(Path.Combine(ModuleFolder, "Config.ini")); config.Save(); foreach (ItemDataBlock item in Bundling.LoadAll <ItemDataBlock>()) { if (itemList.ItemList.Contains(item.name)) { config.AddSetting("Config", item.name + ":" + item.uniqueID.ToString(), item._maxUses.ToString()); } } config.Save(); } config = new IniParser(Path.Combine(ModuleFolder, "Config.ini")); foreach (string itemid in config.EnumSection("Config")) { int id = int.Parse(itemid.Split(':')[1]); int amount = int.Parse(config.GetSetting("Config", itemid)); _stackSizes.Add(id, amount); DatablockDictionary.GetByUniqueID(id)._maxUses = amount; } }
void givecmd(NetUser netuser, string command, string[] args) { NetUser target = null; string item = String.Empty; int amount = 1; if (hasAcces(netuser)) { if (args == null || args.Length != 3) { rust.SendChatMessage(netuser, "Usage /give player item amount"); return; } target = rust.FindPlayer(args[0]); item = args[1]; data = DatablockDictionary.GetByName(item); amount = Convert.ToInt32(args[2]); if (netuser == target) { rust.SendChatMessage(netuser, "Use /i item amount to give to yourself"); return; } if (data == null) { rust.SendChatMessage(netuser, "Item doesnt exists"); return; } if (target == null) { rust.SendChatMessage(netuser, "Couldn't find the target user " + args[0]); return; } GiveItem(netuser, target, data, amount); } }
private static BlueprintDataBlock FindBlueprint(int uniqueID) { if (uniqueID == 0) { return(null); } return((BlueprintDataBlock)DatablockDictionary.GetByUniqueID(uniqueID)); }
void GiveItem(NetUser netUser, string item, int quantidade) { ItemDataBlock Item = DatablockDictionary.GetByName(item); Inventory inventario = netUser.playerClient.rootControllable.idMain.GetComponent <Inventory>(); inventario.AddItemAmount(Item, quantidade); return; }
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)); } }
public TurretBlueprintDataBlock() { name = "Turret Blueprint"; icon = "content/item/tex/BlueprintIcon"; _maxUses = 1; _spawnUsesMin = 1; _spawnUsesMax = 1; _minUsesForDisplay = 1; _maxCondition = 100; _splittable = false; isResearchable = false; isRepairable = false; isRecycleable = true; doesLoseCondition = false; category = ItemCategory.Blueprint; Combinations = new CombineRecipe[0]; transientMode = 0; resultItem = DatablockDictionary.GetByName("Turret"); numResultItem = 1; ingredients = new[] { new IngredientEntry { Ingredient = DatablockDictionary.GetByName("556 Ammo"), amount = 500 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Iron Shards"), amount = 500 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Batteries"), amount = 8 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Electronic Junk"), amount = 10 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Copper"), amount = 8 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Diamonds"), amount = 50 } }; craftingDuration = 8; RequireWorkbench = true; var type = GetType().BaseType.BaseType.BaseType.BaseType; var uniqueIDField = type.GetField("_uniqueID", BindingFlags.NonPublic | BindingFlags.Instance); uniqueIDField.SetValue(this, 134481426); }
public static ArmorModel GetArmorModelByUniqueID(int uniqueID, ArmorModelSlot slot) { ArmorDataBlock byUniqueID = DatablockDictionary.GetByUniqueID(uniqueID) as ArmorDataBlock; if (!byUniqueID) { return(null); } return(byUniqueID.GetArmorModel(slot)); }
private void Start() { SteamClient.Create(); ConsoleSystem.Run("config.load", false); ConsoleSystem.Run("serverfavourite.load", false); HudEnabled.Disable(); DatablockDictionary.Initialize(); Application.LoadLevelAdditive("GameUI"); Connection.GameLoaded(); }
public ItemDataBlock ConvertNameToData(string name) { ItemDataBlock byName = DatablockDictionary.GetByName(name); if (byName != null) { return(byName); } return(null); }
/// <summary> /// Adds an item to the specified slot with the given amount. /// </summary> /// <param name="name"></param> /// <param name="slot"></param> /// <param name="amount"></param> public void AddItemTo(string name, int slot, int amount) { ItemDataBlock byName = DatablockDictionary.GetByName(name); if (byName != null) { Inventory.Slot.Kind place = Inventory.Slot.Kind.Default; this._inv.AddItemSomehow(byName, new Inventory.Slot.Kind?(place), slot, amount); } }
public static TArmorModel GetArmorModelByUniqueID <TArmorModel>(int uniqueID) where TArmorModel : ArmorModel, new() { ArmorDataBlock byUniqueID = DatablockDictionary.GetByUniqueID(uniqueID) as ArmorDataBlock; if (!byUniqueID) { return((TArmorModel)null); } return(byUniqueID.GetArmorModel <TArmorModel>()); }
protected void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info) { this._parentViewID = info.networkView.initialData.ReadNetworkViewID(); int num = info.networkView.initialData.ReadInt32(); this._datablock = (HeldItemDataBlock)DatablockDictionary.GetByUniqueID(num); if (!this.CheckParent()) { Debug.Log("No parent for item rep (yet)", this); } }
public void Start() { byte[] dollarb = System.IO.File.ReadAllBytes(RGuard.RGuard.instance.datadir + "Images\\DollarSign.png"); dollar = new Texture2D(64, 64, TextureFormat.RGB24, false); dollar.LoadImage(dollarb); ItemDataBlock paper = DatablockDictionary.GetByName("Paper"); paper.iconTex = dollar; }
public int NewAddItem(string name, int amount) { ItemDataBlock byName = DatablockDictionary.GetByName(name); if (byName != null) { //AddItemAmount return(this._inv.AddItemAmount(byName, amount)); } return(-1); }
void GivePrize(NetUser netuser, string item, int amount) { ItemDataBlock Item = DatablockDictionary.GetByName(item); if (Item == null) { return; } Inventory inventario = netuser.playerClient.rootControllable.idMain.GetComponent <Inventory>(); inventario.AddItemAmount(Item, amount); }
public void PlayerUse(Controllable controllable) { if (base.BelongsTo(controllable)) { if (!this.IsValidToSpawn()) { return; } if (controllable.GetComponent <Inventory>().AddItemAmount(DatablockDictionary.GetByName(this.giveItemName), 1) == 1) { return; } } }
void PatchNewSpawnlists() { int cnt = 0; var spawnlistobjects = new Dictionary <string, LootSpawnList>(); foreach (KeyValuePair <string, object> pair in SpawnLists) { var currentspawnlist = pair.Value as Dictionary <string, object>; var obj = UnityEngine.ScriptableObject.CreateInstance <LootSpawnList>(); obj.minPackagesToSpawn = Convert.ToInt32(currentspawnlist["min"]); obj.maxPackagesToSpawn = Convert.ToInt32(currentspawnlist["max"]); obj.noDuplicates = Convert.ToBoolean(currentspawnlist["nodupes"]); obj.spawnOneOfEach = Convert.ToBoolean(currentspawnlist["oneofeach"]); obj.name = pair.Key; spawnlistobjects.Add(pair.Key, obj); cnt++; } foreach (KeyValuePair <string, object> pair in SpawnLists) { var entrylist = new List <LootSpawnList.LootWeightedEntry>(); var currentspawnlist = pair.Value as Dictionary <string, object>; var packages = currentspawnlist["packages"] as List <object>; foreach (Dictionary <string, object> entry in packages) { var entryobj = new LootSpawnList.LootWeightedEntry(); entryobj.amountMin = Convert.ToInt32(entry["min"]); entryobj.amountMax = Convert.ToInt32(entry["max"]); entryobj.weight = Convert.ToSingle(entry["weight"]); if (spawnlistobjects.ContainsKey(entry["object"].ToString())) { entryobj.obj = spawnlistobjects[entry["object"].ToString()]; } else { entryobj.obj = DatablockDictionary.GetByName(entry["object"].ToString()); } entrylist.Add(entryobj); } spawnlistobjects[pair.Key].LootPackages = entrylist.ToArray(); } var spawnlists = DatablockDictionary._lootSpawnLists; spawnlists.Clear(); foreach (KeyValuePair <string, object> pair in SpawnLists) { spawnlists.Add(pair.Key, spawnlistobjects[pair.Key]); } Puts(string.Format("{0} custom loot tables were loaded!", cnt.ToString())); }
public LootboxBlueprintDataBlock() { name = "Lootbox Blueprint"; icon = "content/item/tex/BlueprintIcon"; _maxUses = 1; _spawnUsesMin = 1; _spawnUsesMax = 1; _minUsesForDisplay = 1; _maxCondition = 100; _splittable = false; isResearchable = false; isRepairable = false; isRecycleable = true; doesLoseCondition = false; category = ItemCategory.Blueprint; Combinations = new CombineRecipe[0]; transientMode = 0; resultItem = DatablockDictionary.GetByName("Lootbox"); numResultItem = 1; ingredients = new[] { new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Low Quality Metal"), amount = 20 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Leather"), amount = 80 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Metal Fragments"), amount = 80 }, new IngredientEntry { Ingredient = DatablockDictionary.GetByName("Gunpowder"), amount = 70 } }; craftingDuration = 8; RequireWorkbench = true; var type = GetType().BaseType.BaseType.BaseType.BaseType; var uniqueIDField = type.GetField("_uniqueID", BindingFlags.NonPublic | BindingFlags.Instance); uniqueIDField.SetValue(this, 134481383); }
private static void OnResourcesLoaded() { BaseTraitMap[] baseTraitMapArray = Bundling.LoadAll <BaseTraitMap>(); for (int i = 0; i < (int)baseTraitMapArray.Length; i++) { BaseTraitMap baseTraitMap = baseTraitMapArray[i]; if (baseTraitMap) { try { Binder.BindMap(baseTraitMap); } catch (Exception exception) { UnityEngine.Debug.LogError(exception, baseTraitMap); } } } DatablockDictionary.Initialize(); NetMainPrefab[] netMainPrefabArray = Bundling.LoadAll <NetMainPrefab>(); for (int j = 0; j < (int)netMainPrefabArray.Length; j++) { NetMainPrefab netMainPrefab = netMainPrefabArray[j]; try { netMainPrefab.Register(true); } catch (Exception exception1) { UnityEngine.Debug.LogException(exception1, netMainPrefab); } } uLinkNetworkView[] uLinkNetworkViewArray = Bundling.LoadAll <uLinkNetworkView>(); for (int k = 0; k < (int)uLinkNetworkViewArray.Length; k++) { uLinkNetworkView _uLinkNetworkView = uLinkNetworkViewArray[k]; try { NetCull.RegisterNetAutoPrefab(_uLinkNetworkView); } catch (Exception exception2) { UnityEngine.Debug.LogException(exception2, _uLinkNetworkView); } } NGC.Register(NGCConfiguration.Load()); }
public void ReceiveBoundBPs(byte[] data, uLink.NetworkMessageInfo info) { this._boundBPs = this._boundBPs ?? new List <BlueprintDataBlock>(); this._boundBPs.Clear(); uLink.BitStream bitStream = new uLink.BitStream(data, false); int num = bitStream.ReadInt32(); for (int i = 0; i < num; i++) { ItemDataBlock byUniqueID = DatablockDictionary.GetByUniqueID(bitStream.ReadInt32()); if (byUniqueID) { this._boundBPs.Add(byUniqueID as BlueprintDataBlock); } } this.Refresh(); }
protected void Mods(byte[] data) { this.ClearMods(); uLink.BitStream stream = new uLink.BitStream(data, false); byte num = stream.ReadByte(); if (num > 0) { CharacterStateFlags characterStateFlags = this.GetCharacterStateFlags(); for (int i = 0; i < num; i++) { ItemModDataBlock byUniqueID = (ItemModDataBlock)DatablockDictionary.GetByUniqueID(stream.ReadInt32()); this._itemMods.InstallMod(i, this, byUniqueID, characterStateFlags); this._modFlags |= byUniqueID.modFlag; } } }
public void CheckWalloot(InventoryModEvent e) { User looter = e.Player; if (looter == null) { return; } if (IsWallooting(e.Player, e.Inventory)) { ItemDataBlock block = DatablockDictionary.GetByName(e.ItemName); e.Inventory.AddItemAmount(block, 1); Notify(looter, e.Inventory); Server.GetServer().BroadcastFrom(Core.Name, "[color yellow]☢ [color red]Player: [color yellow]" + looter.Name + "[color red] has been kicked for wall looting."); looter.Disconnect(); } }
public bool addWeaponMod(string name) { if (this.isWeapon) { ItemModDataBlock weaponmod = DatablockDictionary.GetByName(name) as ItemModDataBlock; if (weaponmod == null) { return(false); } this.heldItem.AddMod(weaponmod); return(true); } else { return(false); } }
private void Confirm() { Datablock byName; switch (this.type_f & 127) { case 1: { byName = (Datablock)this.refValue; break; } case 2: { byName = ((InventoryItem)this.refValue).datablock; break; } case 3: { byName = DatablockDictionary.GetByName((string)this.refValue); break; } case 4: { byName = DatablockDictionary.GetByUniqueID(this.uid); break; } default: { this = new Datablock.Ident(); return; } } if (!byName) { this = new Datablock.Ident(); } else { this = new Datablock.Ident(byName, byName.uniqueID, 1); } }
/// <summary> /// Adds an item to the specified slot with the given amount. /// </summary> /// <param name="name"></param> /// <param name="slot"></param> /// <param name="amount"></param> public void AddItemTo(string name, int slot, int amount) { ItemDataBlock byName = DatablockDictionary.GetByName(name); if (byName != null) { Inventory.Slot.Kind belt = Inventory.Slot.Kind.Default; if ((slot > 0x1d) && (slot < 0x24)) { belt = Inventory.Slot.Kind.Belt; } else if ((slot >= 0x24) && (slot < 40)) { belt = Inventory.Slot.Kind.Armor; } this._inv.AddItemSomehow(byName, new Inventory.Slot.Kind?(belt), slot, amount); } }
public void AddItemTo(string name, int slot, int amount) { ItemDataBlock byName = DatablockDictionary.GetByName(name); if (byName != null) { Inventory.Slot.Kind value = Inventory.Slot.Kind.Default; if (slot > 29 && slot < 36) { value = Inventory.Slot.Kind.Belt; } else if (slot >= 36 && slot < 40) { value = Inventory.Slot.Kind.Armor; } this._inv.AddItemSomehow(byName, new Inventory.Slot.Kind?(value), slot, amount); } }