Esempio n. 1
0
    private void TurnOff(
        AppearanceComponent component,
        EnergySwordStatus status,
        IEntityManager entManager,
        SpriteComponent?spriteComponent = null)
    {
        if (entManager.TryGetComponent(component.Owner, out SharedItemComponent? itemComponent))
        {
            itemComponent.EquippedPrefix = "off";
        }

        if ((status & EnergySwordStatus.Hacked) != 0x0)
        {
            spriteComponent?.LayerSetState(0, "e_sword");
        }
        else
        {
            spriteComponent?.LayerSetVisible(1, false);
        }

        if (entManager.TryGetComponent(component.Owner, out PointLightComponent? pointLightComponent))
        {
            pointLightComponent.Enabled = false;
        }
    }
Esempio n. 2
0
    private void SetOnFire(SpriteComponent sprite, AppearanceComponent appearance, FireVisualsComponent component, bool onFire, float fireStacks)
    {
        if (component.Sprite != null)
        {
            sprite.LayerSetRSI(FireVisualLayers.Fire, component.Sprite);
        }

        sprite.LayerSetVisible(FireVisualLayers.Fire, onFire);

        if (fireStacks > component.FireStackAlternateState && !string.IsNullOrEmpty(component.AlternateState))
        {
            sprite.LayerSetState(FireVisualLayers.Fire, component.AlternateState);
        }
        else
        {
            sprite.LayerSetState(FireVisualLayers.Fire, component.NormalState);
        }
    }
        /// <summary>
        /// Illuminates the light if it is not active, extinguishes it if it is active.
        /// </summary>
        /// <returns>True if the light's status was toggled, false otherwise.</returns>
        public bool ToggleStatus()
        {
            // Update the activation state.
            Activated = !Activated;

            // Update sprite and light states to match the activation.
            if (Activated)
            {
                spriteComponent.LayerSetState(0, "lantern_on");
                pointLight.State = LightState.On;
            }
            else
            {
                spriteComponent.LayerSetState(0, "lantern_off");
                pointLight.State = LightState.Off;
            }

            // Toggle always succeeds.
            return(true);
        }
Esempio n. 4
0
        private void SetTool()
        {
            if (_tool == null)
            {
                return;
            }

            var current = _tools[_currentTool];

            _tool.UseSound           = current.Sound;
            _tool.UseSoundCollection = current.SoundCollection;
            _tool.Qualities          = current.Behavior;

            if (_sprite == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(current.Texture))
            {
                if (!string.IsNullOrEmpty(current.Sprite))
                {
                    _sprite.LayerSetState(0, current.State, current.Sprite);
                }
                else
                {
                    _sprite.LayerSetState(0, current.State);
                }
            }
            else
            {
                _sprite.LayerSetTexture(0, current.Texture);
            }

            Dirty();
        }
Esempio n. 5
0
    private void TurnOn(
        AppearanceComponent component,
        EnergySwordStatus status,
        Color color,
        IEntityManager entManager,
        SpriteComponent?spriteComponent = null)
    {
        if ((status & EnergySwordStatus.Hacked) != 0x0)
        {
            if (entManager.TryGetComponent(component.Owner, out SharedItemComponent? itemComponent))
            {
                itemComponent.EquippedPrefix = "on-rainbow";
            }

            //todo: figure out how to use the RGBLightControllerSystem to phase out the rainbow sprite AND add lights.
            spriteComponent?.LayerSetColor(1, Color.White);
            spriteComponent?.LayerSetVisible(1, false);
            spriteComponent?.LayerSetState(0, "e_sword_rainbow_on");
        }
        else
        {
            if (entManager.TryGetComponent(component.Owner, out SharedItemComponent? itemComponent))
            {
                itemComponent.EquippedPrefix = "on";
                itemComponent.Color          = color;
            }

            spriteComponent?.LayerSetColor(1, color);
            spriteComponent?.LayerSetVisible(1, true);

            if (entManager.TryGetComponent(component.Owner, out PointLightComponent? pointLightComponent))
            {
                pointLightComponent.Color   = color;
                pointLightComponent.Enabled = true;
            }
        }
    }
Esempio n. 6
0
 private void MakeBroken()
 {
     _status = GravityGeneratorStatus.Broken;
     _sprite.LayerSetState(0, "broken");
     _sprite.LayerSetVisible(1, false);
 }