public bool IsUnfiltered(ItemDefinition d)
		{
			if(RemovedTypes == null)
				return true;

			return !RemovedTypes.Any(rt => rt.IsAssignableFrom(d.ItemType));
		}
Example #2
0
        public DraggableToolbar(ContentItem item, ItemDefinition definition)
        {
            if (definition == null) throw new ArgumentNullException("definition");

            this.currentItem = item;
            this.definition = definition;
        }
    public void ChangeTemplateThrowsIfNoDbItemFound([Greedy]FakeDataProvider sut, ItemDefinition def, TemplateChangeList changes)
    {
      Action action = () => sut.ChangeTemplate(def, changes, null);

      action.ShouldThrow<InvalidOperationException>()
            .WithMessage("Unable to change item template. The item '{0}' is not found.".FormatWith(def.ID));
    }
 public void Refine(ItemDefinition currentDefinition, IList<ItemDefinition> allDefinitions)
 {
     if (currentDefinition.ItemType.IsAssignableFrom(typeof (BlogContainer)))
     {
         currentDefinition.AllowedChildFilters.Add(this);
     }
 }
        protected virtual void AddChildIDsForContactFacetItem(IDList ids, ItemDefinition itemDefinition, CallContext context)
        {
            var facetName = IDTableHelper.GetFacetName(itemDefinition.ID);
            var contractType = ContactFacetHelper.GetContractTypeForFacet(facetName);
            
            foreach (string memberName in FacetReflectionUtil.NonFacetMemberNames(contractType))
            {
                var id = IDTableHelper.GenerateIdForFacetMember(memberName, itemDefinition.ID,
                            Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberTemplate);

                ids.Add(id);
            }

            foreach (string memberName in FacetReflectionUtil.FacetMemberNames(contractType))
            {
                foreach (
                    string subMemberName in
                        FacetReflectionUtil.NonFacetMemberNames(contractType.GetProperty(memberName).PropertyType))
                {
                    string key = $"{memberName}{NestedFacets.Delimeter}{subMemberName}";

                    var id = IDTableHelper.GenerateIdForFacetMember(key, itemDefinition.ID,
                        Sitecore.Strategy.Contacts.DataProviders.TemplateIDs.ContactFacetMemberTemplate);

                    ids.Add(id);
                }
            }
        }
Example #6
0
 // Methods
 public PrefetchData(ItemDefinition itemDefinition, ID parentId)
 {
     Assert.ArgumentNotNull(itemDefinition, "itemDefinition");
     Assert.ArgumentNotNull(parentId, "parentId");
     this._itemDefinition = itemDefinition;
     this._parentId = parentId;
 }
        public override void Refine(ItemDefinition currentDefinition)
        {
			if (InstallerVisibility != InstallerHint.Default)
				currentDefinition.Installer = InstallerVisibility;

            base.Refine(currentDefinition);
        }
Example #8
0
        public override IDictionary<string, System.Web.UI.Control> AddDefinedEditors(ItemDefinition definition, N2.ContentItem item, System.Web.UI.Control container, System.Security.Principal.IPrincipal user, Type containerTypeFilter, IEnumerable<string> editableNameFilter)
        {
            ItemDefinition cloned = null;

            // add a "wrap in container" checkbox to all parts that are within zones that are not wrapped in a container (BeforeMain, AfterMain).
            if (!definition.IsPage)
            {
                if (!(Defaults.IsContainerWrappable(item.ZoneName) ||
                      Defaults.IsContainerWrappable(System.Web.HttpContext.Current.Request["zoneName"])))
                {
                    cloned = definition.Clone();
                    var isWrappable = cloned.Editables.FirstOrDefault(x => x.Name == "UseContainer");
                    if (isWrappable != null)
                    {
                        cloned.Editables.Remove(isWrappable);
                    }
                }
            }

            if (item is IItemAdapter)
            {
                var result = (item as IItemAdapter).AddDefinedEditors(cloned ?? definition, container, user, containerTypeFilter, editableNameFilter);
                if (result != null)
                    return result;
            }
            return base.AddDefinedEditors(cloned ?? definition, item, container, user, containerTypeFilter, editableNameFilter);
        }
 private void AddEditableText(ItemDefinition definition, string title, string name, int sortOrder, int maxLength)
 {
     EditableTextBoxAttribute titleEditor = new EditableTextBoxAttribute(title, sortOrder, maxLength);
     titleEditor.Name = name;
     titleEditor.ContainerName = "seo";
     definition.Add(titleEditor);
 }
 public override VersionUriList GetItemVersions(ItemDefinition itemDefinition, CallContext context)
 {
     if (Items.Contains(itemDefinition.ID))
     {
         Log.Info(string.Format("GetItemVersions called with itemDefinition id = {0}, name = {1} (BasicDataProvider)", itemDefinition.ID, itemDefinition.Name), this);
     }
     return null;
 }
