예제 #1
0
파일: Mod.cs 프로젝트: tpf89/StardewMods
        private void generateObject(string owner, int replacement, int stackAmount, string requirements)
        {
            if (owner == "???")
            {
                Monitor.Log("Attempt to add a object to a shop owned by `???`, this cant be done because `???` means the owner is unknown!", LogLevel.Error);
                return;
            }
            StardewValley.Object stack = new StardewValley.Object(replacement, stackAmount);
            if (stack.salePrice() == 0)
            {
                Monitor.Log("Unable to add item to shop, it has no value: " + replacement, LogLevel.Error);
                return;
            }
            SObject obj = new SObject(stack, stackAmount);

            obj.targetedShop = owner;
            if (!affectedShops.Contains(owner))
            {
                affectedShops.Add(owner);
            }
            obj.requirements = requirements;
            Monitor.Log($"RegisterObject({obj.Name}:{replacement}@{owner},{obj.stackAmount}*{obj.maximumStackSize()},'{requirements}')", LogLevel.Trace);
            if (AddedObjects.ContainsKey(obj.Name))
            {
                return;
            }
            AddedObjects.Add(obj.Name, obj);
            ReplacementStacks.Add(obj.Name, stack);
        }
예제 #2
0
 /// <summary>
 /// Создать штриховку из региона (области).
 /// Используется коммандный метод - ed.Command!!!
 /// </summary>
 /// <param name="reg">Регион</param>
 /// <param name="ed">Редактор</param>
 /// <returns></returns>
 public static ObjectId ConvertToHatch(this Region reg, Editor ed)
 {
     using (var added = new AddedObjects(reg.Database))
     {
         ed.Command("_-HATCH", "_S", reg.Id, "", "");
         return(added.Added.FirstOrDefault(o => o.ObjectClass == General.ClassHatch));
     }
 }
예제 #3
0
 private void ResolveAddedObjects()
 {
     AddedObjects.Clear();
     foreach (var addedMember in NewValue.Where(pm => !OldValue.Contains(pm)))
     {
         AddedObjects.Add(addedMember);
     }
 }
예제 #4
0
        void ComputeMerge_Added(Commit branchTip, PatchEntryChanges change, Patch headChanges)
        {
            var parentDataPath = change.Path.GetDataParentDataPath();

            if (headChanges.Any(c => c.Path.Equals(parentDataPath, StringComparison.OrdinalIgnoreCase) && c.Status == ChangeKind.Deleted))
            {
                throw new NotImplementedException("Node addition while parent has been deleted in head is not supported.");
            }

            var branchObject = GetContent(branchTip, change.Path, "branch tip");

            AddedObjects.Add(new MetadataTreeMergeObjectAdd(change.Path, branchObject));
        }
        private void ComputeMerge_Added(Commit branchTip, PatchEntryChanges change, Patch headChanges)
        {
            // Only data file changes have to be taken into account
            // Changes made to the blobs will product a 'modified' change as well
            if (Path.GetFileName(change.Path) != FileSystemStorage.DataFile)
            {
                return;
            }

            var parentDataPath = change.Path.GetDataParentDataPath();

            if (headChanges.Any(c => c.Path.Equals(parentDataPath, StringComparison.OrdinalIgnoreCase) && c.Status == ChangeKind.Deleted))
            {
                throw new NotImplementedException("Node addition while parent has been deleted in head is not supported.");
            }

            var branchObject = GetContent(branchTip, change.Path, "branch tip");
            var parentId     = change.Path.GetDataParentId(Repository);

            AddedObjects.Add(new ObjectRepositoryAdd(change.Path, branchObject, parentId));
        }
 /// <summary>
 /// Clears the changes.
 /// </summary>
 internal void ClearChanges()
 {
     ModifiedProperties.Clear();
     AddedObjects.Clear();
     DeletedObjects.Clear();
 }