public override void Process(Entity entity) { Entity player = (Entity)BlackBoard.GetEntry("Player"); CollisionBox playerBox = player.GetComponent<CollisionBox>(); Position playerPosition = player.GetComponent<Position>(); Rectangle playerRectangle = new Rectangle( (int)playerPosition.X + playerBox.OffsetX, (int)playerPosition.Y + playerBox.OffsetY, playerBox.Width, playerBox.Height); CollisionBox enemyBox = entity.GetComponent<CollisionBox>(); Position enemyPosition = entity.GetComponent<Position>(); Rectangle enemyRectangle = new Rectangle( (int)enemyPosition.X + enemyBox.OffsetX, (int)enemyPosition.Y + enemyBox.OffsetY, enemyBox.Width, enemyBox.Height); var type = playerRectangle.GetCollisionType(enemyRectangle); if (type == CollisionType.None || !entity.HasComponent<Script>()) return; Script script = entity.GetComponent<Script>(); _scriptManager.QueueScript(script.FilePath, entity, "OnTouch"); }
public override void Process(Entity entity) { if (!entity.HasComponent<Heartbeat>()) return; Heartbeat hb = entity.GetComponent<Heartbeat>(); if (hb.Interval <= 0.0f) return; hb.CurrentTimer += _world.DeltaSeconds(); if (!(hb.CurrentTimer >= hb.Interval)) return; if (entity.HasComponent<Script>()) { Script script = entity.GetComponent<Script>(); _scriptManager.QueueScript(script.FilePath, entity, "OnHeartbeat"); } hb.CurrentTimer = 0.0f; }
public static void SetColorPaletteCustom(Entity entity, int red, int green, int blue, int alpha) { if (entity.HasComponent<Sprite>()) { entity.GetComponent<Sprite>().SetColorOverride(red, green, blue, alpha); } }
public static void ResetColorPalette(Entity entity) { if (entity.HasComponent<Sprite>()) { entity.GetComponent<Sprite>().RemoveColorOverride(); } }
public static void SetColorPalette(Entity entity, ColorType color) { if (entity.HasComponent<Sprite>()) { ColorTypeAttribute attr = color.GetAttributeOfType<ColorTypeAttribute>(); entity.GetComponent<Sprite>().SetColorOverride(attr.Red, attr.Green, attr.Blue, attr.Alpha); } }