2 using Microsoft.Xna.Framework;
3 using Microsoft.Xna.Framework.Graphics;
8 partial class ElectricalDischarger : Powered
10 private static SpriteSheet electricitySprite;
12 private int frameOffset;
14 partial
void InitProjSpecific()
16 if (electricitySprite ==
null)
18 electricitySprite =
new SpriteSheet(
"Content/Lights/Electricity.png", 4, 4,
new Vector2(0.5f, 0.0f));
22 partial
void DischargeProjSpecific()
25 foreach (Node node
in nodes)
27 GameMain.ParticleManager.CreateParticle(
"swirlysmoke", node.WorldPosition, Vector2.Zero);
29 if (node.ParentIndex > -1)
31 CreateParticlesBetween(nodes[node.ParentIndex].WorldPosition, node.WorldPosition);
34 foreach (var character
in charactersInRange)
36 CreateParticlesBetween(character.character.WorldPosition, character.node.WorldPosition);
39 static void CreateParticlesBetween(Vector2 start, Vector2 end)
41 const float ParticleInterval = 50.0f;
42 Vector2 diff = end - start;
43 float dist = diff.Length();
44 Vector2 normalizedDiff = MathUtils.NearlyEqual(dist, 0.0f) ? Vector2.Zero : diff / dist;
45 for (
float x = 0.0f; x < dist; x += ParticleInterval)
47 var spark = GameMain.ParticleManager.CreateParticle(
"ElectricShock", start + normalizedDiff * x, Vector2.Zero);
58 if (timer <= 0.0f &&
Screen.
Selected is { IsEditor: false }) {
return; }
59 for (
int i = 0; i < nodes.Count; i++)
61 if (nodes[i].Length <= 1.0f) {
continue; }
63 electricitySprite.Draw(spriteBatch,
64 (i + frameOffset) % electricitySprite.FrameCount,
65 new Vector2(node.WorldPosition.X, -node.WorldPosition.Y),
66 Color.Lerp(Color.LightBlue, Color.White, Rand.Range(0.0f, 1.0f)),
67 electricitySprite.Origin, -node.Angle - MathHelper.PiOver2,
69 Math.Min(node.Length / electricitySprite.FrameSize.X, 1.0f) * Rand.Range(0.5f, 2.0f),
70 node.Length / electricitySprite.FrameSize.Y) * Rand.Range(1.0f, 1.2f));
75 for (
int i = 1; i < nodes.Count; i++)
77 GUI.DrawLine(spriteBatch,
78 new Vector2(nodes[i].WorldPosition.X, -nodes[i].WorldPosition.Y),
79 new Vector2(nodes[nodes[i].ParentIndex].WorldPosition.X, -nodes[nodes[i].ParentIndex].WorldPosition.Y),
83 if (nodes[i].Length <= 1.0f) {
continue; }
84 GUI.DrawRectangle(spriteBatch,
new Vector2(nodes[i].WorldPosition.X, -nodes[i].WorldPosition.Y), Vector2.One * 10, Color.LightCyan, isFilled:
true);
const ushort NullEntityID
static Entity FindEntityByID(ushort ID)
Find an entity based on the ID
void DrawElectricity(SpriteBatch spriteBatch)
void ClientEventRead(IReadMessage msg, float sendingTime)
void PlaySound(ActionType type, Character user=null)
float CurrPowerConsumption
float powerConsumption
The maximum amount of power the item can draw from connected items
ActionType
ActionTypes define when a StatusEffect is executed.