public void Init(StringBuilder hudLabelText, MyMwcObjectBuilder_InfluenceSphere objectBuilder, Matrix matrix)
        {
            // Influence spheres dont have hud label text
            base.Init(hudLabelText, objectBuilder);

            InfluenceFlags = objectBuilder.InfluenceFlags;

            m_radiusMin = objectBuilder.RadiusMin;
            RadiusMax   = objectBuilder.RadiusMax;
            DustColor   = objectBuilder.DustColor;
            Magnitude   = objectBuilder.Magnitude;

            VisibleInGame = false;

            SetWorldMatrix(matrix);

            Enabled = objectBuilder.Enabled;

            NeedsUpdate = Enabled;
            Save        = true;

            //m_soundType = objectBuilder.SoundType;
            //MySoundCuesEnum cueEnum = GetSoundCueByObjectBuilderType(m_soundType);
            //m_cueEnum = cueEnum;
            m_cueEnum = (MySoundCuesEnum)objectBuilder.SoundCueId;

            if ((InfluenceFlags & MyInfluenceFlags.Sound) > 0)
            {
                MyGuiInfluenceSphereHelper musicHelper = MyGuiInfluenceSphereHelpers.GetInfluenceSphereSoundHelper(m_cueEnum);
                if (musicHelper == null || !musicHelper.Description.ToString().ToLower().StartsWith("amb2d_"))
                {
                    if (musicHelper == null)
                    {
                        Debug.Fail("Incorrect influence sphere sound doesn't exist");
                        MyMwcLog.WriteLine("Incorrect influence sphere sound doesn't exist");
                    }
                    else
                    {
                        Debug.Fail("Incorrect influence sphere sound: " + musicHelper.Description.ToString() + ", deleted");
                        MyMwcLog.WriteLine("Incorrect influence sphere sound: " + musicHelper.Description.ToString() + ", deleted");
                    }
                }
            }

            Flags |= EntityFlags.EditableInEditor;
        }
