4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Graphics;
6 using System.Collections.Generic;
12 private bool? lastReceivedState;
14 private CoroutineHandle resetPredictionCoroutine;
15 private float resetPredictionTimer;
22 private float lightColorMultiplier;
24 [Serialize(1.0f,
IsPropertySaveable.Yes, description:
"The scale of the light sprite.")]
40 partial
void SetLightSourceState(
bool enabled,
float brightness)
42 if (
Light ==
null) {
return; }
45 lightColorMultiplier = brightness;
52 partial
void SetLightSourceTransformProjSpecific()
58 else if (turret !=
null)
71 if (body !=
null && body.Enabled)
73 Light.
Rotation = body.Dir > 0.0f ? body.DrawRotation : body.DrawRotation - MathHelper.Pi;
83 public void Draw(SpriteBatch spriteBatch,
bool editing =
false,
float itemDepth = -1, Color? overrideColor =
null)
85 if (
Light?.LightSprite ==
null) {
return; }
94 Color color = lightColor;
100 new Vector2(drawPos.X, -drawPos.Y),
101 color * lightBrightness,
109 public override void FlipX(
bool relativeToSub)
114 SpriteEffects.FlipHorizontally : SpriteEffects.None;
116 SetLightSourceTransformProjSpecific();
119 partial
void OnStateChanged()
121 if (
GameMain.
Client ==
null || !lastReceivedState.HasValue) {
return; }
123 resetPredictionTimer = 1.0f;
124 if (resetPredictionCoroutine ==
null || !CoroutineManager.IsCoroutineRunning(resetPredictionCoroutine))
126 resetPredictionCoroutine = CoroutineManager.StartCoroutine(ResetPredictionAfterDelay());
133 private IEnumerable<CoroutineStatus> ResetPredictionAfterDelay()
135 while (resetPredictionTimer > 0.0f)
137 resetPredictionTimer -= CoroutineManager.DeltaTime;
138 yield
return CoroutineStatus.Running;
140 if (lastReceivedState.HasValue) {
IsActive = lastReceivedState.Value; }
141 resetPredictionCoroutine =
null;
142 yield
return CoroutineStatus.Success;
153 base.RemoveComponentSpecific();
virtual Vector2 DrawPosition
override Vector2? Position
SpriteEffects SpriteEffects
override bool CanSpriteFlipX
override void RemoveComponentSpecific()
void ClientEventRead(IReadMessage msg, float sendingTime)
void Draw(SpriteBatch spriteBatch, bool editing=false, float itemDepth=-1, Color? overrideColor=null)
override void FlipX(bool relativeToSub)
override void OnScaleChanged()
Vector2 TransformedBarrelPos
float? OverrideLightSpriteAlpha
SpriteEffects LightSpriteEffect
bool IsHidden
Is the entity hidden due to HiddenInGame being enabled or the layer the entity is in being hidden?
void Draw(ISpriteBatch spriteBatch, Vector2 pos, float rotate=0.0f, float scale=1.0f, SpriteEffects spriteEffect=SpriteEffects.None)
Interface for entities that the server can send events to the clients