コード例 #1
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();

            MyMwcVector3Sbyte? relativeSectorPosition = MyMwcMessageIn.ReadVector3SbyteEx(binaryReader, senderEndPoint);
            if (relativeSectorPosition == null) return NetworkError();
            RelativeSectorPosition = relativeSectorPosition.Value;
            MyMwcLog.IfNetVerbose_AddToLog("RelativeSectorPosition: " + RelativeSectorPosition.ToString());

            MyMwcVector3Short? voxelMapPositionInVoxelCoords = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint);
            if (voxelMapPositionInVoxelCoords == null) return NetworkError();
            VoxelMapPositionInVoxelCoords = voxelMapPositionInVoxelCoords.Value;
            MyMwcLog.IfNetVerbose_AddToLog("VoxelMapPositionInVoxelCoords: " + VoxelMapPositionInVoxelCoords.ToString());

            MyMwcVoxelFilesEnum? voxelFile = MyMwcMessageIn.ReadVoxelFileEnumEx(binaryReader, senderEndPoint);
            if (voxelFile == null) return NetworkError();
            VoxelFile = voxelFile.Value;
            MyMwcLog.IfNetVerbose_AddToLog("VoxelFile: " + VoxelFile.ToString());

            MyMwcVoxelMaterialsEnum? voxelMaterial = MyMwcMessageIn.ReadVoxelMaterialsEnumEx(binaryReader, senderEndPoint);
            if (voxelMaterial == null) return NetworkError();
            VoxelMaterial = voxelMaterial.Value;
            MyMwcLog.IfNetVerbose_AddToLog("VoxelMaterial: " + VoxelMaterial.ToString());

            return true;
        }
コード例 #2
0
 public MyMwcObjectBuilder_PrefabScanner(MyMwcObjectBuilder_PrefabScanner_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, Vector3 size, Color color, float scanningSpeed/*, bool on*/)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     Size = size;
     Color = color;
     ScanningSpeed = scanningSpeed;            
 }
コード例 #3
0
 public MyMwcObjectBuilder_PrefabGenerator(MyMwcObjectBuilder_PrefabGenerator_TypesEnum generatorType,
     MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth,
     float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, /*bool on,*/ float range)
     : base((int)generatorType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     //On = on;
 }
コード例 #4
0
 public MyMwcObjectBuilder_PrefabBankNode(MyMwcObjectBuilder_PrefabBankNode_TypesEnum bankNodeType,
     MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth,
     float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, float cash)
     : base((int)bankNodeType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     Cash = cash;
 }
コード例 #5
0
 public static Vector3 GetRelativePositionInAbsoluteCoords(MyMwcVector3Short position)
 {
     return(new Vector3(
                (float)position.X / MyPrefabContainerConstants.CONTAINER_CONVERSION_UNIT,
                (float)position.Y / MyPrefabContainerConstants.CONTAINER_CONVERSION_UNIT,
                (float)position.Z / MyPrefabContainerConstants.CONTAINER_CONVERSION_UNIT));
 }
 public MyMwcObjectBuilder_VoxelMap_MergeMaterial(MyMwcVector3Short positionInVoxelMapInVoxelCoords, MyMwcVoxelFilesEnum voxelFile,
     MyMwcVoxelMaterialsEnum voxelMaterial)
     : base()
 {
     PositionInVoxelMapInVoxelCoords = positionInVoxelMapInVoxelCoords;
     VoxelFile = voxelFile;
     VoxelMaterial = voxelMaterial;
 }
コード例 #7
0
 public MyMwcObjectBuilder_VoxelMap_MergeMaterial(MyMwcVector3Short positionInVoxelMapInVoxelCoords, MyMwcVoxelFilesEnum voxelFile,
                                                  MyMwcVoxelMaterialsEnum voxelMaterial)
     : base()
 {
     PositionInVoxelMapInVoxelCoords = positionInVoxelMapInVoxelCoords;
     VoxelFile     = voxelFile;
     VoxelMaterial = voxelMaterial;
 }
 public MyMwcObjectBuilder_VoxelMap_MergeContent(MyMwcVector3Short positionInVoxelMapInVoxelCoords, MyMwcVoxelFilesEnum voxelFile,
                                                 MyMwcVoxelMapMergeTypeEnum mergeType)
     : base()
 {
     PositionInVoxelMapInVoxelCoords = positionInVoxelMapInVoxelCoords;
     VoxelFile = voxelFile;
     MergeType = mergeType;
 }
 public MyMwcObjectBuilder_VoxelMap_MergeContent(MyMwcVector3Short positionInVoxelMapInVoxelCoords, MyMwcVoxelFilesEnum voxelFile,
     MyMwcVoxelMapMergeTypeEnum mergeType)
     : base()
 {
     PositionInVoxelMapInVoxelCoords = positionInVoxelMapInVoxelCoords;
     VoxelFile = voxelFile;
     MergeType = mergeType;
 }
コード例 #10
0
 public MyMwcObjectBuilder_VoxelMap_Neighbour(MyMwcVector3Sbyte relativeSectorPosition, 
     MyMwcVector3Short voxelMapPositionInVoxelCoords, MyMwcVoxelFilesEnum voxelFile,
     MyMwcVoxelMaterialsEnum voxelMaterial)
     : base()
 {
     RelativeSectorPosition = relativeSectorPosition;
     VoxelMapPositionInVoxelCoords = voxelMapPositionInVoxelCoords;
     VoxelFile = voxelFile;
     VoxelMaterial = voxelMaterial;
 }
