public override void PostAI() { base.PostAI(); if (projectile.light != 0) { light = projectile.light; projectile.light = 0; } if (manualRotation) { projectile.rotation = rotation; } if (trailLength > 1) { for (int i = trailLength - 1; i > 0; i--) { projectile.oldRot[i] = projectile.oldRot[i - 1]; } } if (trailLength > 0) { projectile.oldRot[0] = projectile.rotation; } PaintMethods method = getPaintMethod(); if (xFrameCount > 1 && (animationFrameDuration == 0 || projectile.timeLeft % animationFrameDuration == 0)) { nextFrame(method); } if (!usesShader) { updateColorFrame(method); } createLight(); }
//This is where the painted buff is applied to NPCs that the item hits with melee public override void OnHitNPC(Player p, NPC target, int damage, float knockBack, bool crit) { WoMDNPC npc = target.GetGlobalNPC <WoMDNPC>(); if (npc != null && p != null && item.owner == Main.myPlayer) { WoMDPlayer player = p.GetModPlayer <WoMDPlayer>(); PaintMethods method = overridePaintMethod(player); if (method != PaintMethods.None) { if (method == PaintMethods.RemovePaint) { npc.painted = false; int index = target.FindBuffIndex(BuffType <Painted>()); if (index >= 0) { target.DelBuff(index); } } else { applyPaintedToNPC(target, new PaintData(npcCyclingTimeScale, player.paintData.PaintColor, player.paintData.CustomPaint, player.paintData.CustomPaint is ISprayPaint, Main.GlobalTime, player: player.player)); } } } }
/// <summary> /// Can be used to convert the current colorFrame into a different index. This is useful for projectiles that use the GSShader. /// </summary> /// <param name="method"></param> /// <returns></returns> protected virtual int convertColorFrame(PaintMethods method) { switch (yFrameCount) { case 2: if (method == PaintMethods.RemovePaint || colorFrame == 0) { return(0); } return(1); case 3: if (method == PaintMethods.RemovePaint) { return(1); } if (colorFrame == 0) { return(0); } return(2); } if (method == PaintMethods.RemovePaint) { return(0); } return(colorFrame); }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { WoMDNPC npc = target.GetGlobalNPC <WoMDNPC>(); WoMDPlayer player = getModPlayer(projectile.owner); if (npc != null && player != null) { PaintMethods method = player.paintData.paintMethod; if (method != PaintMethods.None) { if (method == PaintMethods.RemovePaint) { npc.painted = false; int index = target.FindBuffIndex(BuffType <Painted>()); if (index >= 0) { target.DelBuff(index); } } else { applyPaintedToNPC(target, new PaintData(npcCyclingTimeScale, player.paintData.PaintColor, player.paintData.CustomPaint, player.paintData.CustomPaint is ISprayPaint, Main.GlobalTime, player: player.player)); } } } if (projectile.penetrate == 1) { onKillOnNPC(target); } }
private void updateCanvasWachtrijen(object sender, ElapsedEventArgs e) { App.Current.Dispatcher.Invoke((Action) delegate { PaintMethods.paintWachtrij(canvasWachtrijInstructie, wachtrijInstructie.GetAlleSporters()); PaintMethods.paintWachtrij(canvasInstructie, instructieGroep.GetAlleSporters()); PaintMethods.paintWachtrij(canvasWachtrijStarten, wachtrijStarten.GetAlleSporters()); }); }
/// <summary> /// Updates the colorFrame property /// </summary> public void updateColorFrame(PaintMethods method) { if (npcOwner == -1) { WoMDPlayer player = getModPlayer(projectile.owner); if (player != null) { if (player.paintData.PaintColor == -1 && player.paintData.CustomPaint == null) { colorFrame = 0; } else if (player.paintData.CustomPaint == null) { colorFrame = (byte)player.paintData.PaintColor; } else { colorFrame = player.paintData.CustomPaint.getPaintID(player.paintData); } } } else { NPC npc = getNPC(npcOwner); if (npc == null) { return; } WoMDNPC gNpc = npc.GetGlobalNPC <WoMDNPC>(); if (gNpc == null) { return; } PaintData data = gNpc.paintData; if (data == null) { colorFrame = 0; } else { if (data.PaintColor == -1 && data.CustomPaint == null) { colorFrame = 0; } else if (data.CustomPaint == null) { colorFrame = (byte)data.PaintColor; } else { colorFrame = data.CustomPaint.getPaintID(data); } } } updateFrame(method); }
/// <summary> /// Updates the frame property based on the current animationFrame and colorFrame /// </summary> /// <param name="method"></param> public void updateFrame(PaintMethods method) { if (usesShader) { frame = animationFrame; } else { frame = convertColorFrame(method) * xFrameCount + animationFrame; } }
/// <summary> /// Advances the animation frame, wrapping back to frame 0 if necessary /// </summary> public void nextFrame(PaintMethods method) { if (xFrameCount == 1) { return; } animationFrame++; if (animationFrame >= xFrameCount) { animationFrame = 0; } updateFrame(method); }
/// <summary> /// Gets the name for a type of painting tool based on a provided paint method /// </summary> /// <param name="paintMethod"></param> /// <returns></returns> public static string getPaintToolName(PaintMethods paintMethod) { switch (paintMethod) { case PaintMethods.Blocks: return("Paintbrush"); case PaintMethods.Walls: return("Paint Roller"); case PaintMethods.BlocksAndWalls: return("Painting Multi-Tool"); case PaintMethods.RemovePaint: return("Paint Scraper"); } return("None"); }
public static void readPPOverrideDataPacket(BinaryReader reader, out PaintingProjectile projectile) { projectile = null; int projId = reader.ReadInt32(); int projType = reader.ReadInt32(); int paintColor = reader.ReadInt32(); string customPaintName = reader.ReadString(); float timeScale = (float)reader.ReadDouble(); float timeOffset = (float)reader.ReadDouble(); bool sprayPaint = reader.ReadBoolean(); string method = reader.ReadString(); Projectile proj = getProjectile(projId); if (proj != null && proj.type == projType) { projectile = proj.modProjectile as PaintingProjectile; if (projectile != null) { CustomPaint customPaint = customPaintName == "null" ? null : (CustomPaint)Activator.CreateInstance(Type.GetType("WeaponsOfMassDecoration.Items." + customPaintName)); PaintMethods paintMethod = (PaintMethods)Enum.Parse(typeof(PaintMethods), method); projectile._overridePaintData = new PaintData(timeScale, paintColor, customPaint, sprayPaint, timeOffset, paintMethod); } } }
private void updateWaterskibaanCanvas(object sender, ElapsedEventArgs e) { App.Current.Dispatcher.Invoke((Action) delegate { PaintMethods.paintWaterskibaanCanvas(canvasWaterskibaan, waterskibaan); }); }