Ejemplo n.º 1
0
    private void OnAbsorb(object data)
    {
        Pickupable pickupable = (Pickupable)data;

        if ((UnityEngine.Object)pickupable != (UnityEngine.Object)null)
        {
            PrimaryElement component      = GetComponent <PrimaryElement>();
            PrimaryElement primaryElement = pickupable.PrimaryElement;
            if ((UnityEngine.Object)primaryElement != (UnityEngine.Object)null)
            {
                float temperature = 0f;
                float mass        = component.Mass;
                float mass2       = primaryElement.Mass;
                if (mass > 0f && mass2 > 0f)
                {
                    temperature = SimUtil.CalculateFinalTemperature(mass, component.Temperature, mass2, primaryElement.Temperature);
                }
                else if (primaryElement.Mass > 0f)
                {
                    temperature = primaryElement.Temperature;
                }
                component.SetMassTemperature(mass + mass2, temperature);
                if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null)
                {
                    string sound = GlobalAssets.GetSound("Ore_absorb", false);
                    if (sound != null && CameraController.Instance.IsAudibleSound(pickupable.transform.GetPosition(), sound))
                    {
                        PlaySound3D(sound);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
        private static void Postfix(ref GameObject __result)
        {
            PrimaryElement primeElement = __result.GetComponent <PrimaryElement>();

            primeElement.SetMassTemperature(primeElement.Mass, primeElement.InternalTemperature);
        }
Ejemplo n.º 3
0
        private PrimaryElement FindSuitableElement()
        {
            PrimaryElement ret = null;
            // Maybe make it buffer an extra message, that might help?

            // better version: grab stuff from our ass, I mean network - BR

            int x, y;

            Grid.CellToXY(Grid.PosToCell(this), out x, out y);

            JObject message = Z.net.get_message_for("got_packet", x, y);

            if (outstanding && message != null)
            {
                outstanding = false;
                // We have a response from the server, finally ya lazy basterd
                if (message["packet"] != null &&
                    message["packet"].Type == JTokenType.Object)
                {
                    JObject mat_packet  = (JObject)message["packet"];
                    JObject germ_packet = null;
                    if (mat_packet["germs"] != null &&
                        mat_packet["germs"].Type == JTokenType.Object)
                    {
                        germ_packet = (JObject)mat_packet["germs"];
                    }
                    if (dave == null)
                    {
                        dave = GasSourceManager.Instance.CreateChunk(
                            (SimHashes)(-1528777920), 0f, 456f,
                            255, 0, this.transform.GetPosition());
                        steve = dave.GetComponent <PrimaryElement>();
                        steve.KeepZeroMassObject = true;
                    }
                    steve.SetElement((SimHashes)((int)mat_packet["element"]));
                    steve.SetMassTemperature((float)mat_packet["mass"],
                                             (float)mat_packet["temperature"]);
                    string reason = conduitType == ConduitType.Liquid
                        ? "Storage.AddLiquid" : "Storage.AddGasChunk";
                    steve.ModifyDiseaseCount(-steve.DiseaseCount, reason);
                    if (germ_packet != null)
                    {
                        steve.AddDisease((byte)germ_packet["id"],
                                         (int)germ_packet["count"],
                                         reason);
                    }

                    message = null;

                    ret = steve;
                }
            }
            // Only ask for goodies when we are enabled
            if (!outstanding && ztransporter.is_enabled())
            {
                // Send a message to the server asking for goodies

                message = Network.make_message("recv_packet", x, y);
                message.Add("phase", this.conduitType == ConduitType.Liquid ?
                            "Liquid" : "Gas");
                Z.net.send_message(message);
                outstanding = true;
            }
            return(ret);
        }