コード例 #11
0
 public MyMwcObjectBuilder_VoxelMap_Neighbour(MyMwcVector3Sbyte relativeSectorPosition,
                                              MyMwcVector3Short voxelMapPositionInVoxelCoords, MyMwcVoxelFilesEnum voxelFile,
                                              MyMwcVoxelMaterialsEnum voxelMaterial)
     : base()
 {
     RelativeSectorPosition        = relativeSectorPosition;
     VoxelMapPositionInVoxelCoords = voxelMapPositionInVoxelCoords;
     VoxelFile     = voxelFile;
     VoxelMaterial = voxelMaterial;
 }
 public MyMwcObjectBuilder_PrefabFoundationFactory(MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum foundationFactoryType,
     MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth,
     float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority, bool isBuilding, int buildingTimeFromStart,
     MyMwcObjectBuilder_ObjectToBuild buildingObject, List<MyMwcObjectBuilder_ObjectToBuild> buildingQueue)
     : base((int)foundationFactoryType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     IsBuilding = isBuilding;
     BuildingTimeFromStart = buildingTimeFromStart;
     BuildingObject = buildingObject;
     BuildingQueue = buildingQueue;
 }
コード例 #13
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());
            }

            MyMwcVector3Sbyte?relativeSectorPosition = MyMwcMessageIn.ReadVector3SbyteEx(binaryReader, senderEndPoint);

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

            MyMwcVector3Short?voxelMapPositionInVoxelCoords = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint);

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

            MyMwcVoxelFilesEnum?voxelFile = MyMwcMessageIn.ReadVoxelFileEnumEx(binaryReader, senderEndPoint);

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

            MyMwcVoxelMaterialsEnum?voxelMaterial = MyMwcMessageIn.ReadVoxelMaterialsEnumEx(binaryReader, senderEndPoint);

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

            return(true);
        }
コード例 #14
0
 protected MyMwcObjectBuilder_PrefabBase(int prefabObjectBuilderId, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance,
                                         MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName,
                                         float electricCapacity, bool?causesAlarm, int aiPriority, bool requiresEnergy = false)
     : this()
 {
     SetObjectBuilderId(prefabObjectBuilderId);
     //PrefabObjectBuilderId = prefabObjectBuilderId;
     FactionAppearance   = appearance;
     PositionInContainer = position;
     AnglesInContainer   = anglesInContainer;
     PrefabMaxHealth     = prefabMaxHealth;
     PrefabHealthRatio   = prefabHealthRatio;
     DisplayName         = displayName;
     ElectricCapacity    = electricCapacity;
     CausesAlarm         = causesAlarm;
     RequiresEnergy      = requiresEnergy;
     AIPriority          = aiPriority;
 }
コード例 #15
0
 protected MyMwcObjectBuilder_PrefabBase(int prefabObjectBuilderId, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance,
     MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName,
     float electricCapacity, bool? causesAlarm, int aiPriority, bool requiresEnergy = false)
     : this()
 {
     SetObjectBuilderId(prefabObjectBuilderId);
     //PrefabObjectBuilderId = prefabObjectBuilderId;
     FactionAppearance = appearance;
     PositionInContainer = position;
     AnglesInContainer = anglesInContainer;
     PrefabMaxHealth = prefabMaxHealth;
     PrefabHealthRatio = prefabHealthRatio;
     DisplayName = displayName;
     ElectricCapacity = electricCapacity;
     CausesAlarm = causesAlarm;
     RequiresEnergy = requiresEnergy;            
     AIPriority = aiPriority;
 }
コード例 #16
0
        /// <summary>
        /// CreatePrefabObjectBuilder
        /// </summary>
        /// <param name="prefabCategory"></param>
        /// <returns></returns>
        public MyMwcObjectBuilder_PrefabBase CreatePrefabObjectBuilder(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum textureEnum)
        {
            MyGameplayProperties  gameplayProperties = MyGameplayConstants.GetGameplayProperties(prefabType, prefabId, MyMwcObjectBuilder_FactionEnum.Euroamerican);
            MyPrefabConfiguration prefabConfig       = MyPrefabConstants.GetPrefabConfiguration(prefabType, prefabId);
            MyMwcVector3Short     pos = new MyMwcVector3Short(0, 0, 0);

            MyMwcObjectBuilder_PrefabBase objBuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabType, prefabId) as MyMwcObjectBuilder_PrefabBase;

            objBuilder.PositionInContainer = pos;
            objBuilder.AnglesInContainer   = Vector3.Zero;
            objBuilder.PrefabHealthRatio   = MyGameplayConstants.HEALTH_RATIO_MAX;
            objBuilder.PrefabMaxHealth     = null;
            objBuilder.FactionAppearance   = textureEnum;
            objBuilder.IsDestructible      = gameplayProperties.IsDestructible;
            if (prefabConfig.DisplayHud)
            {
                objBuilder.PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud;
            }

            return(objBuilder);
        }
