Esempio n. 1
0
 public MyMwcObjectBuilder_PrefabContainer(int?templateId, MyMwcObjectBuilder_PrefabContainer_TypesEnum containerType,
                                           List <MyMwcObjectBuilder_PrefabBase> prefabs, int userOwnerID, MyMwcObjectBuilder_FactionEnum faction, MyMwcObjectBuilder_Inventory inventory)
 {
     TemplateId    = templateId;
     ContainerType = containerType;
     Prefabs       = prefabs;
     UserOwnerID   = userOwnerID;
     Faction       = faction;
     Inventory     = inventory;
 }
 public MyMwcObjectBuilder_PrefabContainer(int? templateId, MyMwcObjectBuilder_PrefabContainer_TypesEnum containerType,
     List<MyMwcObjectBuilder_PrefabBase> prefabs, int userOwnerID, MyMwcObjectBuilder_FactionEnum faction, MyMwcObjectBuilder_Inventory inventory)
 {
     TemplateId = templateId;
     ContainerType = containerType;
     Prefabs = prefabs;
     UserOwnerID = userOwnerID;
     Faction = faction;
     Inventory = inventory;
 }
Esempio n. 3
0
 internal override void SetObjectBuilderIdInternal(int?objectBuilderId)
 {
     ContainerType = (MyMwcObjectBuilder_PrefabContainer_TypesEnum)Convert.ToUInt16(objectBuilderId);
 }