Beispiel #2
0
        //  Read this object from message-in
        internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
            if (base.Read(binaryReader, senderEndPoint, gameVersion) == false)
            {
                return(NetworkError());
            }

            // Type
            short?flags = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);

            if (flags == null)
            {
                return(NetworkError());
            }
            InfluenceFlags = (MyInfluenceFlags)flags.Value;
            MyMwcLog.IfNetVerbose_AddToLog("InfluenceFlags: " + InfluenceFlags);

            // RadiusMin
            float radiusMin = MyMwcMessageIn.ReadFloat(binaryReader);

            RadiusMin = radiusMin;
            MyMwcLog.IfNetVerbose_AddToLog("RadiusMin: " + RadiusMin);

            // RadiusMax
            float radiusMax = MyMwcMessageIn.ReadFloat(binaryReader);

            RadiusMax = radiusMax;
            MyMwcLog.IfNetVerbose_AddToLog("RadiusMax: " + RadiusMax);

            // Dust color
            Color?dustColor = MyMwcMessageIn.ReadColorEx(binaryReader, senderEndPoint);

            if (dustColor == null)
            {
                return(NetworkError());
            }
            MyMwcLog.IfNetVerbose_AddToLog("dustColor: " + dustColor.ToString());
            DustColor = dustColor.Value;

            // Magnitude
            float magnitude = MyMwcMessageIn.ReadFloat(binaryReader);

            MyMwcLog.IfNetVerbose_AddToLog("Magnitude: " + magnitude);
            Magnitude = magnitude;

            //// Sound
            //short? soundType = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);
            //if (soundType == null) return NetworkError();
            //SoundType = (MyInfluenceSphereSoundsEnum) soundType.Value;
            //MyMwcLog.IfNetVerbose_AddToLog("SoundType: " + SoundType);

            // Sound Cue Id
            short?soundCueId = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);

            if (soundCueId == null)
            {
                return(NetworkError());
            }
            SoundCueId = soundCueId.Value;
            MyMwcLog.IfNetVerbose_AddToLog("SoundCueId: " + SoundCueId);

            return(true);
        }
        //  Read this object from message-in
        internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
            if (base.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();

            // Type
            short? flags = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);
            if (flags == null) return NetworkError();
            InfluenceFlags = (MyInfluenceFlags) flags.Value;
            MyMwcLog.IfNetVerbose_AddToLog("InfluenceFlags: " + InfluenceFlags);

            // RadiusMin
            float radiusMin = MyMwcMessageIn.ReadFloat(binaryReader);
            RadiusMin = radiusMin;
            MyMwcLog.IfNetVerbose_AddToLog("RadiusMin: " + RadiusMin);

            // RadiusMax
            float radiusMax = MyMwcMessageIn.ReadFloat(binaryReader);
            RadiusMax = radiusMax;
            MyMwcLog.IfNetVerbose_AddToLog("RadiusMax: " + RadiusMax);

            // Dust color
            Color? dustColor = MyMwcMessageIn.ReadColorEx(binaryReader, senderEndPoint);
            if (dustColor == null) return NetworkError();
            MyMwcLog.IfNetVerbose_AddToLog("dustColor: " + dustColor.ToString());
            DustColor = dustColor.Value;

            // Magnitude
            float magnitude = MyMwcMessageIn.ReadFloat(binaryReader);
            MyMwcLog.IfNetVerbose_AddToLog("Magnitude: " + magnitude);
            Magnitude = magnitude;

            //// Sound
            //short? soundType = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);
            //if (soundType == null) return NetworkError();
            //SoundType = (MyInfluenceSphereSoundsEnum) soundType.Value;
            //MyMwcLog.IfNetVerbose_AddToLog("SoundType: " + SoundType);

            // Sound Cue Id
            short? soundCueId = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);
            if (soundCueId == null) return NetworkError();
            SoundCueId = soundCueId.Value;
            MyMwcLog.IfNetVerbose_AddToLog("SoundCueId: " + SoundCueId);

            return true;
        }
        public void Init(StringBuilder hudLabelText, MyMwcObjectBuilder_InfluenceSphere objectBuilder, Matrix matrix)
        {
            // Influence spheres dont have hud label text
            base.Init(hudLabelText, objectBuilder);

            InfluenceFlags = objectBuilder.InfluenceFlags;

            m_radiusMin = objectBuilder.RadiusMin;
            RadiusMax = objectBuilder.RadiusMax;
            DustColor = objectBuilder.DustColor;
            Magnitude = objectBuilder.Magnitude;

            VisibleInGame = false;

            SetWorldMatrix(matrix);

            Enabled = objectBuilder.Enabled;

            NeedsUpdate = Enabled;
            Save = true;

            //m_soundType = objectBuilder.SoundType;
            //MySoundCuesEnum cueEnum = GetSoundCueByObjectBuilderType(m_soundType);
            //m_cueEnum = cueEnum;
            m_cueEnum = (MySoundCuesEnum)objectBuilder.SoundCueId;

            if ((InfluenceFlags & MyInfluenceFlags.Sound) > 0)
            {
                MyGuiInfluenceSphereHelper musicHelper = MyGuiInfluenceSphereHelpers.GetInfluenceSphereSoundHelper(m_cueEnum);
                if (musicHelper == null || !musicHelper.Description.ToString().ToLower().StartsWith("amb2d_"))
                {
                    if (musicHelper == null)
                    {
                        Debug.Fail("Incorrect influence sphere sound doesn't exist");
                        MyMwcLog.WriteLine("Incorrect influence sphere sound doesn't exist");
                    }
                    else
                    {
                        Debug.Fail("Incorrect influence sphere sound: " + musicHelper.Description.ToString() + ", deleted");
                        MyMwcLog.WriteLine("Incorrect influence sphere sound: " + musicHelper.Description.ToString() + ", deleted");
                    }
                }
            }

            Flags |= EntityFlags.EditableInEditor;
        }