private void ServerToggleState(HandActivate interaction)
    {
        isActivated = !isActivated;         // This runs SyncState, which sets itemAttributes on clients
        var lightColor = GetLightSourceColor(color);

        lightControl.SetColor(lightColor);
        lightControl.Toggle(isActivated);

        if (isActivated)
        {
            SetActivatedAttributes();
            spriteHandler.ChangeSprite((int)color);
            itemAttributes.SetSprites(GetItemSprites(color));
        }
        else
        {
            SetDeactivatedAttributes();
            spriteHandler.ChangeSprite(0);
            itemAttributes.SetSprites(Sprites.Off);
        }

        SoundManager.PlayNetworkedAtPos(
            isActivated ? saberon : saberoff, gameObject.AssumedWorldPosServer());
        StartCoroutine(DelayCharacterSprite(interaction));
    }
 public override void SyncSprite(ClosetStatus value)
 {
     //Logger.Log("TTTTTTTTTTTTT" + value.ToString());
     if (value == ClosetStatus.Open)
     {
         if (!powered)
         {
             spriteHandler.ChangeSprite(5);
         }
         else
         {
             spriteHandler.ChangeSprite(3);
         }
     }
     else if (!powered)
     {
         spriteHandler.ChangeSprite(6);
     }
     else if (value == ClosetStatus.Closed)
     {
         spriteHandler.ChangeSprite(0);
     }
     else if (value == ClosetStatus.ClosedWithOccupant)
     {
         spriteHandler.ChangeSprite(2);
     }
 }
    public void ServerPerformInteraction(HandActivate interaction)
    {
        isActivated = !isActivated;         // This runs SyncState, which sets itemAttributes on clients
        var lightColor = GetLightSourceColor(color);

        lightControl.SetColor(lightColor);
        lightControl.Toggle(isActivated);

        if (isActivated)
        {
            SetActivatedAttributes();
            spriteHandler.ChangeSprite((int)color);
            itemAttributes.SetSprites(GetItemSprites(color));
        }
        else
        {
            SetDeactivatedAttributes();
            spriteHandler.ChangeSprite(0);
            itemAttributes.SetSprites(Sprites.Off);
        }

        SoundManager.PlayNetworkedAtPos(
            isActivated ? saberon : saberoff, gameObject.AssumedWorldPosServer());

        PlayerAppearanceMessage.SendToAll(interaction.Performer, (int)interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), gameObject);
    }
        private void OnContainerExploded()
        {
            if (IsConnected)
            {
                DisconnectFromConnector();
            }

            if (HasContainerInserted)
            {
                EjectInsertedContainer();
            }

            baseSpriteHandler.ChangeSprite(BURST_SPRITE);
            if (canisterTier > 0)             // Tier overlays only for above 0.
            {
                int burstTier = canisterTierOverlay.CataloguePage + (canisterTierOverlay.CatalogueCount / 2);
                canisterTierOverlay.ChangeSprite(burstTier);
            }
            pressureIndicatorOverlay.PushClear();
            connectorHoseOverlay.PushClear();
            tankInsertedOverlay.PushClear();
            openValveOverlay.PushClear();

            hasBurst = true;
        }
Beispiel #5
0
        /// <summary>
        /// Update Loop, runs every 1 second
        /// </summary>
        private void EmitterUpdate()
        {
            if (CustomNetworkManager.IsServer == false)
            {
                return;
            }

            if (isOn == false && alwaysShoot == false)
            {
                return;
            }

            if (voltage < minVoltage && alwaysShoot == false)
            {
                spriteHandler.ChangeSprite(2);
                return;
            }

            //Reset sprite if power is now available
            TogglePower(isOn);

            //Shoot 75% of the time, to add variation
            if (DMMath.Prob(25))
            {
                return;
            }

            ShootEmitter();
        }
