Пример #1
0
        public void MultiSplit(MixAndVolume InmixAndVolume, float TotalVolume)
        {
            float Multiplier = InmixAndVolume.Volume / TotalVolume;

            InmixAndVolume.gasMix = InmixAndVolume.gasMix + (gasMix * Multiplier);
            Mix.Clone().TransferTo(InmixAndVolume.Mix, Multiplier * Mix.Total);
        }
Пример #2
0
        public void MultiSplit(MixAndVolume InmixAndVolume, float TotalVolume)
        {
            if (TotalVolume == 0)
            {
                Logger.LogError(" divide by 0 in MultiSplit");
            }

            float Multiplier = InmixAndVolume.Volume / TotalVolume;

            InmixAndVolume.gasMix = InmixAndVolume.gasMix + (gasMix * Multiplier);
            Mix.Clone().TransferTo(InmixAndVolume.Mix, Multiplier * Mix.Total);
        }
Пример #3
0
        public MixAndVolume Clone()
        {
            var MiXV = new MixAndVolume();

            MiXV.gasMix = new GasMix(gasMix);
            MiXV.Mix    = Mix.Clone();
            return(MiXV);
        }
Пример #4
0
        public virtual void Eat(PlayerScript eater, PlayerScript feeder)
        {
            //TODO: Reimplement metabolism.
            AudioSourceParameters eatSoundParameters = new AudioSourceParameters(pitch: RandomPitch);

            SoundManager.PlayNetworkedAtPos(sound, eater.WorldPos, eatSoundParameters, sourceObj: eater.gameObject);

            var Stomachs = eater.playerHealth.GetStomachs();

            if (Stomachs.Count == 0)
            {
                //No stomachs?!
                return;
            }

            ReagentMix incomingFood = new ReagentMix();

            FoodContents.CurrentReagentMix.TransferTo(incomingFood, FoodContents.CurrentReagentMix.Total);

            incomingFood.Divide(Stomachs.Count);
            foreach (var Stomach in Stomachs)
            {
                Stomach.StomachContents.Add(incomingFood.Clone());
            }


            var feederSlot = feeder.DynamicItemStorage.GetActiveHandSlot();

            //If food has a stack component, decrease amount by one instead of deleting the entire stack.
            if (stackable != null)
            {
                stackable.ServerConsume(1);
            }
            else
            {
                Inventory.ServerDespawn(gameObject);
            }

            if (leavings != null)
            {
                var  leavingsInstance = Spawn.ServerPrefab(leavings).GameObject;
                var  pickupable       = leavingsInstance.GetComponent <Pickupable>();
                bool added            = Inventory.ServerAdd(pickupable, feederSlot);
                if (!added)
                {
                    //If stackable has leavings and they couldn't go in the same slot, they should be dropped
                    pickupable.CustomNetTransform.SetPosition(feeder.WorldPos);
                }
            }
        }
Пример #5
0
        public virtual void Eat(PlayerScript eater, PlayerScript feeder)
        {
            //TODO: Reimplement metabolism.
            AudioSourceParameters eatSoundParameters = new AudioSourceParameters(pitch: RandomPitch);

            SoundManager.PlayNetworkedAtPos(sound, eater.WorldPos, eatSoundParameters, sourceObj: eater.gameObject);

            var Stomachs = eater.playerHealth.GetStomachs();

            if (Stomachs.Count == 0)
            {
                //No stomachs?!
                return;
            }

            float SpareSpace = 0;

            foreach (var Stomach in Stomachs)
            {
                SpareSpace += Stomach.StomachContents.SpareCapacity;
            }

            if (SpareSpace < 0.5f)
            {
                if (eater == feeder)
                {
                    Chat.AddActionMsgToChat(feeder.gameObject,
                                            "you try the stuff The food into your mouth but your stomach has no more room",
                                            "{performer} Tries to stuff food into the mouth but is unable to");
                }
                else
                {
                    Chat.AddActionMsgToChat(feeder.gameObject,
                                            "You try and stuff more food into your targets mouth but no more seems to go in",
                                            "{performer} Tries to stuff food into Their targets mouth but no more food is going in");
                }

                return;
            }

            if (SpareSpace < FoodContents.CurrentReagentMix.Total)
            {
                Chat.AddActionMsgToChat(feeder.gameObject, "You unwillingly eat the food",
                                        "{performer} Unwillingly force themselves to eat the food");
            }

            ReagentMix incomingFood = FoodContents.CurrentReagentMix.Clone();


            incomingFood.Divide(Stomachs.Count);
            foreach (var Stomach in Stomachs)
            {
                Stomach.StomachContents.Add(incomingFood.Clone());
            }


            var feederSlot = feeder.DynamicItemStorage.GetActiveHandSlot();

            //If food has a stack component, decrease amount by one instead of deleting the entire stack.
            if (stackable != null)
            {
                stackable.ServerConsume(1);
            }
            else
            {
                Inventory.ServerDespawn(gameObject);
            }

            if (leavings != null)
            {
                var  leavingsInstance = Spawn.ServerPrefab(leavings).GameObject;
                var  pickupable       = leavingsInstance.GetComponent <Pickupable>();
                bool added            = Inventory.ServerAdd(pickupable, feederSlot);
                if (!added)
                {
                    //If stackable has leavings and they couldn't go in the same slot, they should be dropped
                    pickupable.CustomNetTransform.SetPosition(feeder.WorldPos);
                }
            }
        }