本文整理汇总了C#中Sandbox.Definitions.MyCubeBlockDefinition类的典型用法代码示例。如果您正苦于以下问题:C# MyCubeBlockDefinition类的具体用法?C# MyCubeBlockDefinition怎么用?C# MyCubeBlockDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyCubeBlockDefinition类属于Sandbox.Definitions命名空间,在下文中一共展示了MyCubeBlockDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
}
}
}
}
示例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();
}
}
示例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;
}
示例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);
示例14: GetBlockPlacementMaterials
public abstract void GetBlockPlacementMaterials(MyCubeBlockDefinition definition, Vector3I position, MyBlockOrientation orientation, MyCubeGrid grid);
示例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);
}
}
}
}