Beispiel #6
0
        private void Start()
        {
            //temp stuff

            if (IsLavaLandBase1)
            {
                LavaLandManager.Instance.LavaLandBase1 = this;
            }

            if (IsLavaLandBase2)
            {
                LavaLandManager.Instance.LavaLandBase2 = this;
            }

            if (IsLavaLandBase1Connector)
            {
                LavaLandManager.Instance.LavaLandBase1Connector = this;
            }

            if (IsLavaLandBase2Connector)
            {
                LavaLandManager.Instance.LavaLandBase2Connector = this;
            }

            spriteHandler.ChangeSprite(0);
        }
Beispiel #7
0
        /// <summary>
        /// Stage 1, Add cable to continue or welder to destroy frame.
        /// </summary>
        /// <param name="interaction"></param>
        private void InitialStateInteraction(HandApply interaction)
        {
            if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Cable) &&
                Validations.HasUsedAtLeast(interaction, 5))
            {
                //add 5 cables
                ToolUtils.ServerUseToolWithActionMessages(interaction, 2f,
                                                          "You start adding cables to the frame...",
                                                          $"{interaction.Performer.ExpensiveName()} starts adding cables to the frame...",
                                                          "You add cables to the frame.",
                                                          $"{interaction.Performer.ExpensiveName()} adds cables to the frame.",
                                                          () =>
                {
                    Inventory.ServerConsume(interaction.HandSlot, 5);
                    stateful.ServerChangeState(cablesAddedState);

                    spriteHandler.ChangeSprite((int)SpriteStates.BoxCable);
                });
            }
            else if (Validations.HasUsedActiveWelder(interaction))
            {
                //deconsruct
                ToolUtils.ServerUseToolWithActionMessages(interaction, 2f,
                                                          "You start deconstructing the frame...",
                                                          $"{interaction.Performer.ExpensiveName()} starts deconstructing the frame...",
                                                          "You deconstruct the frame.",
                                                          $"{interaction.Performer.ExpensiveName()} deconstructs the frame.",
                                                          () =>
                {
                    Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, SpawnDestination.At(gameObject), 5);
                    _ = Despawn.ServerSingle(gameObject);
                });
            }
        }
Beispiel #8
0
    private void ClientUpdateSprite()
    {
        if (activated)
        {
            switch ((SwordColor)color)
            {
            case SwordColor.Blue:
                itemAttributes.SetSprites(Sprites.Blue);
                break;

            case SwordColor.Green:
                itemAttributes.SetSprites(Sprites.Green);
                break;

            case SwordColor.Purple:
                itemAttributes.SetSprites(Sprites.Purple);
                break;

            case SwordColor.Rainbow:
                itemAttributes.SetSprites(Sprites.Rainbow);
                break;

            case SwordColor.Red:
                itemAttributes.SetSprites(Sprites.Red);
                break;
            }

            spriteHandler?.ChangeSprite(color, false);
        }
        else
        {
            itemAttributes.SetSprites(Sprites.Off);
            spriteHandler?.ChangeSprite(0, false);
        }
    }
Beispiel #9
0
        public IEnumerator PlayOpeningAnimation(bool skipAnimation = false, bool panelExposed = false, bool lights = true)
        {
            if (skipAnimation == false)
            {
                if (panelExposed)
                {
                    overlayHackingHandler.ChangeSprite((int)Panel.Opening, false);
                }

                if (lights)
                {
                    overlayLightsHandler.ChangeSprite((int)Lights.Opening, false);
                }
                overlayFillHandler.ChangeSprite((int)DoorFrame.Opening, false);
                doorBaseHandler.ChangeSprite((int)DoorFrame.Opening, false);
                ClientPlaySound(openingSFX);
                yield return(WaitFor.Seconds(openingAnimationTime));
            }

            // Change to open sprite after done opening
            if (panelExposed)
            {
                overlayHackingHandler.ChangeSprite((int)Panel.Open, false);
            }
            else
            {
                overlayHackingHandler.ChangeSprite((int)Panel.NoPanel, false);
            }

            overlayLightsHandler.ChangeSprite((int)Lights.NoLight, false);
            overlayFillHandler.ChangeSprite((int)DoorFrame.Open, false);
            doorBaseHandler.ChangeSprite((int)DoorFrame.Open, false);

            AnimationFinished?.Invoke();
        }
