So I dont have access to spritebatchinstance, can't I use the method I created instead,…
- User
So I dont have access to spritebatchinstance, can't I use the method I created instead, I want to add the whitepixel method within the defaulthitplayer method
using System; using System.Runtime.CompilerServices; using Box2D.XNA; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using SFD.Effects; using SFD.Materials; using SFD.Sounds; using SFD.Weapons; using SFDGameScriptInterface;
namespace SFD.Projectiles { // Token: 0x020003EF RID: 1007 public abstract partial class Projectile : NetMessageCount { // Inside your Projectile class or a relevant class where you want to draw the pixel public Texture2D CreateWhitePixelTexture(GraphicsDevice graphicsDevice) { // Create a 1x1 texture Texture2D texture = new Texture2D(graphicsDevice, 1, 1, false, SurfaceFormat.Color); // Set the pixel to white texture.SetData(new[] { Color.White }); return texture; }
codepublic void DrawWhitePixel(SpriteBatch spriteBatch, Vector2 position, float scale) { if (spriteBatch == null) throw new ArgumentNullException(nameof(spriteBatch)); Texture2D whitePixel = CreateWhitePixelTexture(spriteBatch.GraphicsDevice); // Begin the sprite batch spriteBatch.Begin(); // Draw the white pixel texture at the specified position and scale spriteBatch.Draw(whitePixel, position, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f); // End the sprite batch spriteBatch.End(); } // Token: 0x06004142 RID: 16706 RVA: 0x00111078 File Offset: 0x0010F278 protected void DefaultHitPlayer(Player player, ObjectData playerObjectData) { if (this.GameOwner != GameOwnerEnum.Client) { player.TakeProjectileDamage(this); Material material = player.GetPlayerHitMaterial(); if (material == null) { material = playerObjectData.Tile.Material; } SoundHandler.PlaySound(material.Hit.Projectile.HitSound, this.GameWorld); EffectHandler.PlayEffect(material.Hit.Projectile.HitEffect, this.Position, this.GameWorld); EffectHandler.PlayEffect("BulletHit", this.Position, this.GameWorld); // Draw the white pixel at the player's position DrawWhitePixel(spriteBatchInstance, player.Position, 1.0f); } } } - Assistant
- User
No mean just do what I told you I dont have access to that I am using dnspy
- Assistant
DnSpy is a tool used for .NET assembly editing and debugging. If you're using DnSpy and you want to modify the compiled code to include sprite drawing functionality directly inside the
DefaultHitPlayermethod, you need to work within certain limitations.However, if you're not able to directly access the instance from within , then you can't draw using that object. Presumably, the instance is created and managed elsewhere in the code, and it's typically only available during the method of a game component.