コード例 #17
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();

            MyMwcVector3Short? positionInVoxelMapInVoxelCoords = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint);
            if (positionInVoxelMapInVoxelCoords == null) return NetworkError();
            PositionInVoxelMapInVoxelCoords = positionInVoxelMapInVoxelCoords.Value;
            MyMwcLog.IfNetVerbose_AddToLog("PositionInVoxelMapInVoxelCoords: " + PositionInVoxelMapInVoxelCoords.ToString());

            MyMwcVoxelFilesEnum? voxelFile = MyMwcMessageIn.ReadVoxelFileEnumEx(binaryReader, senderEndPoint);
            if (voxelFile == null) return NetworkError();
            VoxelFile = voxelFile.Value;
            MyMwcLog.IfNetVerbose_AddToLog("VoxelFile: " + VoxelFile.ToString());

            MyMwcVoxelMapMergeTypeEnum? mergeType = MyMwcMessageIn.ReadVoxelMapMergeTypeEnumEx(binaryReader, senderEndPoint);
            if (mergeType == null) return NetworkError();
            MergeType = mergeType.Value;
            MyMwcLog.IfNetVerbose_AddToLog("VoxelMaterial: " + MergeType.ToString());

            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());
            }

            MyMwcVector3Short?positionInVoxelMapInVoxelCoords = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint);

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

            MyMwcVoxelFilesEnum?voxelFile = MyMwcMessageIn.ReadVoxelFileEnumEx(binaryReader, senderEndPoint);

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

            MyMwcVoxelMapMergeTypeEnum?mergeType = MyMwcMessageIn.ReadVoxelMapMergeTypeEnumEx(binaryReader, senderEndPoint);

            if (mergeType == null)
            {
                return(NetworkError());
            }
            MergeType = mergeType.Value;
            MyMwcLog.IfNetVerbose_AddToLog("VoxelMaterial: " + MergeType.ToString());

            return(true);
        }
コード例 #19
0
 public MyMwcObjectBuilder_PrefabLargeWeapon(MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, float aimingDistance, float searchingDistance, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     AimingDistance = aimingDistance;
     SearchingDistance = searchingDistance;
 }
コード例 #20
0
 public MyMwcObjectBuilder_PrefabScanner(MyMwcObjectBuilder_PrefabScanner_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority, Vector3 size, Color color, float scanningSpeed /*, bool on*/)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     Size          = size;
     Color         = color;
     ScanningSpeed = scanningSpeed;
 }
コード例 #21
0
 public MyMwcObjectBuilder_PrefabKinematicPart(MyMwcObjectBuilder_PrefabKinematicPart_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance,
     MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {            
 }
コード例 #22
0
ファイル: MyVoxelMap.cs プロジェクト: Bunni/Miner-Wars-2081
 //  Return data cell to which belongs specified voxel (data cell)
 //  IMPORTANT: Input variable 'tempVoxelCoord' is 'ref' only for optimization. Never change its value in the method!!!
 public MyMwcVector3Int GetDataCellCoordinate(ref MyMwcVector3Short voxelCoord)
 {
     return new MyMwcVector3Int(voxelCoord.X >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS, voxelCoord.Y >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS, voxelCoord.Z >> MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_BITS);
 }
コード例 #23
0
        /// <summary>
        /// CreatePrefabObjectBuilder
        /// </summary>
        /// <param name="prefabCategory"></param>
        /// <returns></returns>
        public MyMwcObjectBuilder_PrefabBase CreatePrefabObjectBuilder(MyMwcObjectBuilderTypeEnum prefabType, int prefabId, MyMwcObjectBuilder_Prefab_AppearanceEnum textureEnum)
        {
            MyGameplayProperties gameplayProperties = MyGameplayConstants.GetGameplayProperties(prefabType, prefabId, MyMwcObjectBuilder_FactionEnum.Euroamerican);
            MyPrefabConfiguration prefabConfig = MyPrefabConstants.GetPrefabConfiguration(prefabType, prefabId);
            MyMwcVector3Short pos = new MyMwcVector3Short(0, 0, 0);

            MyMwcObjectBuilder_PrefabBase objBuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabType, prefabId) as MyMwcObjectBuilder_PrefabBase;
            objBuilder.PositionInContainer = pos;
            objBuilder.AnglesInContainer = Vector3.Zero;
            objBuilder.PrefabHealthRatio = MyGameplayConstants.HEALTH_RATIO_MAX;
            objBuilder.PrefabMaxHealth = null;
            objBuilder.FactionAppearance = textureEnum;
            objBuilder.IsDestructible = gameplayProperties.IsDestructible;
            if (prefabConfig.DisplayHud)
            {
                objBuilder.PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud;
            }
            
            return objBuilder;
        }
 public MyMwcObjectBuilder_PrefabFoundationFactory(MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum foundationFactoryType,
                                                   MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth,
                                                   float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority, bool isBuilding, int buildingTimeFromStart,
                                                   MyMwcObjectBuilder_ObjectToBuild buildingObject, List <MyMwcObjectBuilder_ObjectToBuild> buildingQueue)
     : base((int)foundationFactoryType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     IsBuilding            = isBuilding;
     BuildingTimeFromStart = buildingTimeFromStart;
     BuildingObject        = buildingObject;
     BuildingQueue         = buildingQueue;
 }