Example #11
0
 /// <summary>Changes allowed parents on the item definition.</summary>
 /// <param name="currentDefinition">The definition to alter.</param>
 /// <param name="allDefinitions">All definitions.</param>
 public override void Refine(ItemDefinition currentDefinition, IList<ItemDefinition> allDefinitions)
 {
     foreach (ItemDefinition definition in allDefinitions)
     {
         if (IsAssignable(definition.ItemType))
             definition.AddAllowedChild(currentDefinition);
     }
 }
Example #12
0
 public static IEnumerable<ItemDefinition> AllowedBelow(this IEnumerable<ItemDefinition> allDefinitions, ItemDefinition parentDefinition, ContentItem parentItem, IDefinitionManager definitions)
 {
     foreach (var definition in allDefinitions)
     {
         if (IsAllowed(definition, parentItem, parentDefinition, definitions))
             yield return definition;
     }
 }
Example #13
0
 public static IEnumerable<TemplateDefinition> AllowedBelow(this IEnumerable<TemplateDefinition> allTemplates, ItemDefinition parentDefinition, ContentItem parentItem, IDefinitionManager definitions)
 {
     foreach (var template in allTemplates)
     {
         if (IsAllowed(template.Definition, parentItem, parentDefinition, definitions))
             yield return template;
     }
 }
Example #14
0
 public IEnumerable<TemplateDefinition> GetTemplates(ItemDefinition definition)
 {
     return Definitions.GetTemplates(definition.ItemType)
         .AllowedBelow(Definitions.GetDefinition(Selection.SelectedItem), Selection.SelectedItem, Engine.Definitions)
         .Where(t => t.Definition.IsAllowed(ZoneName, User))
         .OrderBy(t => (t.Definition.TemplateKey ?? "Index") == "Index" ? 0 : 1)
         .ThenBy(t => t.Definition.SortOrder);
 }
 public override IDList GetChildIDs(ItemDefinition itemDefinition, CallContext context)
 {
     if (itemDefinition != null && itemDefinition.ID == JoinParentId)
     {
         Log.Info(string.Format("GetChildIDs called with itemDefinition id = {0}, name = {1} (BasicDataProvider)", itemDefinition.ID, itemDefinition.Name), this);
     }
     return null;
 }
        public void AddVersion(ItemDefinition itemDefinition, VersionUri baseVersion, CallContext context)
        {
            if (DisableSerialization) return;

            Assert.ArgumentNotNull(itemDefinition, "itemDefinition");

            SerializeItemIfIncluded(itemDefinition, "Version Added");
        }
		public NotAllowedParentException(ItemDefinition itemDefinition, Type parentType)
			: base("The item '{0}' isn't allowed below a destination of type '{1}'.", 
				itemDefinition.Title,
				parentType.AssemblyQualifiedName)
		{
			this.itemDefinition = itemDefinition;
			this.parentType = parentType;
		}
Example #18
0
 public CraftEvent(ItemCrafter self, ItemBlueprint bp, BasePlayer owner, ProtoBuf.Item.InstanceData instanceData, int amount)
 {
     Crafter = Server.GetPlayer(owner);
     Target = bp.targetItem;
     itemCrafter = self;
     Amount = amount;
     bluePrint = bp;
 }
