本文整理汇总了C#中Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock.GetId方法的典型用法代码示例。如果您正苦于以下问题:C# MyObjectBuilder_CubeBlock.GetId方法的具体用法?C# MyObjectBuilder_CubeBlock.GetId怎么用?C# MyObjectBuilder_CubeBlock.GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock
的用法示例。
在下文中一共展示了MyObjectBuilder_CubeBlock.GetId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
base.Init(objectBuilder, cubeGrid);
m_cargoDefinition = (MyCargoContainerDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
var cargoBuilder = (MyObjectBuilder_CargoContainer)objectBuilder;
m_containerType = cargoBuilder.ContainerType;
if (!Components.Has<MyInventoryBase>())
{
m_inventory = new MyInventory(m_cargoDefinition.InventorySize.Volume, m_cargoDefinition.InventorySize, MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive, this);
if(MyFakes.ENABLE_MEDIEVAL_INVENTORY)
Components.Add<MyInventoryBase>(m_inventory);
if (m_containerType != null && MyFakes.RANDOM_CARGO_PLACEMENT && (cargoBuilder.Inventory == null || cargoBuilder.Inventory.Items.Count == 0))
SpawnRandomCargo();
else
m_inventory.Init(cargoBuilder.Inventory);
}
else
{
m_inventory = Components.Get<MyInventoryBase>() as MyInventory;
Debug.Assert(m_inventory != null);
//m_inventory.Owner = this;
}
if(MyPerGameSettings.InventoryMass)
m_inventory.ContentsChanged += Inventory_ContentsChanged;
m_conveyorEndpoint = new MyMultilineConveyorEndpoint(this);
AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));
UpdateIsWorking();
}
示例2: Init
public void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid, MyCubeBlock fatBlock)
{
ProfilerShort.Begin("SlimBlock.Init(objectBuilder, ...)");
Debug.Assert(cubeGrid != null);
FatBlock = fatBlock;
m_soundEmitter.Entity = FatBlock;
if (objectBuilder is MyObjectBuilder_CompoundCubeBlock)
BlockDefinition = MyCompoundCubeBlock.GetCompoundCubeBlockDefinition();
else
BlockDefinition = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
m_componentStack = new MyComponentStack(BlockDefinition, objectBuilder.IntegrityPercent, objectBuilder.BuildPercent);
if (MyCubeGridDefinitions.GetCubeRotationOptions(BlockDefinition) == MyRotationOptionsEnum.None)
{
objectBuilder.BlockOrientation = MyBlockOrientation.Identity;
}
DeformationRatio = BlockDefinition.DeformationRatio;
Min = objectBuilder.Min;
Orientation = objectBuilder.BlockOrientation;
if (!Orientation.IsValid)
Orientation = MyBlockOrientation.Identity;
Debug.Assert(Orientation.IsValid, "Orientation of block is not valid.");
CubeGrid = cubeGrid;
ColorMaskHSV = objectBuilder.ColorMaskHSV;
if (BlockDefinition.CubeDefinition != null)
{
//Ensure we have always only one distinct orientation use
Orientation = MyCubeGridDefinitions.GetTopologyUniqueOrientation(BlockDefinition.CubeDefinition.CubeTopology, Orientation);
}
ComputeMax(BlockDefinition, Orientation, ref Min, out Max);
Matrix localMatrix;
Orientation.GetMatrix(out localMatrix);
Position = ComputePositionInGrid(ref localMatrix);
UpdateShowParts();
if (FatBlock == null)
{
bool isRenderedAsModel = !String.IsNullOrEmpty(BlockDefinition.Model);
bool showConstructionModel = BlockDefinition.BlockTopology == MyBlockTopology.Cube && !ShowParts;
if (isRenderedAsModel || showConstructionModel)
{
FatBlock = new MyCubeBlock();
m_soundEmitter.Entity = FatBlock;
}
}
if (FatBlock != null)
{
ProfilerShort.Begin("FatBlock.Init(objectBuilder, ...)");
FatBlock.SlimBlock = this;
FatBlock.Init(objectBuilder, cubeGrid);
ProfilerShort.End();
}
if (objectBuilder.ConstructionStockpile != null)
{
EnsureConstructionStockpileExists();
m_stockpile.Init(objectBuilder.ConstructionStockpile);
}
else if (objectBuilder.ConstructionInventory != null) // Backwards compatibility
{
EnsureConstructionStockpileExists();
m_stockpile.Init(objectBuilder.ConstructionInventory);
}
if (FatBlock == null || FatBlock.GetType() == typeof(MyCubeBlock))
m_objectBuilder = new MyObjectBuilder_CubeBlock();
if (MyFakes.SHOW_DAMAGE_EFFECTS && FatBlock != null && BlockDefinition.RationEnoughForDamageEffect(Integrity / MaxIntegrity))
{//start effect
if (CurrentDamage>0)//fix for weird simple blocks having FatBlock - old save?
{
FatBlock.SetDamageEffect(true);
}
}
ProfilerShort.End();
}
示例3: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
SyncFlag = true;
base.Init(objectBuilder, cubeGrid);
//MyDebug.AssertDebug(objectBuilder.TypeId == typeof(MyObjectBuilder_ShipController));
var def = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
m_enableFirstPerson = BlockDefinition.EnableFirstPerson || MySession.Static.Settings.Enable3rdPersonView == false;
m_enableShipControl = BlockDefinition.EnableShipControl;
m_rechargeSocket = new MyRechargeSocket();
MyObjectBuilder_ShipController shipControllerOb = (MyObjectBuilder_ShipController)objectBuilder;
// No need for backward compatibility of selected weapon, we just leave it alone
// m_selectedGunType = shipControllerOb.SelectedGunType;
m_selectedGunId = shipControllerOb.SelectedGunId;
m_controlThrusters = shipControllerOb.ControlThrusters;
m_controlWheels = shipControllerOb.ControlWheels;
if (shipControllerOb.IsMainCockpit)
{
IsMainCockpit = true;
}
Toolbar = new MyToolbar(ToolbarType);
Toolbar.Init(shipControllerOb.Toolbar, this);
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
// TODO: Seems like overkill
if (Sync.IsServer && false)
{
//Because of simulating thrusts
NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;
}
CubeGrid.OnGridSplit += CubeGrid_OnGridSplit;
}
示例4: GetMountedComponents
public static void GetMountedComponents(MyComponentList addToList, MyObjectBuilder_CubeBlock block)
{
int topGroup = 0;
int topComponent = 0;
MyCubeBlockDefinition blockDef = null;
MyDefinitionManager.Static.TryGetCubeBlockDefinition(block.GetId(), out blockDef);
Debug.Assert(blockDef != null, "Could not find block definition");
if (blockDef == null) return;
Debug.Assert(block!= null, "Getting mounted components of a null block");
if (block == null) return;
float integrity = block.IntegrityPercent * blockDef.MaxIntegrity;
CalculateIndicesInternal(integrity, blockDef, ref topGroup, ref topComponent);
Debug.Assert(topGroup < blockDef.Components.Count(), "Component group overflow in CalculateItemRequirements");
if (topGroup >= blockDef.Components.Count()) return;
Debug.Assert(topComponent < blockDef.Components[topGroup].Count, "Component overflow in CalculateItemRequirements");
if (topComponent >= blockDef.Components[topGroup].Count) return;
int mountCount = topComponent;
if (integrity >= MOUNT_THRESHOLD)
mountCount++;
MyDefinitionId componentId;
for (int group = 0; group < topGroup; ++group)
{
MyCubeBlockDefinition.Component component = blockDef.Components[group];
addToList.AddMaterial(component.Definition.Id, component.Count, addToDisplayList: false);
}
componentId = blockDef.Components[topGroup].Definition.Id;
addToList.AddMaterial(componentId, mountCount, addToDisplayList: false);
}
示例5: GetBattlePoints
public static ulong GetBattlePoints(MyObjectBuilder_CubeBlock block)
{
ulong pts = GetBattlePoints(block.GetId());
MyObjectBuilder_CargoContainer cargoContainer = block as MyObjectBuilder_CargoContainer;
if (cargoContainer != null && cargoContainer.Inventory != null)
{
foreach (var item in cargoContainer.Inventory.Items)
{
if (item.Content is MyObjectBuilder_BlockItem)
{
MyObjectBuilder_BlockItem blockItem = item.Content as MyObjectBuilder_BlockItem;
pts += GetBattlePoints(blockItem.BlockDefId);
}
}
}
return pts;
}
示例6: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
base.Init(objectBuilder, cubeGrid);
PostBaseInit();
//MyDebug.AssertDebug(objectBuilder.TypeId == typeof(MyObjectBuilder_Cockpit));
var def = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
m_isLargeCockpit = (def.CubeSize == MyCubeSize.Large);
m_cockpitInteriorModel = BlockDefinition.InteriorModel;
m_cockpitGlassModel = BlockDefinition.GlassModel;
NeedsUpdate = MyEntityUpdateEnum.EACH_100TH_FRAME;
MyObjectBuilder_Cockpit cockpitOb = (MyObjectBuilder_Cockpit)objectBuilder;
if (cockpitOb.Pilot != null)
{
MyEntity pilotEntity;
MyCharacter pilot = null;
if (MyEntities.TryGetEntityById(cockpitOb.Pilot.EntityId, out pilotEntity))
{ //Pilot already exists, can be the case after cube grid split
pilot = (MyCharacter)pilotEntity;
if (pilot.IsUsing is MyShipController && pilot.IsUsing != this)
{
System.Diagnostics.Debug.Assert(false, "Pilot already sits on another place!");
pilot = null;
}
}
else
{
pilot = (MyCharacter)MyEntities.CreateFromObjectBuilder(cockpitOb.Pilot);
}
if (pilot != null)
{
AttachPilot(pilot, storeOriginalPilotWorld: false, calledFromInit: true);
if (cockpitOb.PilotRelativeWorld.HasValue)
m_pilotRelativeWorld = cockpitOb.PilotRelativeWorld.Value.GetMatrix();
else
m_pilotRelativeWorld = null;
m_singleWeaponMode = cockpitOb.UseSingleWeaponMode;
}
IsInFirstPersonView = cockpitOb.IsInFirstPersonView;
}
if (cockpitOb.Autopilot != null)
{
MyAutopilotBase autopilot = MyAutopilotFactory.CreateAutopilot(cockpitOb.Autopilot);
autopilot.Init(cockpitOb.Autopilot);
AttachAutopilot(autopilot, updateSync: false);
}
m_pilotGunDefinition = cockpitOb.PilotGunDefinition;
// backward compatibility check for automatic rifle without subtype
if (m_pilotGunDefinition.HasValue)
{
if (m_pilotGunDefinition.Value.TypeId == typeof(MyObjectBuilder_AutomaticRifle)
&& string.IsNullOrEmpty(m_pilotGunDefinition.Value.SubtypeName))
m_pilotGunDefinition = new MyDefinitionId(typeof(MyObjectBuilder_AutomaticRifle), "RifleGun");
}
if (!string.IsNullOrEmpty(m_cockpitInteriorModel))
{
if (MyModels.GetModelOnlyDummies(m_cockpitInteriorModel).Dummies.ContainsKey("head"))
m_headLocalPosition = MyModels.GetModelOnlyDummies(m_cockpitInteriorModel).Dummies["head"].Matrix.Translation;
}
else
{
if (MyModels.GetModelOnlyDummies(BlockDefinition.Model).Dummies.ContainsKey("head"))
m_headLocalPosition = MyModels.GetModelOnlyDummies(BlockDefinition.Model).Dummies["head"].Matrix.Translation;
}
AddDebugRenderComponent(new Components.MyDebugRenderComponentCockpit(this));
InitializeConveyorEndpoint();
AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));
m_oxygenLevel = cockpitOb.OxygenLevel;
}
示例7: GetMountedComponents
public static void GetMountedComponents(Dictionary<MyDefinitionId, int> addToDictionary, MyObjectBuilder_CubeBlock block)
{
int topGroup = 0;
int topComponent = 0;
MyCubeBlockDefinition blockDef = null;
MyDefinitionManager.Static.TryGetCubeBlockDefinition(block.GetId(), out blockDef);
Debug.Assert(blockDef != null, "Could not find block definition");
if (blockDef == null) return;
Debug.Assert(block!= null, "Getting mounted components of a null block");
if (block == null) return;
float integrity = block.IntegrityPercent * blockDef.MaxIntegrity;
CalculateIndicesInternal(integrity, blockDef, ref topGroup, ref topComponent);
Debug.Assert(topGroup < blockDef.Components.Count(), "Component group overflow in CalculateItemRequirements");
if (topGroup >= blockDef.Components.Count()) return;
Debug.Assert(topComponent < blockDef.Components[topGroup].Count, "Component overflow in CalculateItemRequirements");
if (topComponent >= blockDef.Components[topGroup].Count) return;
int mountCount = topComponent;
if (integrity >= MOUNT_THRESHOLD)
mountCount++;
MyDefinitionId componentId;
int count = 0;
for (int group = 0; group < topGroup; ++group)
{
componentId = blockDef.Components[group].Definition.Id;
count = addToDictionary.GetValueOrDefault(componentId, 0);
addToDictionary[componentId] = count + blockDef.Components[group].Count;
}
componentId = blockDef.Components[topGroup].Definition.Id;
count = addToDictionary.GetValueOrDefault(componentId, 0);
addToDictionary[componentId] = count + mountCount;
}
示例8: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
base.Init(objectBuilder, cubeGrid);
MyObjectBuilder_ConveyorSorter ob = (MyObjectBuilder_ConveyorSorter)objectBuilder;
DrainAll = ob.DrainAll;
IsWhitelist = ob.IsWhiteList;
foreach (var id in ob.DefinitionIds)
m_inventoryConstraint.Add(id);
foreach (byte b in ob.DefinitionTypes)
{
Tuple<MyObjectBuilderType, StringBuilder> tuple;
if (!CandidateTypes.TryGetValue(b, out tuple))
{
Debug.Assert(false, "type not in dictionary");
continue;
}
m_inventoryConstraint.AddObjectBuilderType(tuple.Item1);
}
m_conveyorSorterDefinition = (MyConveyorSorterDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
m_inventory = new MyInventory(m_conveyorSorterDefinition.InventorySize.Volume, m_conveyorSorterDefinition.InventorySize, MyInventoryFlags.CanSend, this);
m_inventory.Init(ob.Inventory);
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
NeedsUpdate |= Common.MyEntityUpdateEnum.EACH_100TH_FRAME | Common.MyEntityUpdateEnum.EACH_10TH_FRAME;
PowerReceiver = new MyPowerReceiver(
MyConsumerGroupEnum.Conveyors,
false,
BlockDefinition.PowerInput,
UpdatePowerInput);
PowerReceiver.IsPoweredChanged += IsPoweredChanged;
PowerReceiver.Update();
UpdateText();
}