Esempio n. 1
0
    public void ServerPerformInteraction(PositionalHandApply interaction)
    {
        if (reagentContainer.ReagentMixTotal < 1)
        {               //warning
            Chat.AddExamineMsg(interaction.Performer, "Your mop is dry!");
            return;
        }
        //server is performing server-side logic for the interaction
        //do the mopping
        void CompleteProgress()
        {
            Vector3Int worldPos   = interaction.WorldPositionTarget.RoundToInt();
            MatrixInfo matrixInfo = MatrixManager.AtPoint(worldPos, true);
            Vector3Int localPos   = MatrixManager.WorldToLocalInt(worldPos, matrixInfo);

            if (reagentContainer)
            {
                if (reagentContainer.MajorMixReagent == Water)
                {
                    matrixInfo.MetaDataLayer.Clean(worldPos, localPos, true);
                    reagentContainer.TakeReagents(reagentsPerUse);
                }
                else if (reagentContainer.MajorMixReagent == SpaceCleaner)
                {
                    matrixInfo.MetaDataLayer.Clean(worldPos, localPos, false);
                    reagentContainer.TakeReagents(reagentsPerUse);
                }
                else
                {
                    MatrixManager.ReagentReact(reagentContainer.TakeReagents(reagentsPerUse), worldPos);
                }
            }

            Chat.AddExamineMsg(interaction.Performer, "You finish mopping.");
        }

        //Start the progress bar:
        var bar = StandardProgressAction.Create(ProgressConfig, CompleteProgress)
                  .ServerStartProgress(interaction.WorldPositionTarget.RoundToInt(),
                                       useTime, interaction.Performer);

        if (bar)
        {
            Chat.AddActionMsgToChat(interaction.Performer,
                                    $"You begin to clean the floor with the {gameObject.ExpensiveName()}...",
                                    $"{interaction.Performer.name} begins to clean the floor with the {gameObject.ExpensiveName()}.");
        }
    }
Esempio n. 2
0
    IEnumerator BurnFuel()
    {
        int spriteIndex = 0;

        while (isBurning)
        {
            //Flame animation:
            flameRenderer.sprite = flameSprites[spriteIndex];
            spriteIndex++;
            if (spriteIndex == 2)
            {
                spriteIndex = 0;
            }

            //Server fuel burning:
            if (isServer)
            {
                //With the variable below, it takes about 3:40 minutes (or 220 seconds) for a emergency welding tool (starts with 10 fuel) to run dry. In /tg/ it would have taken about 4:30 minutes (or 270 seconds). - PM
                //Original variable below was 0.041f (emergency welder ran out after about 25 seconds with it). - PM
                reagentContainer.TakeReagents(0.005f);

                //Ran out of fuel
                if (FuelAmount <= 0f)
                {
                    SyncIsOn(isOn, false);
                }
            }

            yield return(WaitFor.Seconds(.1f));
        }
    }
Esempio n. 3
0
    public void ServerPerformInteraction(AimApply interaction)
    {
        //just in case
        if (reagentContainer == null)
        {
            return;
        }

        if (reagentContainer.CurrentCapacity < reagentsPerUse)
        {
            return;
        }

        Vector2           startPos     = gameObject.AssumedWorldPosServer();
        Vector2           targetPos    = new Vector2(Mathf.RoundToInt(interaction.WorldPositionTarget.x), Mathf.RoundToInt(interaction.WorldPositionTarget.y));
        List <Vector3Int> positionList = CheckPassableTiles(startPos, targetPos);

        StartCoroutine(Fire(positionList));

        Effect.PlayParticleDirectional(this.gameObject, interaction.TargetVector);

        reagentContainer.TakeReagents(reagentsPerUse);
        SoundManager.PlayNetworkedAtPos("Spray2", startPos, 1, sourceObj: interaction.Performer);

        interaction.Performer.Pushable()?.NewtonianMove((-interaction.TargetVector).NormalizeToInt(), speed: 1f);
    }
Esempio n. 4
0
    IEnumerator BurnFuel()
    {
        int spriteIndex = 0;

        while (isBurning)
        {
            //Flame animation:
            flameRenderer.sprite = flameSprites[spriteIndex];
            spriteIndex++;
            if (spriteIndex == 2)
            {
                spriteIndex = 0;
            }

            //Server fuel burning:
            if (isServer)
            {
                reagentContainer.TakeReagents(.041f);

                //Ran out of fuel
                if (FuelAmount < 0f)
                {
                    SyncIsOn(isOn, false);
                }

                Vector2Int position = gameObject.TileWorldPosition();

                registerTile.Matrix.ReactionManager.ExposeHotspotWorldPosition(position, 700, 0.005f);
            }

            yield return(WaitFor.Seconds(.1f));
        }
    }