Beispiel #10
0
        private void UpdatePhase(EggState state)
        {
            currentState = state;

            switch (currentState)
            {
            case EggState.Growing:
                spriteHandler.ChangeSprite(SMALL_SPRITE);
                StopAllCoroutines();
                StartCoroutine(GrowEgg());
                break;

            case EggState.Grown:
                spriteHandler.ChangeSprite(BIG_SPRITE);
                StopAllCoroutines();
                StartCoroutine(HatchEgg());
                break;

            case EggState.Burst:
                spriteHandler.ChangeSprite(HATCHED_SPRITE);
                registerObject.Passable = true;
                break;

            case EggState.Squished:
                spriteHandler.ChangeSprite(SQUISHED_SPRITE);
                break;
            }

            UpdateExamineMessage();
        }
 private void UpdateSprites()
 {
     if (IsOn)
     {
         if (Voltage < 2700)
         {
             spriteHandler.ChangeSprite((int)SpriteState.GeneratorOffBr);
         }
         else if (Voltage >= 2700)
         {
             ResistanceSourceModule.Resistance = 50f;
             if (!connectedToOther)
             {
                 spriteHandler.ChangeSprite((int)SpriteState.GeneratorOnBr);
             }
             else
             {
                 spriteHandler.ChangeSprite((int)SpriteState.GeneratorOn);
             }
         }
     }
     else
     {
         spriteHandler.ChangeSprite((int)SpriteState.GeneratorOff);
     }
 }
Beispiel #12
0
        public void RefreshPressureIndicator()
        {
            var pressure = GasContainer.ServerInternalPressure;

            if (pressure >= 40 * ONE_ATMOSPHERE)
            {
                pressureIndicatorOverlay.ChangeSprite((int)PressureIndicatorState.Green);
            }
            else if (pressure >= 10 * ONE_ATMOSPHERE)
            {
                pressureIndicatorOverlay.ChangeSprite((int)PressureIndicatorState.Yellow);
            }
            else if (pressure >= 5 * ONE_ATMOSPHERE)
            {
                pressureIndicatorOverlay.ChangeSprite((int)PressureIndicatorState.Red);
            }
            else if (pressure >= 10)
            {
                pressureIndicatorOverlay.ChangeSprite((int)PressureIndicatorState.RedFlashing);
            }
            else
            {
                pressureIndicatorOverlay.PushClear();
            }
        }
Beispiel #13
0
    public void ToggleTypingIcon(bool toggle)
    {
        if (toggle)
        {
            spriteHandler.gameObject.SetActive(true);
            spriteHandler.ChangeSprite(TypingSprite);
            spriteHandler.PushTexture();

            // start coroutine to wait for TypingTimeout
            // if we didn't recived any change for so long - other player must be disconected
            if (coWaitToTurnOff != null)
            {
                StopCoroutine(coWaitToTurnOff);
            }
            coWaitToTurnOff = StartCoroutine(WaitToTurnOff(TypingTimeout));
        }
        else
        {
            spriteHandler.gameObject.SetActive(false);
            if (coWaitToTurnOff != null)
            {
                StopCoroutine(coWaitToTurnOff);
            }
        }
    }
 private void ToggleOn()
 {
     isOn = true;
     ApplyEffect();
     spriteHandler.ChangeSprite((int)SpriteState.On);
     pickupable.RefreshUISlotImage();
 }
        public void SetDoor(Door newState)
        {
            if (newState == doorState)
            {
                return;
            }

            doorState = newState;
            doorSpriteHandler.ChangeSprite((int)doorState);
            if (hideLockWhenOpened && lockState != Lock.NoLock)
            {
                lockSpritehandler.ChangeSprite((int)(IsOpen ? Lock.NoLock : lockState));
            }

            SoundManager.PlayNetworkedAtPos(IsOpen ? soundOnOpen : soundOnClose, registerObject.WorldPositionServer, sourceObj: gameObject);

            if (IsOpen)
            {
                ReleaseObjects();
            }
            else
            {
                CollectObjects();
            }
        }