Example #19
0
 private static void WriteTitle(TextWriter writer, ItemDefinition definition)
 {
     writer.Write("<span class='title' style='background-image:url(");
     writer.Write(Url.ResolveTokens(definition.IconUrl));
     writer.Write(");'>");
     writer.Write(definition.Title);
     writer.Write("</span>");
 }
        public void SetUp()
        {
            parentDefinition = new ItemDefinition(typeof(DefinitionControllingParent)) { TemplateKey = "List" };
            childDefinition = new ItemDefinition(typeof(DefinitionOppressedChild)) { TemplateKey = "Wide" };

            definitions = MockRepository.GenerateStub<IDefinitionManager>();
            definitions.Expect(d => d.GetDefinitions()).Return(new[] { parentDefinition, childDefinition }).Repeat.Any();
        }
 public override FieldList GetItemFields(ItemDefinition itemDefinition, VersionUri versionUri, CallContext context)
 {
     if (Items.Contains(itemDefinition.ID))
     {
         Log.Info(string.Format("GetItemFields called with itemDefinition id = {0}, name = {1}, version = {2}, language = {3} (BasicDataProvider)", itemDefinition.ID, itemDefinition.Name, versionUri.Version, versionUri.Language.Name), this);
     }
     return null;
 }
		public override void Refine(ItemDefinition currentDefinition, IList<ItemDefinition> allDefinitions)
		{
			if (AffectedType != null && !AffectedType.IsAssignableFrom(currentDefinition.ItemType))
				return;

			var containable = currentDefinition.GetNamed(Name);
			currentDefinition.RemoveRange(containable);
		}
 public override void Refine(ItemDefinition currentDefinition)
 {
     currentDefinition.Enabled = true;
     currentDefinition.IsPage = false;
     currentDefinition.AllowedIn = N2.Integrity.AllowedZones.AllNamed;
     currentDefinition.AllowedZoneNames.Add("CommentsPlugin");
     currentDefinition.AllowedParentFilters.Add(this);
     base.Refine(currentDefinition);
 }
		public override bool SaveItem(ItemDefinition itemDefinition, ItemChanges changes, CallContext context)
		{
			if (!base.SaveItem(itemDefinition, changes, context)) return false;

			foreach (var provider in _unicornDataProviders)
				provider.SaveItem(itemDefinition, changes, context);

			return true;
		}
		public override bool MoveItem(ItemDefinition itemDefinition, ItemDefinition destination, CallContext context)
		{
			if (!base.MoveItem(itemDefinition, destination, context)) return false;

			foreach (var provider in _unicornDataProviders)
				provider.MoveItem(itemDefinition, destination, context);

			return true;
		}
    public void ChangeTemplateThrowsIfNoTargetTemplateFound([Greedy]FakeDataProvider sut, ItemDefinition def, TemplateChangeList changes, DbItem item)
    {
      sut.DataStorage.GetFakeItem(def.ID).Returns(item);

      Action action = () => sut.ChangeTemplate(def, changes, null);

      action.ShouldThrow<InvalidOperationException>()
            .WithMessage("Unable to change item template. The target template is not found.");
    }
 private EditableTextAttribute AddEditableText(ItemDefinition definition, string title, string name, int sortOrder, int maxLength)
 {
     EditableTextAttribute editor = new EditableTextAttribute(title, sortOrder);
     editor.MaxLength = maxLength;
     editor.Name = name;
     editor.ContainerName = Tabs.Details;
     definition.Add(editor);
     return editor;
 }
		public TranslateSpecification(string editUrl, ILanguage language, ContentItem existingItem, ItemDefinition definition, Site site)
		{
			EditUrl = editUrl;
			Language = language;
			ExistingItem = existingItem;
			Definition = definition;
			Site = site;
			IsTranslatable = true;
		}
 public override bool SaveItem(ItemDefinition itemDefinition, ItemChanges changes, CallContext context)
 {
     Item item = this.Database.GetItem(itemDefinition.ID);
     ItemDefinition parent = GetItemDefinition(item.ParentID, context);
     /* only creates the item if it does not exist yet */
     CreateItem(itemDefinition.ID, itemDefinition.Name, itemDefinition.TemplateID, parent, context);
     bool result = base.SaveItem(itemDefinition, changes, context);
     return result;
 }
		public override bool HasChildren(ItemDefinition itemDefinition, CallContext context)
		{
			Assert.ArgumentNotNull(itemDefinition, "itemDefinition");

			if (!ShouldExecuteProvider(itemDefinition.ID)) return false;

			context.Abort();
			return GetChildIDs(itemDefinition, context).Count > 0; // we use GetChildIDs here so we can filter on included children
		}
 public override void Refine(ItemDefinition currentDefinition, IList <ItemDefinition> allDefinitions)
 {
     currentDefinition.AllowedChildFilters.Add(this);
 }