Esempio n. 5
0
    public void ServerPerformInteraction(AimApply interaction)
    {
        if (reagentContainer.CurrentCapacity < reagentsPerUse || safety)
        {
            return;
        }

        Vector2           startPos     = gameObject.AssumedWorldPosServer();
        Vector2           targetPos    = interaction.WorldPositionTarget.To2Int();
        List <Vector3Int> positionList = MatrixManager.GetTiles(startPos, targetPos, travelDistance);

        StartCoroutine(Fire(positionList));

        var points = GetParallelPoints(startPos, targetPos, true);

        positionList = MatrixManager.GetTiles(points[0], points[1], travelDistance);
        StartCoroutine(Fire(positionList));

        points       = GetParallelPoints(startPos, targetPos, false);
        positionList = MatrixManager.GetTiles(points[0], points[1], travelDistance);
        StartCoroutine(Fire(positionList));

        Effect.PlayParticleDirectional(this.gameObject, interaction.TargetVector);

        SoundManager.PlayNetworkedAtPos("Extinguish", startPos, 1);
        reagentContainer.TakeReagents(reagentsPerUse);

        interaction.Performer.Pushable()?.NewtonianMove((-interaction.TargetVector).NormalizeToInt());
    }
Esempio n. 6
0
        public override void ImplantPeriodicUpdate()
        {
            base.ImplantPeriodicUpdate();

            //BloodContainer
            if (StomachContents.ReagentMixTotal > 0)
            {
                float ToDigest = DigesterAmountPerSecond * RelatedPart.TotalModified;
                if (StomachContents.ReagentMixTotal < ToDigest)
                {
                    ToDigest = StomachContents.ReagentMixTotal;
                }
                var Digesting = StomachContents.TakeReagents(ToDigest);

                RelatedPart.BloodContainer.Add(Digesting);
            }

            bool AllFat = true;

            foreach (var Fat in BodyFats)
            {
                if (Fat.IsFull == false)
                {
                    AllFat = false;
                    break;
                }
            }

            if (AllFat)
            {
                StartCoroutine(DelayAddFat());
            }
        }
Esempio n. 7
0
        public override void ImplantPeriodicUpdate()
        {
            base.ImplantPeriodicUpdate();

            //BloodContainer
            if (StomachContents.ReagentMixTotal > 0)
            {
                float ToDigest = DigesterAmountPerSecond * RelatedPart.TotalModified;
                if (StomachContents.ReagentMixTotal < ToDigest)
                {
                    ToDigest = StomachContents.ReagentMixTotal;
                }
                var Digesting = StomachContents.TakeReagents(ToDigest);

                RelatedPart.BloodContainer.Add(Digesting);
            }

            bool AllFat = true;

            foreach (var Fat in BodyFats)
            {
                if (Fat.IsFull == false)
                {
                    AllFat = false;
                    break;
                }
            }

            if (AllFat)
            {
                var Added = Spawn.ServerPrefab(BodyFatToInstantiate.gameObject).GameObject.GetComponent <BodyFat>();
                BodyFats.Add(Added);
                RelatedPart.OrganStorage.ServerTryAdd(Added.gameObject);
            }
        }
Esempio n. 8
0
    /// <summary>
    /// Server handles hand interaction with tray
    /// </summary>
    public void ServerPerformInteraction(HandApply interaction)
    {
        var LHB = interaction.TargetObject.GetComponent <LivingHealthMasterBase>();

        if (LHB != null)
        {
            LHB.CirculatorySystem.ReadyBloodPool.Add(LocalContainer.TakeReagents(10f));
        }
    }
Esempio n. 9
0
    /// <summary>
    /// Server handles hand interaction with tray
    /// </summary>
    public void ServerPerformInteraction(HandApply interaction)
    {
        var LHB = interaction.TargetObject.GetComponent <LivingHealthMasterBase>();

        if (LHB != null)
        {
            LHB.CirculatorySystem.BloodPool.Add(LocalContainer.TakeReagents(10f));
            Chat.AddActionMsgToChat(interaction.Performer, $"You Inject The syringe into {LHB.gameObject.ExpensiveName()}",
                                    $"{interaction.Performer.ExpensiveName()} injects a syringe into {LHB.gameObject.ExpensiveName()}");
        }
    }
