/// <summary>A very verbose asset drawer.</summary> public void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { //DEFINITELY FIX THIS PART. Something is wrong with how these two functions handle the drawing of my npc to the scene. //this.draw(b, position, layerDepth); b.Draw(this.currentSprite.sprite.Texture, position, this.currentSprite.sprite.sourceRect, color, 0.0f, origin, scale, effects, layerDepth); //b.Draw(this.Sprite.Texture, npc.getLocalPosition(Game1.viewport) + new Vector2((float)(this.sprite.spriteWidth * Game1.pixelZoom / 2), (float)(this.GetBoundingBox().Height / 2)) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(this.Sprite.SourceRect), Color.White * alpha, this.rotation, new Vector2((float)(this.sprite.spriteWidth / 2), (float)((double)this.sprite.spriteHeight * 3.0 / 4.0)), Math.Max(0.2f, this.scale) * (float)Game1.pixelZoom, this.flip || this.sprite.currentAnimation != null && this.sprite.currentAnimation[this.sprite.currentAnimationIndex].flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.991f : (float)this.getStandingY() / 10000f)); }
/// <summary>A very verbose asset drawer.</summary> public override void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { //Class1.ModMonitor.Log(sourceRectangle.ToString()); Vector2 generalOffset = new Vector2(0, 1 * Game1.tileSize); //Puts the sprite at the correct positioning. position -= new Vector2(0, 0.25f * Game1.tileSize); float smallOffset = 0.001f; float tinyOffset = 0.0001f; //Class1.ModMonitor.Log((position - generalOffset).ToString()); float num = Math.Max(0.0f, (float)(Math.Ceiling(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 600.0 + (double)npc.DefaultPosition.X * 20.0)) / 4.0)); this.body.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bodyColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset); this.eyes.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.eyeColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 1)); this.hair.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.hairColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 2)); if (num > 0.0f) { Vector2 shirtOffset = new Vector2((1 * Game1.tileSize) / 4, (1 * Game1.tileSize) / 4); this.shirt.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shirtColor), alpha, new Vector2(0.5f, 1), scale * Game1.pixelZoom + num, effects, layerDepth + smallOffset + (tinyOffset * 3)); } else { this.shirt.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shirtColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 3)); } this.pants.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bottomsColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 4)); this.shoes.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shoesColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 5)); foreach (var accessory in this.accessories) { accessory.draw(b, npc, position - generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + 0.0006f); } }
/// <summary>Use this to add a new npc into the game.</summary> /// <param name="loc">The game location to add the npc to.</param> /// <param name="npc">The extended npc to add to the location.</param> public void addNewNpcToLocation(GameLocation loc, ExtendedNpc npc) { this.moddedNpcs.Add(npc); npc.defaultLocation = loc; npc.currentLocation = loc; loc.addCharacter(npc); }
/// <summary>Add a npc to a location.</summary> /// <param name="loc">The game location to add an npc to.</param> /// <param name="npc">The extended npc to add to the location.</param> /// <param name="tilePosition">The tile position at the game location to add the mpc to.</param> public void addNewNpcToLocation(GameLocation loc, ExtendedNpc npc, Vector2 tilePosition) { this.moddedNpcs.Add(npc); npc.defaultLocation = loc; npc.currentLocation = loc; npc.position.Value = tilePosition * Game1.tileSize; loc.addCharacter(npc); }
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { // TODO Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE ExtendedNpc myNpc3 = assetPool.generateNPC(Genders.female, 0, 1, new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null)); MerchantNpc merch = new MerchantNpc(new List <Item>() { new StardewValley.Object(475, 999) }, myNpc3); npcTracker.addNewNpcToLocation(Game1.getLocationFromName("BusStop", false), merch, new Vector2(2, 23)); }
/// <summary>Wrapper for a draw function that accepts rectangles to be null.</summary> public virtual void draw(SpriteBatch b, ExtendedNpc extendedNPC, Vector2 position, Rectangle?v1, Color white, float rotation, Vector2 origin, float scale, SpriteEffects spriteEffects, float v3) { this.draw(b, extendedNPC, position, new Rectangle(0, 0, 16, 32), white, rotation, origin, scale, spriteEffects, v3); }
/// <summary>A very verbose asset drawer.</summary> public virtual void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { this.currentAnimation.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); }
/// <summary>Sets the npc's portrait to be this portrait texture.</summary> public void setCharacterPortraitFromThis(ExtendedNpc npc) { npc.Portrait = this.portrait; }
/// <summary>A very verbose asset drawer.</summary> public virtual void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { }
/// <summary>Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc.</summary> public void setUp(ExtendedNpc npc) { npc.characterRenderer?.setUp(); }
/// <summary>Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc.</summary> public void setRight(ExtendedNpc npc) { npc.characterRenderer?.setRight(); }
/// <summary>Sets the npc's portrait to be this portrait texture.</summary> public void setCharacterSpriteFromThis(ExtendedNpc npc) { npc.Sprite = this.sprite; }
/// <summary>Use this to completly remove and npc from the game as it is removed from the location and is no longer tracked.</summary> /// <param name="npc">The npc to remove from the location.</param> public void removeFromLocationAndTrackingList(ExtendedNpc npc) { npc.currentLocation?.characters.Remove(npc); this.moddedNpcs.Remove(npc); }
/// <summary>Use this simply to remove a single npc from a location.</summary> public void removeCharacterFromLocation(GameLocation loc, ExtendedNpc npc) { loc.characters.Remove(npc); }