Example #32
0
 protected void rblPosition_OnSelectedIndexChanged(object sender, EventArgs args)
 {
     ParentItemDefinition = Definitions.GetDefinition(ActualItem);
     LoadZones();
     ZoneName = GetSelectedZone();
 }
Example #33
0
 public CommandContext(ItemDefinition definition, ContentItem content, string userInterface, IPrincipal user)
     : this(definition, content, userInterface, user, new NullBinder <CommandContext>(), new NullValidator <CommandContext>())
 {
 }
Example #34
0
 void RemoveContainable(ItemDefinition definition, ContainableElement editable)
 {
     definition.Remove(definition.Get(editable.Name));
 }
Example #35
0
 public override bool CopyItem(ItemDefinition source, ItemDefinition destination, string copyName, ID copyID, CallContext context)
 {
     return(base.CopyItem(source, destination, copyName, copyID, context));
 }
 int GetStackSize(ItemDefinition item)
 {
     return(item.stackable);
 }
        void OnItemAddedToContainer(ItemContainer container, Item item)
        {
            if (item.info.shortname != "metal.ore" && item.info.shortname != "sulfur.ore" && item.info.shortname != "hq.metal.ore")
            {
                return;
            }

            if (container.itemList.Count() > 1)
            {
                return;
            }

            int cap = container.capacity;

            if (cap != 6 && cap != 18)
            {
                return;
            }

            if (item.amount < cap)
            {
                return;
            }

            int oresize, woodsize, outputsize;

            if (cap == 6)
            {
                oresize    = Cfg.furnaceHQMetalOres;
                woodsize   = Cfg.furnaceHQMetalWood;
                outputsize = Cfg.furnaceHQMetalOutput;
                if (item.info.shortname == "metal.ore")
                {
                    oresize    = Cfg.furnaceMetalOres;
                    woodsize   = Cfg.furnaceMetalWood;
                    outputsize = Cfg.furnaceMetalOutput;
                }
                else if (item.info.shortname == "sulfur.ore")
                {
                    oresize    = Cfg.furnaceSulfurOres;
                    woodsize   = Cfg.furnaceSulfurWood;
                    outputsize = Cfg.furnaceSulfurOutput;
                }
            }
            else
            {
                oresize    = Cfg.largeFurnaceHQMetalOres;
                woodsize   = Cfg.largeFurnaceHQMetalWood;
                outputsize = Cfg.largeFurnaceHQMetalOutput;
                if (item.info.shortname == "metal.ore")
                {
                    oresize    = Cfg.largeFurnaceMetalOres;
                    woodsize   = Cfg.largeFurnaceMetalWood;
                    outputsize = Cfg.largeFurnaceMetalOutput;
                }
                else if (item.info.shortname == "sulfur.ore")
                {
                    oresize    = Cfg.largeFurnaceSulfurOres;
                    woodsize   = Cfg.largeFurnaceSulfurWood;
                    outputsize = Cfg.largeFurnaceSulfurOutput;
                }
            }
            double woodfactor = Cfg.cooktime_hqmetal / Cfg.burntime_wood;
            string outputname = "metal.refined";

            if (item.info.shortname == "metal.ore")
            {
                woodfactor = Cfg.cooktime_metal / Cfg.burntime_wood;
                outputname = "metal.fragments";
            }
            else if (item.info.shortname == "sulfur.ore")
            {
                woodfactor = Cfg.cooktime_sulfur / Cfg.burntime_wood;
                outputname = "sulfur";
            }

            if (oresize + woodsize + outputsize > cap)
            {
                return;
            }

            BaseOven furnace = null;

            foreach (BaseOven key in furnaceCache.Keys)
            {
                if (key.inventory == container)
                {
                    furnace = key;
                    break;
                }
            }
            if (!furnace)
            {
                return;
            }

            BasePlayer player;

            if (!furnaceCache.TryGetValue(furnace, out player) || !player)
            {
                return;
            }

            int orecount = 0;

            Item[] items = player.inventory.AllItems();
            foreach (Item itm in items)
            {
                if (itm.info.shortname == item.info.shortname)
                {
                    orecount += itm.amount;
                }
            }
            orecount += item.amount;
            if (orecount > oresize * GetStackSize(outputname))
            {
                orecount = oresize * GetStackSize(outputname);
            }


            ItemDefinition wooddefinition = ItemManager.FindItemDefinition("wood");
            int            woodToRetain   = (int)(Math.Ceiling((double)orecount / oresize) * woodfactor);
            //Puts(woodToRetain.ToString());
            int woodMaxStack = GetStackSize(wooddefinition);

            if (woodToRetain > woodMaxStack * woodsize)
            {
                woodToRetain = woodMaxStack * woodsize;
            }
            //Puts(woodToRetain.ToString());

            int retainedWood = RemoveItemsFromInventory(player, wooddefinition, woodToRetain);

            if (retainedWood < woodsize)
            {
                GivePlayerItems(player, wooddefinition, retainedWood);
                return;
            }

            if (woodToRetain > retainedWood)
            {
                orecount = (int)(Math.Floor(retainedWood / woodfactor) * oresize);
                int oldretained = retainedWood;
                retainedWood = (int)(orecount / oresize * woodfactor);
                GivePlayerItems(player, wooddefinition, oldretained - retainedWood);
            }

            int retainedAmount;

            retainedAmount = RemoveItemsFromInventory(player, outputname, outputsize);
            if (retainedAmount < outputsize)
            {
                GivePlayerItems(player, wooddefinition, retainedWood);
                return;
            }

            item.MoveToContainer(player.inventory.containerMain, -1, false);

            int extraWood = retainedWood % woodsize;
            //Puts(extraWood.ToString());
            int perstack = (int)Math.Floor((double)retainedWood / woodsize);

            //Puts(perstack.ToString());
            for (int i = 0; i < woodsize; i++)
            {
                ItemManager.Create(wooddefinition, perstack + (extraWood > 0 ? 1 : 0)).MoveToContainer(container, -1, false);
                extraWood--;
            }

            for (int i = 0; i < outputsize; i++)
            {
                ItemManager.Create(ItemManager.FindItemDefinition(outputname), 1).MoveToContainer(container, -1, false);
            }

            RemoveItemsFromInventory(player, item.info.shortname, orecount);

            int amountPerStack = orecount / oresize;

            Item[] oresToAdd = new Item[oresize];
            int    extras    = orecount % oresize;

            for (int i = 0; i < oresize; i++)
            {
                int tmpCnt = 0;
                if (extras > 0)
                {
                    tmpCnt++;
                }
                tmpCnt += amountPerStack;
                extras--;
                oresToAdd[i] = ItemManager.Create(ItemManager.FindItemDefinition(item.info.shortname), tmpCnt);
            }

            foreach (Item oreToAdd in oresToAdd)
            {
                oreToAdd.MoveToContainer(container, -1, false);
            }

            furnace.Invoke("StartCooking", 0);
        }