コード例 #25
0
ファイル: MyVoxelMap.cs プロジェクト: Bunni/Miner-Wars-2081
        //  Merges specified materials (from file) into our actual voxel map - overwriting materials only.
        //  We are using a regular voxel map to define areas where we want to set a specified material. Empty voxels are ignored and 
        //  only mixed/full voxels are used to tell us that that voxel will contain new material - 'materialToSet'.
        //  If we are seting indestructible material, voxel content values from merged voxel map will be used to define indestructible content.
        //  Parameter 'voxelPosition' - place where we will place merged voxel map withing actual voxel map. It's in voxel coords.
        //  IMPORTANT: THIS METHOD WILL WORK ONLY IF WE PLACE THE MAP THAT WE TRY TO MERGE FROM IN VOXEL COORDINATES THAT ARE MULTIPLY OF DATA CELL SIZE
        //  This method is used to load small material areas, overwriting actual material only if value from file is 1. Zeros are ignored (it's empty space).
        //  This method is quite fast, even on large maps - 512x512x512, so we can do more overwrites.
        //  Parameter 'materialToSet' tells us what material to set at places which are full in file. Empty are ignored - so stay as they were before this method was called.
        //  IMPORTANT: THIS MERGE MATERIAL CAN BE CALLED ONLY AFTER ALL VOXEL CONTENTS ARE LOADED. THAT'S BECAUSE WE NEED TO KNOW THEM FOR MIN CONTENT / INDESTRUCTIBLE CONTENT.
        //  Voxel map we are trying to merge into existing voxel map can be bigger or outside of area of existing voxel map. This method will just ignore those parts.
        public void MergeVoxelMaterials(MyMwcVoxelFilesEnum voxelFile, MyMwcVector3Short voxelPosition, MyMwcVoxelMaterialsEnum materialToSet)
        {
            MyMwcLog.WriteLine("MyVoxelMap.MergeVoxelMaterials() - Start");
            MyMwcLog.IncreaseIndent();

            MyCompressionFileLoad decompressFile = new MyCompressionFileLoad(MyVoxelFiles.Get(voxelFile).GetVoxFilePath());

            //  Version of a VOX file
            int fileVersion = decompressFile.GetInt32();

            //  Not supported VOX file version
            MyCommonDebugUtils.AssertRelease(fileVersion == MyVoxelConstants.VOXEL_FILE_ACTUAL_VERSION);

            //  Size of this voxel map (in voxels)
            int sizeX = decompressFile.GetInt32();
            int sizeY = decompressFile.GetInt32();
            int sizeZ = decompressFile.GetInt32();

            //  Size of data cell in voxels, doesn't have to be same as current size specified by our constants.
            int cellSizeX = decompressFile.GetInt32();
            int cellSizeY = decompressFile.GetInt32();
            int cellSizeZ = decompressFile.GetInt32();

            int cellsCountX = sizeX / cellSizeX;
            int cellsCountY = sizeY / cellSizeY;
            int cellsCountZ = sizeZ / cellSizeZ;

            //  This method will work only if we place the map that we try to merge from in voxel coordinates that are multiply of data cell size
            MyCommonDebugUtils.AssertRelease((voxelPosition.X & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            MyCommonDebugUtils.AssertRelease((voxelPosition.Y & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            MyCommonDebugUtils.AssertRelease((voxelPosition.Z & MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS_MASK) == 0);
            MyMwcVector3Int cellFullForVoxelPosition = GetDataCellCoordinate(ref voxelPosition);

            MyMwcVector3Int cellCoord;
            for (cellCoord.X = 0; cellCoord.X < cellsCountX; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < cellsCountY; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < cellsCountZ; cellCoord.Z++)
                    {
                        MyVoxelCellType cellType = (MyVoxelCellType)decompressFile.GetByte();

                        //  We can do "continue" here, becase we need to read this file properly, even if we will ignore that data
                        bool isDataCellInVoxelMap = IsDataCellInVoxelMap(
                            new MyMwcVector3Int(
                                cellFullForVoxelPosition.X + cellCoord.X,
                                cellFullForVoxelPosition.Y + cellCoord.Y,
                                cellFullForVoxelPosition.Z + cellCoord.Z));

                        if (cellType == MyVoxelCellType.EMPTY)
                        {
                            //  If merged cell is empty, there is nothing to overwrite, so we can skip this cell
                            continue;
                        }
                        else if (cellType == MyVoxelCellType.FULL)
                        {
                            //  If merged cell is full, than we reset whole material cell to 'materialToSet'
                            if (isDataCellInVoxelMap)
                            {
                                m_voxelMaterialCells[cellFullForVoxelPosition.X + cellCoord.X][cellFullForVoxelPosition.Y +
                                    cellCoord.Y][cellFullForVoxelPosition.Z + cellCoord.Z].Reset(
                                    materialToSet, GetIndestructibleContentByMaterial(materialToSet));
                            }
                        }
                        else
                        {
                            MyMwcVector3Int cellCoordInVoxels = GetVoxelCoordinatesOfDataCell(ref cellCoord);

                            MyMwcVector3Int voxelCoordRelative;
                            voxelCoordRelative.X = voxelPosition.X + cellCoordInVoxels.X;
                            voxelCoordRelative.Y = voxelPosition.Y + cellCoordInVoxels.Y;
                            voxelCoordRelative.Z = voxelPosition.Z + cellCoordInVoxels.Z;

                            MyMwcVector3Int voxelCoordInCell;
                            for (voxelCoordInCell.X = 0; voxelCoordInCell.X < cellSizeX; voxelCoordInCell.X++)
                            {
                                for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < cellSizeY; voxelCoordInCell.Y++)
                                {
                                    for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < cellSizeZ; voxelCoordInCell.Z++)
                                    {
                                        byte voxelFromFile = decompressFile.GetByte();

                                        if (isDataCellInVoxelMap)
                                        {
                                            //  Ignore empty voxels, but use mixed/full for seting the material
                                            if (voxelFromFile > MyVoxelConstants.VOXEL_CONTENT_EMPTY)
                                            {
                                                MyMwcVector3Int voxelCoord = new MyMwcVector3Int(
                                                    voxelCoordRelative.X + voxelCoordInCell.X,
                                                    voxelCoordRelative.Y + voxelCoordInCell.Y,
                                                    voxelCoordRelative.Z + voxelCoordInCell.Z);

                                                //  Actual voxel content
                                                byte voxelContent = GetVoxelContent(ref voxelCoord);

                                                //  If this is indestructible material, here we will get 'min content' for this voxel
                                                byte indestructibleContent = GetIndestructibleContentsByMaterialAndContent(materialToSet, voxelFromFile);

                                                //  Indestructible content can be less than real voxel at this place. First I made this mistake.
                                                //  If forgoten, then during explosions we will in fact create matter from 'indestructible content' array.
                                                if (indestructibleContent > voxelContent)
                                                {
                                                    indestructibleContent = voxelContent;
                                                }

                                                SetVoxelMaterialAndIndestructibleContent(materialToSet, indestructibleContent, ref voxelCoord);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyVoxelMap.MergeVoxelMaterials() - End");
        }
コード例 #26
0
ファイル: MyVoxelMap.cs プロジェクト: Bunni/Miner-Wars-2081
        // Not used
        //public void Reinitialize()
        //{
        //    if (m_isClosed)
        //    {
        //        Init(this.Name, this.PositionLeftBottomCorner, (MyMwcObjectBuilder_VoxelMap)this.GetObjectBuilderInternal());
        //        m_isClosed = false;
        //    }
        //}

        //  Merges a specified voxel map (from a file) into our actual voxel map at a specified position. 
        //  This merging is slower than loading voxel map through constructor (because we are setting voxels through SetVoxelContent) - so use it only 
        //  for merging-in small areas.
        //  Parameter 'voxelPosition' - where will be placed new merged voxel map withing actual voxel map. It's in voxel coords.
        //  Voxel map we are trying to merge into existing voxel map can be bigger or outside of area of existing voxel map. This method will just ignore those parts.
        //  Coordinate of 'voxelPosition' DOESN'T NEED to be aligned to data cell (multiplies of 8).
        public void MergeVoxelContents(MyMwcVoxelFilesEnum voxelFile, MyMwcVector3Short voxelPosition, MyMwcVoxelMapMergeTypeEnum mergeType)
        {
            MyCompressionFileLoad decompressFile = new MyCompressionFileLoad(MyVoxelFiles.Get(voxelFile).GetVoxFilePath());

            //  Version of a VOX file
            int fileVersion = decompressFile.GetInt32();

            //  Not supported VOX file version
            MyCommonDebugUtils.AssertRelease(fileVersion == MyVoxelConstants.VOXEL_FILE_ACTUAL_VERSION);

            //  Size of this voxel map (in voxels)
            int sizeX = decompressFile.GetInt32();
            int sizeY = decompressFile.GetInt32();
            int sizeZ = decompressFile.GetInt32();

            //  Size of data cell in voxels, doesn't have to be same as current size specified by our constants.
            int cellSizeX = decompressFile.GetInt32();
            int cellSizeY = decompressFile.GetInt32();
            int cellSizeZ = decompressFile.GetInt32();

            int cellsCountX = sizeX / cellSizeX;
            int cellsCountY = sizeY / cellSizeY;
            int cellsCountZ = sizeZ / cellSizeZ;

            MyMwcVector3Int cellCoord;
            for (cellCoord.X = 0; cellCoord.X < cellsCountX; cellCoord.X++)
            {
                for (cellCoord.Y = 0; cellCoord.Y < cellsCountY; cellCoord.Y++)
                {
                    for (cellCoord.Z = 0; cellCoord.Z < cellsCountZ; cellCoord.Z++)
                    {
                        MyVoxelCellType cellType = (MyVoxelCellType)decompressFile.GetByte();

                        MyMwcVector3Int cellCoordInVoxels = GetVoxelCoordinatesOfDataCell(ref cellCoord);

                        //  Go through every voxel in a cell and change it's value. If cell is empty, set all voxels to empty. Otherwise set by value from file.
                        MyMwcVector3Int voxelCoordInCell;
                        for (voxelCoordInCell.X = 0; voxelCoordInCell.X < cellSizeX; voxelCoordInCell.X++)
                        {
                            for (voxelCoordInCell.Y = 0; voxelCoordInCell.Y < cellSizeY; voxelCoordInCell.Y++)
                            {
                                for (voxelCoordInCell.Z = 0; voxelCoordInCell.Z < cellSizeZ; voxelCoordInCell.Z++)
                                {
                                    byte newContent;
                                    if (cellType == MyVoxelCellType.EMPTY)
                                    {
                                        newContent = MyVoxelConstants.VOXEL_CONTENT_EMPTY;
                                    }
                                    else if (cellType == MyVoxelCellType.FULL)
                                    {
                                        newContent = MyVoxelConstants.VOXEL_CONTENT_FULL;
                                    }
                                    else
                                    {
                                        newContent = decompressFile.GetByte();
                                    }

                                    MyMwcVector3Int voxelCoord;
                                    voxelCoord.X = voxelPosition.X + cellCoordInVoxels.X + voxelCoordInCell.X;
                                    voxelCoord.Y = voxelPosition.Y + cellCoordInVoxels.Y + voxelCoordInCell.Y;
                                    voxelCoord.Z = voxelPosition.Z + cellCoordInVoxels.Z + voxelCoordInCell.Z;

                                    if (IsVoxelInVoxelMap(ref voxelCoord) == true)
                                    {
                                        byte originalContent = GetVoxelContent(ref voxelCoord);

                                        if (mergeType == MyMwcVoxelMapMergeTypeEnum.ADD)
                                        {
                                            //  Set new content only if its value is higher than actual - so we only can add matter
                                            if (newContent > originalContent)
                                            {
                                                SetVoxelContent(newContent, ref voxelCoord);
                                            }
                                        }
                                        else if (mergeType == MyMwcVoxelMapMergeTypeEnum.INVERSE_AND_SUBTRACT)
                                        {
                                            //  Subtract new content from original, so if original voxel is full and new is full too, result will be empty voxel
                                            //  If new is empty, nothing will happen. If new is full but original is empty, nothing will happen either.
                                            SetVoxelContent((byte)MyMwcUtils.GetClampInt((int)originalContent - (int)newContent, MyVoxelConstants.VOXEL_CONTENT_EMPTY, MyVoxelConstants.VOXEL_CONTENT_FULL), ref voxelCoord);
                                        }
                                        else
                                        {
                                            throw new MyMwcExceptionApplicationShouldNotGetHere();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #27
0
ファイル: MyVoxelMap.cs プロジェクト: Bunni/Miner-Wars-2081
 public static Vector3 GetVoxelSizeInMetres(ref MyMwcVector3Short sizeInVoxels)
 {
     return new Vector3(sizeInVoxels.X * MyVoxelConstants.VOXEL_SIZE_IN_METRES, sizeInVoxels.Y * MyVoxelConstants.VOXEL_SIZE_IN_METRES, sizeInVoxels.Z * MyVoxelConstants.VOXEL_SIZE_IN_METRES);
 }
コード例 #28
0
        public static void AddMergeContent(Random rnd, List<MyMwcVoxelFilesEnum> voxelAsteroids, int voxelAsteroidSize, MyMwcObjectBuilder_VoxelMap builder)
        {
            if (voxelAsteroidSize > (int)(64 * MyVoxelConstants.VOXEL_SIZE_IN_METRES))
            {
                int mergeSize = voxelAsteroidSize / 2;
                int numMerges = rnd.Next(0, 3);
                //numMerges = 1;
                for (int i = 0; i < numMerges; i++)
                {
                    voxelAsteroids.Clear();

                    MyMwcVoxelMapMergeTypeEnum mergeType;
                    int maxPos = (int)(mergeSize / MyVoxelConstants.VOXEL_SIZE_IN_METRES) / 2;
                    int mergeTypeIndex = rnd.Next(0, 2);
                    //mergeTypeIndex = 0;
                    if (mergeTypeIndex == 0)
                    {
                        mergeType = MyMwcVoxelMapMergeTypeEnum.ADD;
                        MyVoxelMap.GetAsteroidsBySizeInMeters(mergeSize, voxelAsteroids, true);
                        maxPos /= 2;
                    }
                    else
                    {
                        // Subtract merge works with bigger asteroids
                        mergeType = MyMwcVoxelMapMergeTypeEnum.INVERSE_AND_SUBTRACT;
                        MyVoxelMap.GetAsteroidsBySizeInMeters(mergeSize, voxelAsteroids, false);
                        MyVoxelMap.GetAsteroidsBySizeInMeters(mergeSize * 2, voxelAsteroids, false);
                    }

                    int mergeIndex = rnd.Next(0, voxelAsteroids.Count);

                    MyMwcVector3Short offset = new MyMwcVector3Short((short)rnd.Next(0, maxPos), (short)rnd.Next(0, maxPos), (short)rnd.Next(0, maxPos));

                    builder.MergeContents.Add(new MyMwcObjectBuilder_VoxelMap_MergeContent(offset, voxelAsteroids[mergeIndex], mergeType));
                }
            }
        }
 public MyMwcObjectBuilder_PrefabSecurityControlHUB(MyMwcObjectBuilder_PrefabHangar_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, List<uint> connectedEntities, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority, true)
 {
     ConnectedEntities = connectedEntities;
 }
コード例 #30
0
 /// <summary>
 /// c-tor
 /// </summary>
 /// <param name="prefabType"></param>
 /// <param name="position"></param>
 /// <param name="anglesInContainer"></param>
 public MyMwcObjectBuilder_PrefabLight(MyMwcObjectBuilder_PrefabLight_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float? prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool? causesAlarm, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     PointFalloff = SpotFalloff = 1.0f;
     PointIntensity = SpotIntensity = 1.0f;
     SpotRange = SpotRange = 100.0f;
     PointColor = SpotColor = new Vector4(1, 1, 1, 1);
     PointSpecular = SpotSpecular = new Vector3(0, 0, 0);
     PointOffset = 0;
     Effect = MyLightEffectTypeEnum.NORMAL;
     SpotAgle = 1;
     ShadowsDistance = 200;
 }
コード例 #31
0
 public MyMwcObjectBuilder_PrefabLargeWeapon(MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, float aimingDistance, float searchingDistance, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     AimingDistance    = aimingDistance;
     SearchingDistance = searchingDistance;
 }
コード例 #32
0
 public static Vector3 GetRelativePositionInAbsoluteCoords(MyMwcVector3Short position)
 {
     return new Vector3(
         (float)position.X / MyPrefabContainerConstants.CONTAINER_CONVERSION_UNIT,
         (float)position.Y / MyPrefabContainerConstants.CONTAINER_CONVERSION_UNIT,
         (float)position.Z / MyPrefabContainerConstants.CONTAINER_CONVERSION_UNIT);
 }
コード例 #33
0
 public MyMwcObjectBuilder_PrefabHangar(MyMwcObjectBuilder_PrefabHangar_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
 }
コード例 #34
0
 public static void WriteVector3Short(MyMwcVector3Short val, BinaryWriter binaryWriter)
 {
     binaryWriter.Write(val.X);
     binaryWriter.Write(val.Y);
     binaryWriter.Write(val.Z);
 }
コード例 #35
0
        private bool Read_01085000(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
// PrefabType
            int?prefabObjectBuilderId = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);

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

            // PositionInContainer
            MyMwcVector3Short?positionInContainer = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint);

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

            // AnglesInContainer
            Vector3?anglesInContainer = MyMwcMessageIn.ReadVector3FloatEx(binaryReader, senderEndPoint);

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

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

            if (!hasMaxHealth.HasValue)
            {
                return(NetworkError());
            }
            if (hasMaxHealth.Value)
            {
                // PrefabMaxHealth
                float?prefabMaxHealth = MyMwcMessageIn.ReadFloat(binaryReader);
                if (prefabMaxHealth == null)
                {
                    return(NetworkError());
                }
                PrefabMaxHealth = prefabMaxHealth.Value;
                MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth: " + PrefabMaxHealth.Value.ToString());
                if (float.IsNaN(PrefabMaxHealth.Value) || float.IsInfinity(PrefabMaxHealth.Value))
                {
                    System.Diagnostics.Debug.Fail("PrefabMaxHealth is: " + PrefabMaxHealth.Value);
                    PrefabMaxHealth = null; // MyGameplayConstants.MAX_HEALTH_MAX;
                }
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth is: null");
                PrefabMaxHealth = null;
            }

            // PrefabHealthRatio
            float?prefabHealthRatio = MyMwcMessageIn.ReadFloat(binaryReader);

            if (prefabHealthRatio == null)
            {
                return(NetworkError());
            }
            PrefabHealthRatio = prefabHealthRatio.Value;
            MyMwcLog.IfNetVerbose_AddToLog("PrefabHealth: " + PrefabHealthRatio.ToString());

            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;
            }

            // faction appearance (texture set)
            short?factionAppearance = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);

            if (!factionAppearance.HasValue)
            {
                return(NetworkError());
            }
            FactionAppearance = (MyMwcObjectBuilder_Prefab_AppearanceEnum)factionAppearance.Value;
            MyMwcLog.IfNetVerbose_AddToLog("FactionAppearance: " + FactionAppearance);

            //  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;
            }

            // Causes Alarm
            bool?hasCausesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!hasCausesAlarm.HasValue)
            {
                return(NetworkError());
            }
            if (hasCausesAlarm.Value)
            {
                bool?causesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
                if (!causesAlarm.HasValue)
                {
                    return(NetworkError());
                }
                MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + CausesAlarm);
                CausesAlarm = causesAlarm.Value;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + "null");
                CausesAlarm = null;
            }

            // Requires Energy
            bool?hasRequiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!hasRequiresEnergy.HasValue)
            {
                return(NetworkError());
            }
            if (hasRequiresEnergy.Value)
            {
                bool?requiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
                if (!requiresEnergy.HasValue)
                {
                    return(NetworkError());
                }
                MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + RequiresEnergy);
                RequiresEnergy = requiresEnergy.Value;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + "null");
                RequiresEnergy = null;
            }

            // Display HUD
            bool?hasDisplayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);

            if (!hasDisplayHud.HasValue)
            {
                return(NetworkError());
            }
            if (hasDisplayHud.Value)
            {
                bool?displayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
                if (!displayHud.HasValue)
                {
                    return(NetworkError());
                }
                if (displayHud.Value)
                {
                    PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud;
                }
                else
                {
                    PersistentFlags &= ~MyPersistentEntityFlags.DisplayOnHud;
                }
                MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + displayHud.Value);
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + "null");
            }

            // AI Priority
            int?aiPriority = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);

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

            return(true);
        }
 public MyMwcObjectBuilder_PrefabSecurityControlHUB(MyMwcObjectBuilder_PrefabHangar_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, List <uint> connectedEntities, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority, true)
 {
     ConnectedEntities = connectedEntities;
 }
コード例 #37
0
 /// <summary>
 /// c-tor
 /// </summary>
 /// <param name="prefabType"></param>
 /// <param name="position"></param>
 /// <param name="anglesInContainer"></param>
 public MyMwcObjectBuilder_PrefabLight(MyMwcObjectBuilder_PrefabLight_TypesEnum prefabType, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, MyMwcVector3Short position, Vector3 anglesInContainer, float?prefabMaxHealth, float prefabHealthRatio, string displayName, float electricCapacity, bool?causesAlarm, int aiPriority)
     : base((int)prefabType, appearance, position, anglesInContainer, prefabMaxHealth, prefabHealthRatio, displayName, electricCapacity, causesAlarm, aiPriority)
 {
     PointFalloff    = SpotFalloff = 1.0f;
     PointIntensity  = SpotIntensity = 1.0f;
     SpotRange       = SpotRange = 100.0f;
     PointColor      = SpotColor = new Vector4(1, 1, 1, 1);
     PointSpecular   = SpotSpecular = new Vector3(0, 0, 0);
     PointOffset     = 0;
     Effect          = MyLightEffectTypeEnum.NORMAL;
     SpotAgle        = 1;
     ShadowsDistance = 200;
 }
コード例 #38
0
        private bool Read_01085000(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
// PrefabType
            int? prefabObjectBuilderId = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (prefabObjectBuilderId == null) return NetworkError();
            PrefabObjectBuilderId = prefabObjectBuilderId.Value;
            MyMwcLog.IfNetVerbose_AddToLog("PrefabObjectBuilderId: " + PrefabObjectBuilderId);

            // PositionInContainer
            MyMwcVector3Short? positionInContainer = MyMwcMessageIn.ReadVector3ShortEx(binaryReader, senderEndPoint);
            if (positionInContainer == null) return NetworkError();
            PositionInContainer = positionInContainer.Value;
            MyMwcLog.IfNetVerbose_AddToLog("PositionInContainer: " + PositionInContainer);

            // AnglesInContainer
            Vector3? anglesInContainer = MyMwcMessageIn.ReadVector3FloatEx(binaryReader, senderEndPoint);
            if (anglesInContainer == null) return NetworkError();
            AnglesInContainer = anglesInContainer.Value;
            MyMwcLog.IfNetVerbose_AddToLog("AnglesInContainer: " + AnglesInContainer.ToString());

            bool? hasMaxHealth = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasMaxHealth.HasValue) return NetworkError();
            if (hasMaxHealth.Value)
            {
                // PrefabMaxHealth
                float? prefabMaxHealth = MyMwcMessageIn.ReadFloat(binaryReader);
                if (prefabMaxHealth == null) return NetworkError();
                PrefabMaxHealth = prefabMaxHealth.Value;
                MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth: " + PrefabMaxHealth.Value.ToString());
                if (float.IsNaN(PrefabMaxHealth.Value) || float.IsInfinity(PrefabMaxHealth.Value))
                {
                    System.Diagnostics.Debug.Fail("PrefabMaxHealth is: " + PrefabMaxHealth.Value);
                    PrefabMaxHealth = null; // MyGameplayConstants.MAX_HEALTH_MAX;
                }
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("PrefabMaxHealth is: null");
                PrefabMaxHealth = null;
            }

            // PrefabHealthRatio
            float? prefabHealthRatio = MyMwcMessageIn.ReadFloat(binaryReader);
            if (prefabHealthRatio == null) return NetworkError();
            PrefabHealthRatio = prefabHealthRatio.Value;
            MyMwcLog.IfNetVerbose_AddToLog("PrefabHealth: " + PrefabHealthRatio.ToString());

            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;
            }

            // faction appearance (texture set)
            short? factionAppearance = MyMwcMessageIn.ReadInt16Ex(binaryReader, senderEndPoint);
            if (!factionAppearance.HasValue) return NetworkError();
            FactionAppearance = (MyMwcObjectBuilder_Prefab_AppearanceEnum) factionAppearance.Value;
            MyMwcLog.IfNetVerbose_AddToLog("FactionAppearance: " + FactionAppearance);

            //  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;
            }

            // Causes Alarm
            bool? hasCausesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasCausesAlarm.HasValue) return NetworkError();
            if (hasCausesAlarm.Value)
            {
                bool? causesAlarm = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
                if (!causesAlarm.HasValue) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + CausesAlarm);
                CausesAlarm = causesAlarm.Value;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("CausesAlarm: " + "null");
                CausesAlarm = null;
            }

            // Requires Energy
            bool? hasRequiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasRequiresEnergy.HasValue) return NetworkError();
            if (hasRequiresEnergy.Value)
            {
                bool? requiresEnergy = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
                if (!requiresEnergy.HasValue) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + RequiresEnergy);
                RequiresEnergy = requiresEnergy.Value;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("RequiresEnergy: " + "null");
                RequiresEnergy = null;
            }

            // Display HUD
            bool? hasDisplayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasDisplayHud.HasValue) return NetworkError();
            if (hasDisplayHud.Value)
            {
                bool? displayHud = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
                if (!displayHud.HasValue) return NetworkError();
                if (displayHud.Value)
                    PersistentFlags |= MyPersistentEntityFlags.DisplayOnHud;
                else
                    PersistentFlags &= ~MyPersistentEntityFlags.DisplayOnHud;
                MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + displayHud.Value);
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("DisplayHud: " + "null");
            }

            // AI Priority
            int? aiPriority = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (aiPriority == null) return NetworkError();
            AIPriority = aiPriority.Value;
            MyMwcLog.IfNetVerbose_AddToLog("AIPriority: " + AIPriority);

            return true;
        }