Esempio n. 4
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());
            }

            //  TemplateId
            bool?isTemplateId = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (isTemplateId == null)
            {
                return(NetworkError());
            }
            if (isTemplateId.Value)
            {
                TemplateId = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            }
            else
            {
                TemplateId = null;
            }

            //  Container Type
            MyMwcObjectBuilder_PrefabContainer_TypesEnum?containerType = MyMwcMessageIn.ReadObjectBuilderPrefabContainerTypesEnumEx(binaryReader, senderEndPoint);

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

            // Faction
            Faction = (MyMwcObjectBuilder_FactionEnum)MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            // Faction must be defined
            System.Diagnostics.Debug.Assert(Enum.IsDefined(typeof(MyMwcObjectBuilder_FactionEnum), Faction));

            //  Prefabs
            int?countPrefabs = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);

            if (countPrefabs == null)
            {
                return(NetworkError());
            }
            MyMwcLog.IfNetVerbose_AddToLog("countPrefabs: " + countPrefabs);
            Prefabs = new List <MyMwcObjectBuilder_PrefabBase>(countPrefabs.Value);
            for (int i = 0; i < countPrefabs; i++)
            {
                MyMwcObjectBuilder_PrefabBase prefab = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_PrefabBase;
                if (prefab == null)
                {
                    return(NetworkError());
                }
                if (prefab.Read(binaryReader, senderEndPoint, gameVersion) == false)
                {
                    return(NetworkError());
                }
                Prefabs.Add(prefab);
            }

            //  Inventory
            bool?isInventory = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (isInventory == null)
            {
                return(NetworkError());
            }
            if (isInventory.Value)
            {
                Inventory = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Inventory;
                if (Inventory == null)
                {
                    return(NetworkError());
                }
                if (Inventory.Read(binaryReader, senderEndPoint, gameVersion) == false)
                {
                    return(NetworkError());
                }
            }
            else
            {
                Inventory = null;
            }


            bool?hasDisplayName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!hasDisplayName.HasValue)
            {
                return(NetworkError());
            }
            if (hasDisplayName.Value)
            {
                string displayName = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint);
                if (displayName == null)
                {
                    return(NetworkError());
                }
                MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + displayName);
                DisplayName = displayName;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + "null");
                DisplayName = null;
            }

            //  Use Properties
            bool?hasUseProperties = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (hasUseProperties == null)
            {
                return(NetworkError());
            }
            if (hasUseProperties.Value)
            {
                UseProperties = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_EntityUseProperties;
                if (UseProperties == null)
                {
                    return(NetworkError());
                }
                if (UseProperties.Read(binaryReader, senderEndPoint, gameVersion) == false)
                {
                    return(NetworkError());
                }
            }
            else
            {
                UseProperties = null;
            }

            //  Alarm On
            bool?alarmOn = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

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

            //  Refill time
            bool?refillTime = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (refillTime == null)
            {
                return(NetworkError());
            }
            if (refillTime.Value)
            {
                RefillTime = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            }
            else
            {
                RefillTime = null;
            }

            return(true);
        }
 internal override void SetObjectBuilderIdInternal(int? objectBuilderId)
 {
     ContainerType = (MyMwcObjectBuilder_PrefabContainer_TypesEnum)Convert.ToUInt16(objectBuilderId);
 }
        //  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();

            //  TemplateId
            bool? isTemplateId = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (isTemplateId == null) return NetworkError();
            if (isTemplateId.Value)
            {
                TemplateId = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            }
            else
            {
                TemplateId = null;
            }
            
            //  Container Type
            MyMwcObjectBuilder_PrefabContainer_TypesEnum? containerType = MyMwcMessageIn.ReadObjectBuilderPrefabContainerTypesEnumEx(binaryReader, senderEndPoint);
            if (containerType == null) return NetworkError();
            ContainerType = containerType.Value;
            MyMwcLog.IfNetVerbose_AddToLog("ContainerType: " + ContainerType);

            // Faction
            Faction = (MyMwcObjectBuilder_FactionEnum)MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            // Faction must be defined
            System.Diagnostics.Debug.Assert(Enum.IsDefined(typeof(MyMwcObjectBuilder_FactionEnum), Faction));

            //  Prefabs
            int? countPrefabs = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (countPrefabs == null) return NetworkError();
            MyMwcLog.IfNetVerbose_AddToLog("countPrefabs: " + countPrefabs);
            Prefabs = new List<MyMwcObjectBuilder_PrefabBase>(countPrefabs.Value);
            for (int i = 0; i < countPrefabs; i++)
            {
                MyMwcObjectBuilder_PrefabBase prefab = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_PrefabBase;
                if (prefab == null) return NetworkError();
                if (prefab.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
                Prefabs.Add(prefab);
            }

            //  Inventory
            bool? isInventory = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (isInventory == null) return NetworkError();
            if (isInventory.Value)
            {
                Inventory = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Inventory;
                if (Inventory == null) return NetworkError();
                if (Inventory.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
            }
            else
            {
                Inventory = null;
            }


            bool? hasDisplayName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasDisplayName.HasValue) return NetworkError();
            if (hasDisplayName.Value)
            {
                string displayName = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint);
                if (displayName == null) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + displayName);
                DisplayName = displayName;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + "null");
                DisplayName = null;
            }

            //  Use Properties
            bool? hasUseProperties = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (hasUseProperties == null) return NetworkError();
            if (hasUseProperties.Value)
            {
                UseProperties = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_EntityUseProperties;
                if (UseProperties == null) return NetworkError();
                if (UseProperties.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
            }
            else
            {
                UseProperties = null;
            }

            //  Alarm On
            bool? alarmOn = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (alarmOn == null) return NetworkError();
            AlarmOn = alarmOn.Value;
            MyMwcLog.IfNetVerbose_AddToLog("AlarmOn: " + AlarmOn);

            //  Refill time
            bool? refillTime = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (refillTime == null) return NetworkError();
            if (refillTime.Value)
            {
                RefillTime = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            }
            else
            {
                RefillTime = null;
            }

            return true;
        }
Esempio n. 7
0
 public static void WriteObjectBuilderPrefabContainerTypesEnum(MyMwcObjectBuilder_PrefabContainer_TypesEnum val, BinaryWriter binaryWriter)
 {
     binaryWriter.Write((ushort)val);
 }