Example #38
0
 public virtual IEnumerable <TemplateDefinition> GetTemplates(ContentItem item, ItemDefinition definition)
 {
     return(Definitions.GetTemplates(definition.ItemType));
 }
    public void DistributeFromShopItem(ShopSlot slot, InventorySlot dropSlot)
    {
        int            stackLimit  = slot.InventoryItem.StackLimit;
        ItemDefinition item        = slot.Item;
        int            spaceNeeded = 1;

        if (dropSlot != null)
        {
            if (dropSlot.HasItem)
            {
                if (dropSlot.HasFreeSpaceForItem(slot.Item))
                {
                    spaceNeeded = dropSlot.SlotItem.AddItems(spaceNeeded);
                }
            }
            else
            {
                if (spaceNeeded <= stackLimit)
                {
                    dropSlot.CreateItem(item.Type, item.Id, spaceNeeded);
                    spaceNeeded = 0;
                }
                else
                {
                    dropSlot.CreateItem(item.Type, item.Id, stackLimit);
                    spaceNeeded -= stackLimit;
                }
            }
        }

        while (spaceNeeded > 0)
        {
            InventorySlot extendableSlot = SeekExtendableStack(slot.Item);
            if (extendableSlot != null)
            {
                spaceNeeded = extendableSlot.SlotItem.AddItems(spaceNeeded);
            }
            else
            {
                break;
            }
        }

        for (int i = 0; i < InventorySlots.Count; i++)
        {
            if (spaceNeeded == 0)
            {
                return;
            }

            if (InventorySlots[i].HasItem)
            {
                if (InventorySlots[i].HasFreeSpaceForItem(item))
                {
                    spaceNeeded = InventorySlots[i].SlotItem.AddItems(spaceNeeded);
                }
            }
            else
            {
                if (spaceNeeded <= stackLimit)
                {
                    InventorySlots[i].CreateItem(item.Type, item.Id, spaceNeeded);
                    spaceNeeded = 0;
                }
                else
                {
                    InventorySlots[i].CreateItem(item.Type, item.Id, stackLimit);
                    spaceNeeded -= stackLimit;
                }
            }
        }
    }
