Exemplo n.º 1
0
 public ModRecipe(ICoreTranslationHelper translationHelper, ISprite sprite, IEnumerable <IRecipePart> results, IEnumerable <IRecipePart> ingredients, string name = null, bool isCooking = false) : base(isCooking)
 {
     this.Sprite             = sprite;
     this.Results            = results;
     this.Ingredients        = ingredients;
     this._translationHelper = translationHelper;
     this._name = name;
 }
Exemplo n.º 2
0
        public CoreApi(IMod owner, ItemDelegator itemDelegator, TextureTracker textureTracker)
        {
            this.Owner             = owner;
            this.ContentSource     = new ModContentSource(owner);
            this.TranslationHelper = new CoreTranslationHelper(this);

            // Create the APIs
            this._drawing = new Lazy <IDrawingApi>(() => new DrawingApi(new ApiHelper(this, "Drawing"), textureTracker));
            this._items   = new Lazy <IItemApi>(() => new ItemApi(new ApiHelper(this, "Items"), itemDelegator));
            this._json    = new Lazy <IJsonApi>(() => new JsonApi(new ApiHelper(this, "Json")));
        }
Exemplo n.º 3
0
 public ModWeapon(ICoreTranslationHelper translationHelper, string rawName, ISprite sprite, WeaponType type, int minDamage, int maxDamage, float knockback = 1, int speed = 0, int precision = 0, int defense = 0, int areaOfEffect = 1, float critChance = 0.02f, float critMultiplier = 3) : base(translationHelper, rawName, sprite)
 {
     this.MinDamage      = minDamage;
     this.MaxDamage      = maxDamage;
     this.Knockback      = knockback;
     this.Speed          = speed;
     this.Precision      = precision;
     this.Defense        = defense;
     this.Type           = type;
     this.AreaOfEffect   = areaOfEffect;
     this.CritChance     = critChance;
     this.CritMultiplier = critMultiplier;
 }
Exemplo n.º 4
0
 public ModFood(ICoreTranslationHelper translationHelper, ISprite sprite, string rawName, int cost, int edibility, Category category, bool isDrink, in BuffDescription buffs) : base(translationHelper, sprite, rawName, cost, category, edibility)
Exemplo n.º 5
0
 public ModFood(ICoreTranslationHelper translationHelper, ISprite sprite, string rawName, int cost, int edibility, Category category, bool isDrink) : this(translationHelper, sprite, rawName, cost, edibility, category, isDrink, new BuffDescription(0))
 {
 }
Exemplo n.º 6
0
 protected ModItem(ICoreTranslationHelper translationHelper, string rawName, ISprite sprite)
 {
     this.TranslationHelper = translationHelper;
     this.RawName           = rawName;
     this.Sprite            = sprite;
 }
Exemplo n.º 7
0
 public ModRecipe(ICoreTranslationHelper translationHelper, ISprite sprite, IEnumerable <IRecipePart> results, params IRecipePart[] ingredients) : this(translationHelper, sprite, results, ingredients?.AsEnumerable())
 {
 }
Exemplo n.º 8
0
 public ModRecipe(ICoreTranslationHelper translationHelper, ISprite sprite, IRecipePart result, IEnumerable <IRecipePart> ingredients, string name = null, bool isCooking = false) : this(translationHelper, sprite, result.Yield(), ingredients?.AsEnumerable(), name, isCooking)
 {
 }
        private void LoadWeapons(IContentPack contentPack, IContentSource contentSource, ICoreTranslationHelper translationHelper, IEnumerable <ContentPackDataInfo> sources)
        {
            var weapons = (from source in sources
                           from entry in source.Content.Weapons
                           select new { Source = source, Name = entry.Key, Data = entry.Value }).ToArray();

            // Create exceptions for conflicting item names
            Exception[] exceptions = (from itemGroup in this.GetDuplicateGroups(weapons, item => item.Name)
                                      select new Exception($"Weapon '{itemGroup.Key}' is being registered by multiple content files: {string.Join(", ", itemGroup.Select(item => $"'{item.Source.FullPath}'"))}")).ToArray();

            // Throw the exceptions
            if (exceptions.Any())
            {
                if (exceptions.Length > 1)
                {
                    throw new AggregateException(exceptions);
                }

                throw exceptions.First();
            }

            // Create each weapon
            foreach (var weapon in weapons)
            {
                ItemKey key = new ItemKey(contentPack.Manifest, weapon.Name);

                // Create the sprite for the object
                ISprite sprite = this.CreateSprite(contentSource, weapon.Source, weapon.Name, weapon.Data);
                if (weapon.Data.Tint != Color.White)
                {
                    sprite = new TintedSprite(sprite, weapon.Data.Tint);
                }

                // Create the weapon's manager
                ModWeapon manager = new ModWeapon(translationHelper, key.LocalKey, sprite, weapon.Data.Type, weapon.Data.MinDamage, weapon.Data.MaxDamage, weapon.Data.Knockback, weapon.Data.Speed, weapon.Data.Accuracy, weapon.Data.Defense, weapon.Data.AreaOfEffect, weapon.Data.CritChance, weapon.Data.CritMultiplier);

                // Register the object
                this._api.Items.CommonRegistry.Weapons.Register(key, manager);
                this._api.Owner.Monitor.Log($" - {key} registered (weapon)", LogLevel.Trace);
            }
        }
