本文整理汇总了C#中Sandbox.Definitions.MyCubeBlockDefinition类的典型用法代码示例。如果您正苦于以下问题:C# MyCubeBlockDefinition类的具体用法?C# MyCubeBlockDefinition怎么用?C# MyCubeBlockDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyCubeBlockDefinition类属于Sandbox.Definitions命名空间,在下文中一共展示了MyCubeBlockDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LoadDefinition
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader<MyDefinitionId, int> materials, bool merge = true)
{
InitBlockInfo(blockInfo, definition);
foreach (var material in materials)
{
var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key);
var info = new MyHudBlockInfo.ComponentInfo();
if (componentDefinition == null)
{
MyPhysicalItemDefinition physicalDefinition = null;
if (!MyDefinitionManager.Static.TryGetPhysicalItemDefinition(material.Key, out physicalDefinition))
continue;
info.ComponentName = physicalDefinition.DisplayNameText;
info.Icon = physicalDefinition.Icon;
info.DefinitionId = physicalDefinition.Id;
info.TotalCount = 1;
}
else
{
info.DefinitionId = componentDefinition.Id;
info.ComponentName = componentDefinition.DisplayNameText;
info.Icon = componentDefinition.Icon;
info.TotalCount = material.Value;
}
blockInfo.Components.Add(info);
}
if (merge) MergeSameComponents(blockInfo, definition);
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:30,代码来源:MyHudBlockInfoExtensions.cs
示例2: MyGeneratedBlockLocation
public MyGeneratedBlockLocation(MySlimBlock refBlock, MyCubeBlockDefinition blockDefinition, Vector3I position, Vector3I forward, Vector3I up, ushort? blockIdInCompound = null, MyGridInfo gridInfo = null)
{
RefBlock = refBlock;
BlockDefinition = blockDefinition;
Position = position;
Orientation = new MyBlockOrientation(Base6Directions.GetDirection(ref forward), Base6Directions.GetDirection(ref up));
BlockIdInCompound = blockIdInCompound;
GridInfo = gridInfo;
GeneratedBlockType = MyStringId.NullOrEmpty;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:10,代码来源:MyAdditionalModelGeneratorBase.cs
示例3: Initialize
public void Initialize(ref MyBlockBuildArea area, MyCubeBlockDefinition definition)
{
m_definition = definition;
m_orientation = new MyBlockOrientation(area.OrientationForward, area.OrientationUp);
m_posInGrid = area.PosInGrid;
m_blockMin = area.BlockMin;
m_blockMax = area.BlockMax;
m_stepDelta = area.StepDelta;
m_lookup.Clear();
}
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:10,代码来源:MyCubeGrid.Static.cs
示例4: InitBlockInfo
private static void InitBlockInfo(MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition)
{
blockInfo.BlockName = definition.DisplayNameText;
blockInfo.BlockIcon = definition.Icon;
blockInfo.BlockIntegrity = 0;
blockInfo.CriticalComponentIndex = -1;
blockInfo.CriticalIntegrity = 0;
blockInfo.OwnershipIntegrity = 0;
blockInfo.MissingComponentIndex = -1;
blockInfo.Components.Clear();
}
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:11,代码来源:MyHudBlockInfoExtensions.cs
示例5: MyCubeBlockDefinitionWithVariants
public MyCubeBlockDefinitionWithVariants(MyCubeBlockDefinition definition, int variantIndex)
{
m_baseDefinition = definition;
m_variantIndex = variantIndex;
if (m_baseDefinition.Variants == null || m_baseDefinition.Variants.Count == 0)
{
m_variantIndex = -1;
}
else if (m_variantIndex != -1)
{
m_variantIndex %= m_baseDefinition.Variants.Count;
}
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:13,代码来源:MyCubeBlockDefinitionWithVariants.cs
示例6: AddComponentsForBlock
private static void AddComponentsForBlock(MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition)
{
for (int i = 0; i < definition.Components.Length; ++i)
{
var comp = definition.Components[i];
var info = new MyHudBlockInfo.ComponentInfo();
info.DefinitionId = comp.Definition.Id;
info.ComponentName = comp.Definition.DisplayNameText;
info.Icon = comp.Definition.Icon;
info.TotalCount = comp.Count;
blockInfo.Components.Add(info);
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:13,代码来源:MyHudBlockInfoExtensions.cs
示例7: BeforeCreateBlock
// This function does some modifications to the cube block's object builder before it's built, usually integrity changes, etc...
public virtual void BeforeCreateBlock(MyCubeBlockDefinition definition, MyEntity builder, MyObjectBuilder_CubeBlock ob, bool buildAsAdmin)
{
if (definition.EntityComponents == null) return;
if (ob.ComponentContainer == null)
{
ob.ComponentContainer = new MyObjectBuilder_ComponentContainer();
}
foreach (var componentOb in definition.EntityComponents)
{
var data = new MyObjectBuilder_ComponentContainer.ComponentData();
data.TypeId = componentOb.Key.ToString();
data.Component = componentOb.Value;
ob.ComponentContainer.Components.Add(data);
}
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:18,代码来源:MyBuildComponentBase.cs
示例8: LoadDefinition
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader<MyDefinitionId, int> materials, bool merge = true)
{
InitBlockInfo(blockInfo, definition);
foreach (var material in materials)
{
var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key);
var info = new MyHudBlockInfo.ComponentInfo();
info.DefinitionId = componentDefinition.Id;
info.ComponentName = componentDefinition.DisplayNameText;
info.Icon = componentDefinition.Icon;
info.TotalCount = material.Value;
blockInfo.Components.Add(info);
}
if (merge) MergeSameComponents(blockInfo, definition);
}
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:17,代码来源:MyHudBlockInfoExtensions.cs
示例9: GetDefaultObjectBuilder
public static MyObjectBuilder_BlockNavigationDefinition GetDefaultObjectBuilder(MyCubeBlockDefinition blockDefinition)
{
MyObjectBuilder_BlockNavigationDefinition ob = m_tmpDefaultOb;
m_tmpStringBuilder.Clear();
m_tmpStringBuilder.Append("Default_");
m_tmpStringBuilder.Append(blockDefinition.Size.X);
m_tmpStringBuilder.Append("_");
m_tmpStringBuilder.Append(blockDefinition.Size.Y);
m_tmpStringBuilder.Append("_");
m_tmpStringBuilder.Append(blockDefinition.Size.Z);
ob.Id = new MyDefinitionId(typeof(MyObjectBuilder_BlockNavigationDefinition), m_tmpStringBuilder.ToString());
ob.Size = blockDefinition.Size;
ob.Center = blockDefinition.Center;
return ob;
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:18,代码来源:MyBlockNavigationDefinition.cs
示例10: LoadDefinition
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, bool merge = true)
{
blockInfo.BlockName = definition.DisplayNameText;
blockInfo.BlockIcon = definition.Icon;
blockInfo.BlockIntegrity = 0;
blockInfo.CriticalComponentIndex = -1;
blockInfo.CriticalIntegrity = 0;
blockInfo.OwnershipIntegrity = 0;
blockInfo.MissingComponentIndex = -1;
blockInfo.Components.Clear();
for (int i = 0; i < definition.Components.Length; ++i)
{
var comp = definition.Components[i];
var info = new MyHudBlockInfo.ComponentInfo();
info.ComponentName = comp.Definition.DisplayNameText;
info.Icon = comp.Definition.Icon;
info.TotalCount = comp.Count;
blockInfo.Components.Add(info);
}
// Merge same components
if (merge)
{
for (int i = definition.Components.Length - 1; i >= 0; i--)
{
for (int j = i - 1; j >= 0; j--)
{
if (definition.Components[i].Definition == definition.Components[j].Definition)
{
var info = blockInfo.Components[j];
info.TotalCount += blockInfo.Components[i].TotalCount;
blockInfo.Components[j] = info;
blockInfo.Components.RemoveAt(i);
break;
}
}
}
}
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:41,代码来源:MyHudBlockInfoExtensions.cs
示例11: CreateFrom
private static WeaponDescription CreateFrom(MyCubeBlockDefinition definition)
{
if (string.IsNullOrWhiteSpace(definition.DescriptionString))
return new WeaponDescription();
WeaponDescription desc = new WeaponDescription();
try
{
XML_Amendments<WeaponDescription> ammender = new XML_Amendments<WeaponDescription>(desc);
ammender.AmendAll(definition.DescriptionString, true);
return ammender.Deserialize();
}
catch (Exception ex)
{
Logger.debugNotify("Failed to load description for a weapon", 10000, Logger.severity.ERROR);
Logger log = new Logger("WeaponDescription", () => definition.Id.ToString());
log.alwaysLog("Failed to load description for a weapon", Logger.severity.ERROR);
log.alwaysLog("Exception: " + ex, Logger.severity.ERROR);
return new WeaponDescription();
}
}
开发者ID:Souper07,项目名称:Autopilot,代码行数:21,代码来源:WeaponDescription.cs
示例12: ComputeMax
/// <summary>
/// Called when block is destroyed before being removed from grid
/// </summary>
//public void OnDestroy()
//{
// if (FatBlock != null)
// {
// Profiler.Begin("MySlimBlock.OnDestroy");
// FatBlock.OnDestroy();
// Profiler.End();
// }
//}
public static void ComputeMax(MyCubeBlockDefinition definition, MyBlockOrientation orientation, ref Vector3I min, out Vector3I max)
{
Vector3I size = definition.Size - 1;
MatrixI localMatrix = new MatrixI(orientation);
Vector3I.TransformNormal(ref size, ref localMatrix, out size);
Vector3I.Abs(ref size, out size);
max = min + size;
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:21,代码来源:MySlimBlock.cs
示例13: GetGridSpawnMaterials
// Convention: All these functions will erase the RequiredMaterials first thing when they're called
public abstract void GetGridSpawnMaterials(MyCubeBlockDefinition definition, MatrixD worldMatrix, bool isStatic);
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:2,代码来源:MyBuildComponentBase.cs
示例14: GetBlockPlacementMaterials
public abstract void GetBlockPlacementMaterials(MyCubeBlockDefinition definition, Vector3I position, MyBlockOrientation orientation, MyCubeGrid grid);
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:1,代码来源:MyBuildComponentBase.cs
示例15: AddFastBuildModelWithSubparts
protected static void AddFastBuildModelWithSubparts(ref MatrixD matrix, List<MatrixD> matrices, List<string> models, MyCubeBlockDefinition blockDefinition)
{
if (string.IsNullOrEmpty(blockDefinition.Model))
return;
matrices.Add(matrix);
models.Add(blockDefinition.Model);
var data = new MyEntitySubpart.Data();
MyCubeBlockDefinition subBlockDefinition;
MatrixD subBlockMatrix;
Vector3 dummyPosition;
MyModel modelData = MyModels.GetModelOnlyData(blockDefinition.Model);
foreach (var dummy in modelData.Dummies)
{
if (MyEntitySubpart.GetSubpartFromDummy(blockDefinition.Model, dummy.Key, dummy.Value, ref data))
{
MatrixD mCopy = MatrixD.Multiply(data.InitialTransform, matrix);
matrices.Add(mCopy);
models.Add(data.File);
}
else if (MyFakes.ENABLE_SUBBLOCKS
&& MyCubeBlock.GetSubBlockDataFromDummy(blockDefinition, dummy.Key, dummy.Value, false, out subBlockDefinition, out subBlockMatrix, out dummyPosition))
{
if (!string.IsNullOrEmpty(subBlockDefinition.Model))
{
// Repair subblock matrix to have int axes (because preview renderer does not allow such non integer rotation).
Vector3I forward = Vector3I.Round(Vector3.DominantAxisProjection(subBlockMatrix.Forward));
Vector3I invForward = Vector3I.One - Vector3I.Abs(forward);
Vector3I right = Vector3I.Round(Vector3.DominantAxisProjection((Vector3)subBlockMatrix.Right * invForward));
Vector3I up;
Vector3I.Cross(ref right, ref forward, out up);
subBlockMatrix.Forward = forward;
subBlockMatrix.Right = right;
subBlockMatrix.Up = up;
MatrixD mCopy = MatrixD.Multiply(subBlockMatrix, matrix);
matrices.Add(mCopy);
models.Add(subBlockDefinition.Model);
}
}
}
}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:46,代码来源:MyBlockBuilderBase.cs
示例16: Init
public void Init(MyObjectBuilder_GunBase objectBuilder, MyCubeBlockDefinition cubeBlockDefinition, IMyGunBaseUser gunBaseUser)
{
if (cubeBlockDefinition is MyWeaponBlockDefinition)
{
MyWeaponBlockDefinition weaponBlockDefinition = cubeBlockDefinition as MyWeaponBlockDefinition;
Init(objectBuilder, weaponBlockDefinition.WeaponDefinitionId, gunBaseUser);
}
else
{
// Backward compatibility
MyDefinitionId weaponDefinitionId = GetBackwardCompatibleDefinitionId(cubeBlockDefinition.Id.TypeId);
Init(objectBuilder, weaponDefinitionId, gunBaseUser);
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:14,代码来源:MyGunBase.cs
示例17: ParseInventory
private static InventoryEditorModel ParseInventory(MyObjectBuilder_Inventory inventory, MyCubeBlockDefinition definition = null)
{
if (inventory == null)
return null;
float volumeMultiplier = 1f; // Unsure if there should be a default of 1 if there isn't a InventorySize defined.
if (definition == null)
volumeMultiplier = 0.4f;
else
{
var definitionType = definition.GetType();
var invSizeField = definitionType.GetField("InventorySize");
var inventoryMaxVolumeField = definitionType.GetField("InventoryMaxVolume");
if (invSizeField != null)
{
var invSize = (Vector3)invSizeField.GetValue(definition);
volumeMultiplier = invSize.X * invSize.Y * invSize.Z;
}
if (inventoryMaxVolumeField != null)
{
var maxSize = (float)inventoryMaxVolumeField.GetValue(definition);
volumeMultiplier = MathHelper.Min(volumeMultiplier, maxSize);
}
}
var settings = SpaceEngineersCore.WorldResource.Checkpoint.Settings;
return new InventoryEditorModel(inventory, volumeMultiplier * 1000 * settings.InventorySizeMultiplier, null) { Name = inventory.InventoryFlags.ToString(), IsValid = true };
}
开发者ID:midspace,项目名称:SEToolbox,代码行数:28,代码来源:SpaceEngineersExtensions.cs
示例18: GetBlockMass
public float GetBlockMass(string model, MyCubeBlockDefinition def)
{
var sh = BlockShapePool.GetBreakableShape(model, def);
var mass = sh.GetMass();
BlockShapePool.EnqueShape(model, def.Id, sh);
return mass;
}
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:7,代码来源:MyDestructionData.cs
示例19: GetInventory
//public static ObservableCollection<InventoryEditorModel> GetInventory(this MyObjectBuilder_EntityBase objectBuilderBase)
//{
// var inventoryEditors = new ObservableCollection<InventoryEditorModel>();
// if (objectBuilderBase.ComponentContainer != null)
// {
// var inventoryBase = objectBuilderBase.ComponentContainer.Components.FirstOrDefault(e => e.TypeId == "MyInventoryBase");
// if (inventoryBase != null)
// {
// var singleInventory = inventoryBase.Component as MyObjectBuilder_Inventory;
// if (singleInventory != null)
// {
// var iem = ParseInventory(singleInventory);
// if (iem != null)
// inventoryEditors.Add(iem);
// }
// var aggregate = inventoryBase.Component as MyObjectBuilder_InventoryAggregate;
// if (aggregate != null)
// foreach (var field in aggregate.Inventories)
// {
// var iem = ParseInventory(field as MyObjectBuilder_Inventory);
// if (iem != null)
// inventoryEditors.Add(iem);
// }
// }
// }
// return inventoryEditors;
//}
public static ObservableCollection<InventoryEditorModel> GetInventory(this MyObjectBuilder_ComponentContainer componentContainer, MyCubeBlockDefinition definition = null)
{
var inventoryEditors = new ObservableCollection<InventoryEditorModel>();
if (componentContainer != null)
{
var inventoryBase = componentContainer.Components.FirstOrDefault(e => e.TypeId == "MyInventoryBase");
if (inventoryBase != null)
{
var singleInventory = inventoryBase.Component as MyObjectBuilder_Inventory;
if (singleInventory != null)
{
var iem = ParseInventory(singleInventory, definition);
if (iem != null)
inventoryEditors.Add(iem);
}
var aggregate = inventoryBase.Component as MyObjectBuilder_InventoryAggregate;
if (aggregate != null)
foreach (var field in aggregate.Inventories)
{
var iem = ParseInventory(field as MyObjectBuilder_Inventory, definition);
if (iem != null)
inventoryEditors.Add(iem);
}
}
}
return inventoryEditors;
}
开发者ID:midspace,项目名称:SEToolbox,代码行数:61,代码来源:SpaceEngineersExtensions.cs
示例20: CheckMountPointsForSide
/// <summary>
/// Checkes whether blocks A and B have matching mount point on one of their sides. Each block is given by its
/// definition, rotation and position in grid. Position has to be relative to same center. Also, normal relative to block A specifies
/// wall which is used for checking.
/// </summary>
public static bool CheckMountPointsForSide(MyCubeBlockDefinition defA, MyCubeBlockDefinition.MountPoint[] mountPointsA, ref MyBlockOrientation orientationA, ref Vector3I positionA, ref Vector3I normalA,
MyCubeBlockDefinition defB, MyCubeBlockDefinition.MountPoint[] mountPointsB, ref MyBlockOrientation orientationB, ref Vector3I positionB)
{
TransformMountPoints(m_cacheMountPointsA, defA, mountPointsA, ref orientationA);
TransformMountPoints(m_cacheMountPointsB, defB, mountPointsB, ref orientationB);
return CheckMountPointsForSide(m_cacheMountPointsA, ref orientationA, ref positionA, defA.Id, ref normalA, m_cacheMountPointsB, ref orientationB, ref positionB, defB.Id);
}
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:12,代码来源:MyCubeGrid.Static.cs
注:本文中的Sandbox.Definitions.MyCubeBlockDefinition类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论