Example #40
0
        public override bool SaveItem(ItemDefinition itemDefinition, ItemChanges changes, CallContext context)
        {
            var current = Provider.GetItem(itemDefinition.ID.ToGuid());

            if (current == null)
            {
                return(false);
            }

            if (changes.HasPropertiesChanged)
            {
                current.Name = StringUtil.GetString(changes.GetPropertyValue("name"), itemDefinition.Name);

                var templateId = MainUtil.GetObject(changes.GetPropertyValue("templateid"), itemDefinition.TemplateID) as ID;
                current.TemplateId = templateId != ID.Null ? templateId.ToGuid() : Guid.Empty;

                var branchId = MainUtil.GetObject(changes.GetPropertyValue("branchid"), itemDefinition.BranchId) as ID;
                current.BranchId = branchId != ID.Null ? branchId.ToGuid() : Guid.Empty;
            }

            if (changes.HasFieldsChanged)
            {
                foreach (FieldChange change in changes.FieldChanges)
                {
                    var fieldVersionUri = new VersionUri(
                        change.Definition == null || change.Definition.IsShared ? null : change.Language,
                        change.Definition == null || change.Definition.IsUnversioned ? null : change.Version);

                    var matchingFields = current.FieldValues.Where(fv => fv.Matches(fieldVersionUri) && fv.Id.Equals(change.FieldID.ToGuid())).ToList();

                    if (change.RemoveField)
                    {
                        if (matchingFields.Any())
                        {
                            current.FieldValues.Remove(matchingFields.First());
                        }
                    }
                    else
                    {
                        if (matchingFields.Any())
                        {
                            current.FieldValues.Find(fv => fv.Matches(fieldVersionUri) && fv.Id.Equals(change.FieldID.ToGuid())).Value = change.Value;
                        }
                        else
                        {
                            current.FieldValues.Add(new FieldDto
                            {
                                Id       = change.FieldID.ToGuid(),
                                Language = fieldVersionUri.Language != null ? fieldVersionUri.Language.Name : null,
                                Version  = fieldVersionUri.Version != null ? fieldVersionUri.Version.Number : null as int?,
                                Value    = change.Value
                            });
                        }

                        if (change.FieldID == FieldIDs.WorkflowState)
                        {
                            Guid workflowStateId;

                            Guid.TryParse(change.Value, out workflowStateId);

                            current.WorkflowStateId = workflowStateId;
                        }
                    }
                }

                Provider.WritableProvider.Store(current);
            }

            return(true);
        }
Example #41
0
 public override WorkflowInfo GetWorkflowInfo(ItemDefinition item, VersionUri version, CallContext context)
 {
     return(base.GetWorkflowInfo(item, version, context));
 }
