public void Setup() { _itemDefinition = new ItemDefinition(System.Guid.NewGuid()); _equippableItemDefinition = new EquippableItemDefinition(System.Guid.NewGuid()); ItemFactory.Bind <ItemDefinition, ItemInstance>(); }
/// <summary> /// Get the currentChainValue of a parent object. If none is found null will be returned. /// </summary> /// <returns></returns> protected bool DoesInheritFromParent <TValueType>(string propertyName, TValueType currentChainValue, IItemDefinition startObj) { IItemDefinition parent = startObj.parent; while (parent != null) { var type = parent.GetType(); var field = type.GetField(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var startValue = field?.GetValue(parent); if (Equals(startValue, currentChainValue)) { return(true); } var startValueValue = Equals(startValue, GetDefault(type)); var currentChainValueValue = Equals(currentChainValue, GetDefault(type)); if (startValueValue && currentChainValueValue == false) { return(true); } parent = parent.parent; } return(false); }
public Item(IItemDefinition definition, Guid parentId, IEnumerable <IItemDefinition> children, PresentationDetails details = null) { _definition = definition; ParentId = parentId; Children = children; PresentationDetails = details; }
public Item(IItemDefinition definition, Guid parentId, IEnumerable<IItemDefinition> children, PresentationDetails details = null) { _definition = definition; ParentId = parentId; Children = children; PresentationDetails = details; }
public virtual IItemDefinition getDef(string name) { IItemDefinition ret = new IItemDefinition(mcworld_client_corePINVOKE.IItemDefManager_getDef(swigCPtr, name), false); if (mcworld_client_corePINVOKE.SWIGPendingException.Pending) { throw mcworld_client_corePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public ItemInstance(Guid ID, IItemDefinition itemDefinition) { if (itemDefinition == null) { throw new ArgumentException("Given ItemDefintiion is null!"); } this.ID = ID; this.itemDefinition = itemDefinition; }
public static IItemDefinition GetRoot(this IItemDefinition itemDefinition) { var p = itemDefinition; while (p.parent != null) { p = p.parent; } return(p); }
public bool Equals(IItemDefinition other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(ID.Equals(other.ID)); }
public static int GetParentCount(this IItemDefinition itemDefinition) { int i = 0; var p = itemDefinition; while (p.parent != null) { p = p.parent; i++; } return(i); }
public static TValueType GetValue <TValueType>(this IItemDefinition itemDef, GetValueDelegate <TValueType> get, IItemDefinition target, TValueType ignoreValue) { var val = get(target); if (EqualityComparer <TValueType> .Default.Equals(val, ignoreValue)) { if (target.parent != null) { return(GetValue <TValueType>(target, get, target.parent, ignoreValue)); } } return(val); }
public static TValueType GetUnityObjectValue <TValueType>(this IItemDefinition itemDef, GetValueDelegate <TValueType> get, IItemDefinition target, TValueType ignoreValue) where TValueType : UnityEngine.Object { var val = get(target); if (val == ignoreValue) { if (target.parent != null) { return(GetUnityObjectValue <TValueType>(target, get, target.parent, ignoreValue)); } } return(val); }
public virtual string FormatItemAddedMessage(IItemDefinition definition, FormatArguments arguments) { definition = definition ?? throw new ArgumentNullException(nameof(definition)); arguments = arguments ?? throw new ArgumentNullException(nameof(arguments)); var definitionType = FormatDefinitionType(definition); var identifier = FormatItemAddedIdentifier(definition, arguments.Identifier); var oldValue = FormatOldValue(definition, arguments.OldValue); var newValue = FormatNewValue(definition, arguments.NewValue); ValidateMessageMarkers(arguments); // The message format is expected to have markers for each of the above values var message = arguments.MessageFormat .Replace("{DefinitionType}", definitionType) .Replace("{Identifier}", identifier) .Replace("{OldValue}", oldValue) .Replace("{NewValue}", newValue); return(message); }
public static TValueType GetValue <TValueType>(this IItemDefinition itemDef, GetValueDelegate <TValueType> get, TValueType ignoreValue = default(TValueType)) { return(GetValue <TValueType>(itemDef, get, itemDef, ignoreValue)); }
protected override string FormatOldValue(IItemDefinition definition, string?value) { return("`" + base.FormatOldValue(definition, value) + "`"); }
public CollectionItemInstance(Guid ID, IItemDefinition itemDefinition) : base(ID, itemDefinition) { }
public static long GetOverflow(this IItemDefinition def, long uncheckedAmount) => uncheckedAmount > def.MaxAmount ? uncheckedAmount - def.MaxAmount : 0;
protected override string FormatIdentifier(IItemDefinition definition, string identifier) { return("`" + base.FormatIdentifier(definition, identifier) + "`"); }
protected virtual string FormatDefinitionType(IItemDefinition definition) { definition = definition ?? throw new ArgumentNullException(nameof(definition)); if (definition is IClassDefinition) { return("Class"); } if (definition is IInterfaceDefinition) { return("Interface"); } if (definition is IStructDefinition) { return("Struct"); } if (definition is IConstraintListDefinition) { return("Generic constraint"); } if (definition is IPropertyDefinition) { return("Property"); } if (definition is IPropertyAccessorDefinition) { return("Property accessor"); } if (definition is IFieldDefinition) { return("Field"); } if (definition is IMethodDefinition) { return("Method"); } if (definition is IParameterDefinition) { return("Parameter"); } if (definition is IAttributeDefinition) { return("Attribute"); } if (definition is IArgumentDefinition argument) { if (argument.ArgumentType == ArgumentType.Named) { return("Named argument"); } return("Ordinal argument"); } return("Element"); }
public static System.Guid GetRootID(this IItemDefinition itemDefinition) { return(GetRoot(itemDefinition).ID); }
/// <summary> /// Constructs an item stack. /// </summary> public ItemStack([NotNull] IItemDefinition id, int amount) { Id = id ?? throw new ArgumentNullException(nameof(id)); Amount = amount; }
public bool Equals(IItemDefinition other) => other.ItemId == ItemId;
protected virtual string FormatItemRemovedIdentifier(IItemDefinition definition, string identifier) { return(FormatIdentifier(definition, identifier)); }
protected virtual string FormatIdentifier(IItemDefinition definition, string identifier) { return(identifier); }
protected virtual string FormatOldValue(IItemDefinition definition, string?value) { return(value ?? string.Empty); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(IItemDefinition obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public ItemWithCollectionMock(Guid ID, IItemDefinition itemDefinition) : base(ID, itemDefinition) { this.collection = new Collection <IItemInstance>(5); }
public static string GetUrl(this IItemUrlService service, IItemDefinition item) { Requires.IsNotNull(item, nameof(item)); return(service.GetUrl(item.Language, item.Path)); }
public static TValueType GetUnityObjectValue <TValueType>(this IItemDefinition itemDef, GetValueDelegate <TValueType> get, TValueType ignoreValue = default(TValueType)) where TValueType : UnityEngine.Object { return(GetUnityObjectValue <TValueType>(itemDef, get, itemDef, ignoreValue)); }
public static string GetUrl(this IItemUrlService service, IItemDefinition item) { Requires.IsNotNull(item, nameof(item)); return service.GetUrl(item.Language, item.Path); }