Beispiel #16
0
        /// <summary>
        /// Uses one charge from the emag, returns true if successful
        /// </summary>
        public bool UseCharge(HandApply interaction)
        {
            Chat.AddActionMsgToChat(interaction,
                                    $"You wave the Emag over the {interaction.TargetObject.ExpensiveName()}'s electrical panel.",
                                    $"{interaction.Performer.ExpensiveName()} waves something over the {interaction.TargetObject.ExpensiveName()}'s electrical panel.");

            if (Charges > 0)
            {
                //if this is the first charge taken off, add recharge loop
                if (Charges >= startCharges)
                {
                    UpdateManager.Add(RegenerateCharge, rechargeTimeInSeconds);
                }

                SyncCharges(Charges, Charges - 1);
                if (Charges > 0)
                {
                    spriteHandler.ChangeSprite(ScaleChargesToSpriteIndex());
                }
                else
                {
                    _ = SoundManager.PlayNetworkedForPlayer(recipient: interaction.Performer, OutOfChargesSFXA, sourceObj: gameObject);
                    spriteHandler.Empty();
                }
                return(true);
            }
            return(false);
        }
Beispiel #17
0
        public IEnumerator ServerAnimation()
        {
            spriteHandler.ChangeSprite(1);
            yield return(WaitFor.Seconds(1f));

            spriteHandler.ChangeSprite(0);
            ServerSync(false);
        }
Beispiel #18
0
    public void Lock()
    {
        if (!CheckForSpriteRenderer())
        {
            return;
        }

        spriteHandler.ChangeSprite((int)LockState.Locked);
    }
 public void TurnOn()
 {
     if (toggleAffectsComponent)
     {
         meleeEffect.enabled = true;
     }
     weaponState = WeaponState.On;
     spriteHandler.ChangeSprite((int)WeaponState.On);
 }
Beispiel #20
0
        /// <summary>
        /// Set the mob sprite to the first alive sprite.
        /// </summary>
        public void SetToAlive(bool network = false)
        {
            if (spriteHandler == null)
            {
                Logger.LogWarning($"{nameof(SpriteHandler)} missing on {gameObject}!");
                return;
            }

            spriteHandler.ChangeSprite(aliveSpriteIndex, network);
        }
Beispiel #21
0
 private void UpdateChargingIndicator()
 {
     if (IsCharging)
     {
         chargingIndicator.ChangeSprite((int)ChargingOverlayState.Charging);
     }
     else
     {
         chargingIndicator.ChangeSprite((int)ChargingOverlayState.Discharging);
     }
 }
Beispiel #22
0
 private void UpdateSprite()
 {
     if (MachineOperating)
     {
         spriteHandler.ChangeSprite((int)SpriteState.Operating);
     }
     else
     {
         spriteHandler.ChangeSprite((int)SpriteState.Idle);
     }
 }
Beispiel #23
0
 private void UpdateSpriteOutletState()
 {
     if (massDriverOperating)
     {
         spriteHandler.ChangeSprite(1);
     }
     else
     {
         spriteHandler.ChangeSprite(0);
     }
 }
Beispiel #24
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     safety = !safety;
     if (safety)
     {
         spriteHandler.ChangeSprite((int)SpriteState.SafetyOn);
     }
     else
     {
         spriteHandler.ChangeSprite((int)SpriteState.SafetyOff);
     }
 }