Example #42
0
 public virtual Item CreateItem(ItemDefinition itemDefinition, Vector3 position)
 {
     return(world.itemManager.CreateItem(itemDefinition, NextObjectId(), position, true));
 }
Example #43
0
 public override bool ChangeTemplate(ItemDefinition itemDefinition, TemplateChangeList changes, CallContext context)
 {
     return(base.ChangeTemplate(itemDefinition, changes, context));
 }
Example #44
0
        public override void Refine(ItemDefinition currentDefinition)
        {
            currentDefinition.Installer = InstallerVisibility;

            base.Refine(currentDefinition);
        }
Example #45
0
        public override bool DeleteItem(ItemDefinition itemDefinition, CallContext context)
        {
            var provider = Provider.WritableProvider;

            return(provider.DeleteItem(itemDefinition.ID.ToGuid()));
        }
Example #46
0
 public override bool SetWorkflowInfo(ItemDefinition item, VersionUri version, WorkflowInfo info, CallContext context)
 {
     return(base.SetWorkflowInfo(item, version, info, context));
 }
Example #47
0
        Item MightyRNG(string type, int itemCount, bool blockBPs = false)
        {
            bool          asBP = rng.NextDouble() < blueprintProbability && !blockBPs;
            List <string> selectFrom;
            int           limit = 0;
            string        itemName;
            Item          item;
            int           maxRetry = 10 * itemCount;

            do
            {
                selectFrom = null;
                item       = null;
                if (asBP)
                {
                    var r = rng.Next(totalBlueprintWeight[type]);
                    for (var i = 0; i < 5; ++i)
                    {
                        limit += blueprintWeights[type][i];
                        if (r < limit)
                        {
                            selectFrom = Blueprints[type][i];
                            break;
                        }
                    }
                }
                else
                {
                    var r = rng.Next(totalItemWeight[type]);
                    for (var i = 0; i < 5; ++i)
                    {
                        limit += itemWeights[type][i];
                        if (r < limit)
                        {
                            selectFrom = Items[type][i];
                            break;
                        }
                    }
                }
                if (selectFrom == null)
                {
                    if (--maxRetry <= 0)
                    {
                        break;
                    }
                    continue;
                }
                itemName = selectFrom[rng.Next(0, selectFrom.Count)];
                ItemDefinition itemDef = ItemManager.FindItemDefinition(itemName);
                if (asBP && itemDef.Blueprint != null && itemDef.Blueprint.isResearchable)
                {
                    var blueprintBaseDef = ItemManager.FindItemDefinition("blueprintbase");
                    item = ItemManager.Create(blueprintBaseDef, 1, 0uL);
                    item.blueprintTarget = itemDef.itemid;
                }
                else
                {
                    item = ItemManager.CreateByName(itemName, 1);
                }
                if (item == null || item.info == null)
                {
                    continue;
                }
                break;
            } while (true);
            if (item == null)
            {
                return(null);
            }
            object itemOptions;

            if (((lootTables[type] as Dictionary <string, object>)["ItemList"] as Dictionary <string, object>).TryGetValue(item.info.shortname, out itemOptions))
            {
                Dictionary <string, object> options = itemOptions as Dictionary <string, object>;
                item.amount = UnityEngine.Random.Range(Math.Min((int)options["Min"], (int)options["Max"]), Math.Max((int)options["Min"], (int)options["Max"])) * lootMultiplier;
                //if (options.ContainsKey("SkinId"))
                //item.skin = (uint)options["SkinId"];
            }
            item.OnVirginSpawn();
            return(item);
        }
Example #48
0
 public override bool RemoveVersions(ItemDefinition itemDefinition, Language language, CallContext context)
 {
     return(base.RemoveVersions(itemDefinition, language, context));
 }
Example #49
0
 private static ushort GetItemType(this ItemDefinition item)
 {
     // since the original game server/client supports up to 512 items per group, we have to shift the group by 9 bytes instead of 8.
     return((ushort)((ushort)(item.Group << 9) | (ushort)item.Number));
 }
Example #50
0
 public override bool RemoveVersion(ItemDefinition itemDefinition, VersionUri version, CallContext context)
 {
     return(base.RemoveVersion(itemDefinition, version, context));
 }
