예제 #1
0
 public static void OnLoadExtendedItemData(ExtendedItemData itemdata)
 {
     if (UniqueItemTypes.Contains(itemdata.m_shared.m_itemType) && !itemdata.IsUnique())
     {
         var uniqueItemData = itemdata.AddComponent <UniqueItemData>();
         uniqueItemData.CreateNewGuid();
     }
 }
예제 #2
0
        private void Awake()
        {
            _instance       = this;
            _enabledConfig  = Config.Bind("General", "Enabled", true, "Turn off to disable this mod. When uninstalling, load and quit a game once with this option set to false.");
            _loggingEnabled = Config.Bind("General", "Logging Enabled", false, "Enables log output from the mod.");
            DisplayUniqueItemIDInTooltip = Config.Bind("General", "Display UniqueItemID in Tooltip", false, "Displays the item's unique id in magenta text at the bottom of the tooltip.");

            ExtendedItemData.RegisterCustomTypeID(CrafterNameData.TypeID, typeof(CrafterNameData));
            ExtendedItemData.RegisterCustomTypeID(UniqueItemData.TypeID, typeof(UniqueItemData));

            ExtendedItemData.NewExtendedItemData  += UniqueItemData.OnNewExtendedItemData;
            ExtendedItemData.LoadExtendedItemData += UniqueItemData.OnLoadExtendedItemData;

            _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), PluginId);
        }
예제 #3
0
        public static bool Prefix(Inventory __instance, ref bool __result, string name, int stack, float durability, Vector2i pos, bool equiped, int quality, int variant, long crafterID, string crafterName)
        {
            __result = false;
            GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(name);

            if (itemPrefab == null)
            {
                ZLog.Log("Failed to find item prefab " + name);
                return(false);
            }
            ZNetView.m_forceDisableInit = true;
            GameObject gameObject = Object.Instantiate(itemPrefab);

            ZNetView.m_forceDisableInit = false;
            ItemDrop component = gameObject.GetComponent <ItemDrop>();

            if (component == null)
            {
                ZLog.Log("Missing itemdrop in " + name);
                Object.Destroy(gameObject);
                return(false);
            }
            var newItemData = new ExtendedItemData(
                component.m_itemData,
                stack,
                durability,
                pos,
                equiped,
                quality,
                variant,
                crafterID,
                crafterName);

            __instance.AddItem(newItemData, newItemData.m_stack, pos.x, pos.y);
            Object.Destroy(gameObject);
            __result = true;
            return(false);
        }
예제 #4
0
        public ExtendedItemData ExtendedClone()
        {
            var result = new ExtendedItemData();

            result.m_stack          = m_stack;
            result.m_durability     = m_durability;
            result.m_quality        = m_quality;
            result.m_variant        = m_variant;
            result.m_shared         = m_shared;
            result.m_crafterID      = m_crafterID;
            result.m_crafterName    = m_crafterName;
            result.m_gridPos        = m_gridPos;
            result.m_equiped        = m_equiped;
            result.m_dropPrefab     = m_dropPrefab;
            result.m_lastAttackTime = m_lastAttackTime;
            result.m_lastProjectile = m_lastProjectile;

            foreach (var component in Components)
            {
                result.Components.Add(component.Clone());
            }

            return(result);
        }
예제 #5
0
 protected BaseExtendedItemComponent(string typeName, ExtendedItemData parent)
 {
     TypeName = typeName;
     ItemData = parent;
 }
예제 #6
0
 public UniqueItemData(ExtendedItemData parent)
     : base(typeof(UniqueItemData).AssemblyQualifiedName, parent)
 {
 }
예제 #7
0
 public UniqueItemData(ExtendedItemData parent)
     : base(TypeID, parent)
 {
 }