Exemplo n.º 10
0
        private void LoadObjects(IContentPack contentPack, IContentSource contentSource, ICoreTranslationHelper translationHelper, IEnumerable <ContentPackDataInfo> sources)
        {
            var objects = (from source in sources
                           from entry in source.Content.Objects
                           select new { Source = source, Name = entry.Key, Data = entry.Value }).ToArray();

            // Create exceptions for conflicting item names
            Exception[] exceptions = (from itemGroup in this.GetDuplicateGroups(objects, item => item.Name)
                                      select new Exception($"Object '{itemGroup.Key}' is being registered by multiple content files: {string.Join(", ", itemGroup.Select(item => $"'{item.Source.FullPath}'"))}")).ToArray();

            // Throw the exceptions
            if (exceptions.Any())
            {
                if (exceptions.Length > 1)
                {
                    throw new AggregateException(exceptions);
                }

                throw exceptions.First();
            }

            // Create each object
            foreach (var obj in objects)
            {
                ItemKey key = new ItemKey(contentPack.Manifest, obj.Name);

                // Create the sprite for the object
                ISprite sprite = this.CreateSprite(contentSource, obj.Source, obj.Name, obj.Data);
                if (obj.Data.Tint != Color.White)
                {
                    sprite = new TintedSprite(sprite, obj.Data.Tint);
                }

                // Create the object's manager
                Category   category = new Category(obj.Data.CategoryNumber, obj.Data.CategoryName);
                IModObject manager  = obj.Data.Buffs.HasValue.Match <bool, IModObject>()
                                      .When(true, () => new ModFood(translationHelper, sprite, key.LocalKey, obj.Data.Cost, obj.Data.Edibility, category, false, obj.Data.Buffs.Value))
                                      .When(false, () => new ModObject(translationHelper, sprite, key.LocalKey, obj.Data.Cost, category, obj.Data.Edibility))
                                      .ElseThrow();

                // Register the object
                this._api.Items.CommonRegistry.Objects.Register(key, manager);
                this._api.Owner.Monitor.Log($" - {key} registered (object)", LogLevel.Trace);
            }
        }
Exemplo n.º 11
0
 public ModObject(ICoreTranslationHelper translationHelper, ISprite sprite, string rawName, int cost, Category category, int edibility) : base(translationHelper, rawName, sprite)
 {
     this.Cost      = cost;
     this.Edibility = edibility;
     this.Category  = category;
 }
Exemplo n.º 12
0
 public ModObject(ICoreTranslationHelper translationHelper, ISprite sprite, string rawName, int cost, Category category) : this(translationHelper, sprite, rawName, cost, category, -300)
 {
 }
Exemplo n.º 13
0
 public ModCraftable(ICoreTranslationHelper translationHelper, string rawName, int cost, int fragility) : base(translationHelper, null, rawName, cost, Category.BigCraftable, -300)
 {
     this.Fragility = fragility;
 }
Exemplo n.º 14
0
 public ModCraftable(ICoreTranslationHelper translationHelper, string rawName, int cost) : this(translationHelper, rawName, cost, 0)
 {
 }