Esempio n. 10
0
    private void Drink(PlayerScript eater, PlayerScript feeder)
    {
        // Start drinking reagent mix
        // todo: actually transfer reagent mix inside player stomach
        var drinkAmount = container.TransferAmount;

        container.TakeReagents(drinkAmount);

        // Play sound
        if (item && !string.IsNullOrEmpty(sound))
        {
            SoundManager.PlayNetworkedAtPos(sound, eater.WorldPos, sourceObj: eater.gameObject);
        }
    }
Esempio n. 11
0
    private void Drink(PlayerScript eater, PlayerScript feeder)
    {
        // Start drinking reagent mix
        // todo: actually transfer reagent mix inside player stomach
        var drinkAmount = container.TransferAmount;

        container.TakeReagents(drinkAmount);

        DoDrinkEffects(eater, drinkAmount);

        // Play sound
        if (item && drinkSound != null)
        {
            SoundManager.PlayNetworkedAtPos(drinkSound, eater.WorldPos, audioSourceParameters, sourceObj: eater.gameObject);
        }
    }
Esempio n. 12
0
        public override void ImplantPeriodicUpdate()
        {
            base.ImplantPeriodicUpdate();

            //BloodContainer
            if (StomachContents.ReagentMixTotal > 0)
            {
                float ToDigest = DigesterAmountPerSecond * RelatedPart.TotalModified;
                if (StomachContents.ReagentMixTotal < ToDigest)
                {
                    ToDigest = StomachContents.ReagentMixTotal;
                }
                var Digesting = StomachContents.TakeReagents(ToDigest);

                RelatedPart.HealthMaster.CirculatorySystem.UsedBloodPool.Add(Digesting);
            }

            if (StomachContents.SpareCapacity < 15f)             //Magic number
            {
                RelatedPart.HungerState = HungerState.Full;
            }
            else
            {
                RelatedPart.HungerState = HungerState.Normal;
            }

            bool AllFat = true;

            foreach (var Fat in BodyFats)
            {
                if (Fat.IsFull == false)
                {
                    AllFat = false;
                    break;
                }
            }

            if (AllFat)
            {
                var Added = Spawn.ServerPrefab(BodyFatToInstantiate.gameObject).GameObject.GetComponent <BodyFat>();
                Added.SetAbsorbedAmount(0);
                Added.RelatedStomach = this;
                BodyFats.Add(Added);
                RelatedPart.OrganStorage.ServerTryAdd(Added.gameObject);
            }
        }
Esempio n. 13
0
    void SprayTile(Vector3Int worldPos)
    {
        MatrixInfo matrixInfo = MatrixManager.AtPoint(worldPos, true);
        Vector3Int localPos   = MatrixManager.WorldToLocalInt(worldPos, matrixInfo);

        if (reagentContainer != null && reagentContainer.ReagentMixTotal > 0.1)
        {
            if (reagentContainer.MajorMixReagent.name == "SpaceCleaner")
            {
                matrixInfo.MetaDataLayer.Clean(worldPos, localPos, false);
            }
            else if (reagentContainer.MajorMixReagent.name == "Water")
            {
                matrixInfo.MetaDataLayer.Clean(worldPos, localPos, true);
            }
            else
            {
                MatrixManager.ReagentReact(reagentContainer.TakeReagents(reagentsPerUse), worldPos);
            }
        }
    }
Esempio n. 14
0
        public override void ImplantPeriodicUpdate()
        {
            base.ImplantPeriodicUpdate();
            //BloodContainer
            if (StomachContents.ReagentMixTotal > 0)
            {
                float ToDigest = DigesterAmountPerSecond * RelatedPart.TotalModified;
                if (StomachContents.ReagentMixTotal < ToDigest)
                {
                    ToDigest = StomachContents.ReagentMixTotal;
                }
                var Digesting = StomachContents.TakeReagents(ToDigest);

                RelatedPart.BloodContainer.Add(Digesting);

                //healthMaster.NutrimentLevel += Digesting[Nutriment];
                //What to do with non Digesting content, put back in stomach?
            }

            bool AllFat = true;

            foreach (var Fat in BodyFats)
            {
                if (Fat.IsFull == false)
                {
                    AllFat = false;
                    break;
                }
            }

            if (AllFat)
            {
                var Parent = RelatedPart.GetParent();
                var Added  = Spawn.ServerPrefab(BodyFatToInstantiate.gameObject).GameObject.GetComponent <BodyFat>();
                BodyFats.Add(Added);
                Parent.Storage.ServerTryAdd(Added.gameObject);
            }
        }
Esempio n. 15
0
 public void CleanTile(Vector3 worldPos)
 {
     MatrixManager.ReagentReact(reagentContainer.TakeReagents(reagentsPerUse), worldPos.CutToInt());
 }