Beispiel #25
0
        private IEnumerator RunLandingSequence()
        {
            GameObject targetReticule = landingSpriteHandler.gameObject;
            GameObject dropPod        = baseSpriteHandler.gameObject;

            // Initialise target reticule for animating.
            targetReticule.LeanAlpha(0.25f, 0);
            targetReticule.transform.localScale = Vector3.one * 1.5f;

            // Initialise drop pod sprite to the start of falling animation.
            baseSpriteHandler.ChangeSprite((int)BaseSprite.Falling, false);
            dropPod.transform.localScale = Vector3.zero;
            Vector3 localPos = dropPod.transform.localPosition;

            localPos.y = DROP_HEIGHT;
            dropPod.transform.localPosition = localPos;
            registerObject.Passable         = true;

            // ClosetControl initialises, redisplaying the door, so wait a frame...
            yield return(WaitFor.EndOfFrame);

            doorSpriteHandler.PushClear(false);

            // Begin the drop animation.
            dropPod.LeanScale(Vector3.one, TRAVEL_TIME);
            dropPod.LeanMoveLocalY(0, TRAVEL_TIME);

            // Animate the target reticule.
            targetReticule.LeanScale(Vector3Int.one, TRAVEL_TIME / 2);
            targetReticule.LeanRotateZ(-270, TRAVEL_TIME);
            targetReticule.LeanAlpha(0.75f, TRAVEL_TIME / 2);

            yield return(WaitFor.Seconds(TRAVEL_TIME));

            // Swap to stationary drop pod.
            if (IsServer)
            {
                closetControl.ServerToggleLocked(false);
            }
            baseSpriteHandler.ChangeSprite((int)BaseSprite.Stationary, false);
            doorSpriteHandler.PushTexture(false);
            landingSpriteHandler.PushClear(false);
            registerObject.Passable = false;

            // Create a small explosion to apply damage to objects underneath.
            var matrixInfo = MatrixManager.AtPoint(WorldPosition, IsServer);

            Explosion.StartExplosion(registerObject.LocalPosition, EXPLOSION_STRENGTH, matrixInfo.Matrix);

            isLanding = false;
        }
 private void UpdateSprite()
 {
     if (activated)
     {
         spriteHandler.ChangeSprite(12 + color);
         spriteHandler.Infos.SetVariant(color);
     }
     else
     {
         spriteHandler.ChangeSprite(12);
         spriteHandler.Infos.SetVariant(0);
     }
     pickupable.RefreshUISlotImage();
 }
Beispiel #27
0
        private void OnSecuredChanged()
        {
            if (securable.IsAnchored)
            {
                baseSpriteHandler.ChangeSprite((int)SpriteState.Off);
            }
            else
            {
                ToggleOff();
                baseSpriteHandler.ChangeSprite((int)SpriteState.Unsecured);
            }

            ElectricalManager.Instance.electricalSync.StructureChange = true;
        }
Beispiel #28
0
        private void ChangePowerState(bool newState)
        {
            hasPower = newState;

            UpdateGui();

            if (newState)
            {
                ChangeOnState(isOn);
                return;
            }

            spriteHandler.ChangeSprite(0);
        }
Beispiel #29
0
        private void SyncPhotocopierState(PhotocopierState newState)
        {
            photocopierState = newState;
            switch (newState)
            {
            case PhotocopierState.Idle:
                spriteHandler.ChangeSprite(0);
                break;

            case PhotocopierState.Production:
                spriteHandler.ChangeSprite(1);
                break;
            }
        }
Beispiel #30
0
        /// <summary>
        /// Toggles the light on and off depending on the "IsOn" bool from the "ItemLightControl" component
        /// </summary>
        public void ServerPerformInteraction(HandActivate interaction)
        {
            bool isOn = lightControl.IsOn;

            if (isOn)
            {
                lightControl.Toggle(false);
                spriteHandler.ChangeSprite((int)SpriteState.LightOff);
            }
            else
            {
                lightControl.Toggle(true);
                spriteHandler.ChangeSprite((int)SpriteState.LightOn);
            }
        }