Example #51
0
        protected string GetEditUrl(ItemDefinition definition)
        {
            Url newUrl = Engine.ManagementPaths.GetEditNewPageUrl(Selection.SelectedItem, definition, ZoneName, GetCreationPosition());

            return(newUrl.AppendQuery("returnUrl", Request["returnUrl"]));
        }
Example #52
0
 public override bool MoveItem(ItemDefinition itemDefinition, ItemDefinition destination, CallContext context)
 {
     return(base.MoveItem(itemDefinition, destination, context));
 }
Example #53
0
        public static bool RequiresTileExtra(int id)
        {
            ItemDefinition def = GetItemDef(id);

            return
                (def.actionType == 2 ||  // Door
                 def.actionType == 3 ||  // Lock
                 def.actionType == 10 || // Sign
                 def.actionType == 13 || // Main Door
                 def.actionType == 19 || // Seed
                 def.actionType == 26 || // Portal
                 def.actionType == 33 || // Mailbox
                 def.actionType == 34 || // Bulletin Board
                 def.actionType == 36 || // Dice Block
                 def.actionType == 36 || // Roshambo Block
                 def.actionType == 38 || // Chemical Source
                 def.actionType == 40 || // Achievement Block
                 def.actionType == 43 || // Sungate
                 def.actionType == 46 ||
                 def.actionType == 47 ||
                 def.actionType == 49 ||
                 def.actionType == 50 ||
                 def.actionType == 51 || // Bunny Egg
                 def.actionType == 52 ||
                 def.actionType == 53 ||
                 def.actionType == 54 || // Xenonite
                 def.actionType == 55 || // Phone Booth
                 def.actionType == 56 || // Crystal
                 def.id == 2246 ||       // Crystal
                 def.actionType == 57 || // Crime In Progress
                 def.actionType == 59 || // Spotlight
                 def.actionType == 61 ||
                 def.actionType == 62 ||
                 def.actionType == 63 ||  // Fish Wall Port
                 def.id == 3760 ||        // Data Bedrock
                 def.actionType == 66 ||  // Forge
                 def.actionType == 67 ||  // Giving Tree
                 def.actionType == 73 ||  // Sewing Machine
                 def.actionType == 74 ||
                 def.actionType == 76 ||  // Painting Easel
                 def.actionType == 78 ||  // Pet Trainer (WHY?!)
                 def.actionType == 80 ||  // Lock-Bot (Why?!)
                 def.actionType == 81 ||
                 def.actionType == 83 ||  // Display Shelf
                 def.actionType == 84 ||
                 def.actionType == 85 ||  // Challenge Timer
                 def.actionType == 86 ||  // Challenge Start/End Flags
                 def.actionType == 87 ||  // Fish Wall Mount
                 def.actionType == 88 ||  // Portrait
                 def.actionType == 89 ||
                 def.actionType == 91 ||  // Fossil Prep Station
                 def.actionType == 93 ||  // Howler
                 def.actionType == 97 ||  // Storage Box Xtreme / Untrade-a-box
                 def.actionType == 100 || // Geiger Charger
                 def.actionType == 101 ||
                 def.actionType == 111 || // Magplant
                 def.actionType == 113 || // CyBot
                 def.actionType == 115 || // Lucky Token
                 def.actionType == 116 || // GrowScan 9000 ???
                 def.actionType == 127 || // Temp. Platform
                 def.actionType == 130 ||
                 (def.id % 2 == 0 && def.id >= 5818 && def.id <= 5932) ||
                 // ...
                 false);
        }
Example #54
0
 public override bool HasChildren(ItemDefinition itemDefinition, CallContext context)
 {
     return(base.HasChildren(itemDefinition, context));
 }
Example #55
0
        public static void DrainStaminaViaCustomItemDefinition(Player player, ItemDefinition itemDef)
        {
            var myplayer = player.GetModPlayer <StaminaPlayer>();

            myplayer.Logic.DrainStaminaViaCustomItemUse(player, itemDef);
        }
Example #56
0
 public RefinerPair(ItemDefinition definition, ISortableRefiner refiner)
 {
     Definition = definition;
     Refiner    = refiner;
 }