本文整理汇总了C#中VRage.Game.Entity.MyInventoryBase类的典型用法代码示例。如果您正苦于以下问题:C# MyInventoryBase类的具体用法?C# MyInventoryBase怎么用?C# MyInventoryBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyInventoryBase类属于VRage.Game.Entity命名空间,在下文中一共展示了MyInventoryBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetItemAmountCombined
public MyFixedPoint GetItemAmountCombined(MyInventoryBase inventory, MyDefinitionId contentId)
{
int amount = 0;
var group = MyDefinitionManager.Static.GetGroupForComponent(contentId, out amount);
if (group == null)
{
//MyComponentSubstitutionDefinition substitutions;
//if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(contentId, out substitutions))
//{
// foreach (var providingComponent in substitutions.ProvidingComponents)
// {
// amount += (int)inventory.GetItemAmount(providingComponent.Key) / providingComponent.Value;
// }
//}
return amount + inventory.GetItemAmount(contentId, substitute: true);
}
else
{
Clear();
inventory.CountItems(m_componentCounts);
AddItem(group.Id, amount, int.MaxValue);
Solve(m_componentCounts);
return GetSolvedItemCount();
}
}
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:26,代码来源:MyComponentCombiner.cs
示例2: RemoveItemsCombined
protected internal void RemoveItemsCombined(MyInventoryBase inventory, int itemAmount, MyDefinitionId itemDefinitionId)
{
m_materialListCombined.Clear();
m_materialListCombined.AddMaterial(itemDefinitionId, itemAmount);
m_componentCombiner.RemoveItemsCombined(inventory, m_materialListCombined.TotalMaterials);
m_materialListCombined.Clear();
return;
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:8,代码来源:MyBuildComponentBase.cs
示例3: InventoryChanged
void InventoryChanged(MyInventoryBase obj)
{
if (m_clientInventoryUpdate == null)
{
return;
}
foreach (var clientData in m_clientInventoryUpdate)
{
m_clientInventoryUpdate[clientData.Key].Dirty = true;
}
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:11,代码来源:MyEntityInventoryStateGroup.cs
示例4: OnBeforeInventoryRemovedFromAggregate
protected override void OnBeforeInventoryRemovedFromAggregate(Inventory.MyInventoryAggregate aggregate, MyInventoryBase inventory)
{
if (inventory == InputInventory)
{
InputInventory.ContentsChanged += inventory_OnContentsChanged;
}
else if (inventory == OutputInventory)
{
OutputInventory.ContentsChanged += inventory_OnContentsChanged;
}
else
{
Debug.Fail("Added inventory to aggregate, but not input or output invenoty?! This shouldn't happen.");
}
base.OnBeforeInventoryRemovedFromAggregate(aggregate, inventory); // Base method needs to be called here, cuz it removes the inventories from properties
}
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:16,代码来源:MyRefinery.cs
示例5: PasteGrid
public virtual bool PasteGrid(MyInventoryBase buildInventory = null, bool deactivate = true)
{
return PasteGridInternal(buildInventory, deactivate, touchingGrids: m_touchingGrids);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:4,代码来源:MyGridClipboard.cs
示例6: ShowAggregateInventoryScreen
public MyGuiScreenBase ShowAggregateInventoryScreen(MyInventoryBase rightSelectedInventory = null)
{
if (MyPerGameSettings.GUI.InventoryScreen != null)
{
if (InventoryAggregate != null)
{
InventoryAggregate.Init();
m_InventoryScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.InventoryScreen, InventoryAggregate, rightSelectedInventory);
MyGuiSandbox.AddScreen(m_InventoryScreen);
m_InventoryScreen.Closed += (scr) => { if (InventoryAggregate != null) { InventoryAggregate.DetachCallbacks(); } m_InventoryScreen = null; };
}
}
return m_InventoryScreen;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:14,代码来源:MyCharacter.cs
示例7: DecreaseMountLevelToDesiredRatio
public void DecreaseMountLevelToDesiredRatio(float desiredIntegrityRatio, MyInventoryBase outputInventory)
{
float desiredIntegrity = desiredIntegrityRatio * MaxIntegrity;
float grinderAmount = Integrity - desiredIntegrity;
Debug.Assert(grinderAmount >= 0f);
if (grinderAmount <= 0f)
return;
if (FatBlock != null)
grinderAmount *= FatBlock.DisassembleRatio;
else
grinderAmount *= BlockDefinition.DisassembleRatio;
DecreaseMountLevel(grinderAmount / BlockDefinition.IntegrityPointsPerSec, outputInventory, useDefaultDeconstructEfficiency: true);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:15,代码来源:MySlimBlock.cs
示例8: RemoveItemsCombined
public void RemoveItemsCombined(MyInventoryBase inventory, DictionaryReader<MyDefinitionId, int> toRemove)
{
Clear();
foreach (var material in toRemove) // rename material to component
{
int groupAmount = 0;
MyComponentGroupDefinition group = MyDefinitionManager.Static.GetGroupForComponent(material.Key, out groupAmount);
// The component does not belong to any component group => we are looking exactly for the given component
if (group == null)
{
if (MySessionComponentEquivalency.Static != null && MySessionComponentEquivalency.Static.HasEquivalents(material.Key))
{
var eqGroup = MySessionComponentEquivalency.Static.GetEquivalents(material.Key);
if (eqGroup != null)
{
int amountToRemove = material.Value;
foreach (var element in eqGroup)
{
if (amountToRemove > 0)
{
var removed = inventory.RemoveItemsOfType(amountToRemove, element);
amountToRemove -= (int)removed;
}
else
{
break;
}
}
}
}
else
{
inventory.RemoveItemsOfType(material.Value, material.Key);
continue;
}
//MyComponentSubstitutionDefinition substitutionDefinition = null;
//if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(material.Key, out substitutionDefinition))
//{
// int amountToRemove = material.Value;
// foreach (var entry in substitutionDefinition.ProvidingComponents)
// {
// if (amountToRemove > 0)
// {
// var removed = inventory.RemoveItemsOfType(amountToRemove * entry.Value, entry.Key);
// amountToRemove -= (int)removed;
// }
// else
// {
// break;
// }
// }
// if (amountToRemove > 0)
// {
// var removed = inventory.RemoveItemsOfType(amountToRemove, material.Key);
// amountToRemove -= (int)removed;
// }
//}
//else
//{
// inventory.RemoveItemsOfType(material.Value, material.Key);
// continue;
//}
}
else
{
AddItem(group.Id, groupAmount, material.Value);
}
}
inventory.CountItems(m_componentCounts);
bool success = Solve(m_componentCounts);
Debug.Assert(success, "Could not combine required items!");
inventory.ApplyChanges(m_solution);
/*CheckUpdate();
m_remainder.Clear();
foreach (var material in toRemove)
{
m_remainder.Add(material.Key, material.Value);
}
bool success = true;
m_cuttingSolver.Clear();
foreach (var material in m_remainder)
{
int groupAmount = 0;
MyComponentGroupDefinition group = MyDefinitionManager.Static.GetGroupForComponent(material.Key, out groupAmount);
// The component does not belong to any component group => we are looking exactly for the given component
if (group == null)
{
success &= RemoveItemsOfTypeInternal(material.Key, material.Value);
Debug.Assert(success, "Could not find the required component although we were permitted to build!");
//.........这里部分代码省略.........
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:101,代码来源:MyComponentCombiner.cs
示例9: TryGetInventory
// ----------- inventory --------------------
public static bool TryGetInventory(this MyEntity thisEntity, out MyInventoryBase inventoryBase)
{
inventoryBase = null;
return thisEntity.Components.TryGet<MyInventoryBase>(out inventoryBase);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyEntityExtensions.cs
示例10: MoveItemsToConstructionStockpile
public void MoveItemsToConstructionStockpile(MyInventoryBase fromInventory)
{
if (MySession.Static.CreativeMode)
return;
m_tmpComponents.Clear();
GetMissingComponents(m_tmpComponents);
if (m_tmpComponents.Count != 0)
{
EnsureConstructionStockpileExists();
m_stockpile.ClearSyncList();
foreach (var kv in m_tmpComponents)
{
var id = new MyDefinitionId(typeof(MyObjectBuilder_Component), kv.Key);
int amountAvailable = (int)MyCubeBuilder.BuildComponent.GetItemAmountCombined(fromInventory, id);
int moveAmount = Math.Min(kv.Value, amountAvailable);
if (moveAmount > 0)
{
MyCubeBuilder.BuildComponent.RemoveItemsCombined(fromInventory, moveAmount, id);
m_stockpile.AddItems((int)moveAmount, new MyDefinitionId(typeof(MyObjectBuilder_Component), kv.Key));
}
}
CubeGrid.SendStockpileChanged(this, m_stockpile.GetSyncList());
m_stockpile.ClearSyncList();
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MySlimBlock.cs
示例11: AddBlockComponent
private static void AddBlockComponent(MyHudBlockInfo hudInfo, MyComponentStack.GroupInfo groupInfo, MyInventoryBase availableInventory)
{
var componentInfo = new MyHudBlockInfo.ComponentInfo();
componentInfo.DefinitionId = groupInfo.Component.Id;
componentInfo.ComponentName = groupInfo.Component.DisplayNameText;
componentInfo.Icons = groupInfo.Component.Icons;
componentInfo.TotalCount = groupInfo.TotalCount;
componentInfo.MountedCount = groupInfo.MountedCount;
if (availableInventory != null)
componentInfo.AvailableAmount = (int)MyCubeBuilder.BuildComponent.GetItemAmountCombined(availableInventory, groupInfo.Component.Id);
hudInfo.Components.Add(componentInfo);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:13,代码来源:MySlimBlock.cs
示例12: SetBlockComponentsInternal
// CH: TODO: This method actually doesn't have a bad internal structure, but it should be refactored BIG TIME (and put to MyHudBlockInfo)!
private static void SetBlockComponentsInternal(MyHudBlockInfo hudInfo, MyCubeBlockDefinition blockDefinition, MySlimBlock block, MyInventoryBase availableInventory)
{
hudInfo.Components.Clear();
if (block != null)
{
Debug.Assert(block.BlockDefinition == blockDefinition, "The definition given to SetBlockComponnentsInternal was not a definition of the block");
}
hudInfo.InitBlockInfo(blockDefinition);
hudInfo.ShowAvailable = MyPerGameSettings.AlwaysShowAvailableBlocksOnHud;
if (!MyFakes.ENABLE_SMALL_GRID_BLOCK_COMPONENT_INFO && blockDefinition.CubeSize == MyCubeSize.Small) return;
if (block != null)
{
hudInfo.BlockIntegrity = block.Integrity / block.MaxIntegrity;
}
// CH: TODO: Multiblocks
if (block != null && block.IsMultiBlockPart)
{
var multiBlockInfo = block.CubeGrid.GetMultiBlockInfo(block.MultiBlockId);
Debug.Assert(multiBlockInfo != null);
if (multiBlockInfo != null)
{
// Load all block definition components
foreach (var blockDefId in multiBlockInfo.MultiBlockDefinition.BlockDefinitions)
{
MyCubeBlockDefinition blockDef;
if (MyDefinitionManager.Static.TryGetCubeBlockDefinition(blockDefId.Id, out blockDef))
{
hudInfo.AddComponentsForBlock(blockDef);
}
}
// Merge components from all blocks
hudInfo.MergeSameComponents();
// Add mounted counts to components
foreach (var multiBlockPart in multiBlockInfo.Blocks)
{
for (int j = 0; j < multiBlockPart.BlockDefinition.Components.Length; ++j)
{
var comp = multiBlockPart.BlockDefinition.Components[j];
var groupInfo = multiBlockPart.ComponentStack.GetGroupInfo(j);
for (int i = 0; i < hudInfo.Components.Count; i++)
{
if (hudInfo.Components[i].DefinitionId == comp.Definition.Id)
{
var c = hudInfo.Components[i];
c.MountedCount += groupInfo.MountedCount;
hudInfo.Components[i] = c;
break;
}
}
}
}
// Inventory counts
for (int i = 0; i < hudInfo.Components.Count; i++)
{
if (availableInventory != null)
{
var c = hudInfo.Components[i];
c.AvailableAmount = (int)MyCubeBuilder.BuildComponent.GetItemAmountCombined(availableInventory, c.DefinitionId);
hudInfo.Components[i] = c;
}
// Get amount in stockpile
int amount = 0;
foreach (var multiBlockPart in multiBlockInfo.Blocks)
{
if (!multiBlockPart.StockpileEmpty)
amount += multiBlockPart.GetConstructionStockpileItemAmount(hudInfo.Components[i].DefinitionId);
}
if (amount > 0)
{
//RKTODO: ??? see below code for non multiblocks
/*amount =*/ SetHudInfoComponentAmount(hudInfo, amount, i);
}
}
}
}
else if (block == null && blockDefinition.MultiBlock != null)
{
MyDefinitionId defId = new MyDefinitionId(typeof(MyObjectBuilder_MultiBlockDefinition), blockDefinition.MultiBlock);
var mbDefinition = MyDefinitionManager.Static.TryGetMultiBlockDefinition(defId);
if (mbDefinition != null)
{
foreach (var blockDefId in mbDefinition.BlockDefinitions)
{
MyCubeBlockDefinition blockDef;
if (MyDefinitionManager.Static.TryGetCubeBlockDefinition(blockDefId.Id, out blockDef))
{
hudInfo.AddComponentsForBlock(blockDef);
}
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:101,代码来源:MySlimBlock.cs
示例13: SetBlockComponents
public static void SetBlockComponents(MyHudBlockInfo hudInfo, MyCubeBlockDefinition blockDefinition, MyInventoryBase availableInventory = null)
{
SetBlockComponentsInternal(hudInfo, blockDefinition, null, availableInventory);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:4,代码来源:MySlimBlock.cs
示例14: DeconstructStockpile
private void DeconstructStockpile(float deconstructAmount, MyInventoryBase outputInventory, bool useDefaultDeconstructEfficiency = false)
{
Debug.Assert(Sync.IsServer, "This method is only meant to be called on the server!");
if (MySession.Static.CreativeMode)
{
ClearConstructionStockpile(outputInventory);
}
else
{
EnsureConstructionStockpileExists();
}
if (m_stockpile != null)
{
m_stockpile.ClearSyncList();
m_componentStack.DecreaseMountLevel(deconstructAmount, m_stockpile, useDefaultDeconstructEfficiency: useDefaultDeconstructEfficiency);
CubeGrid.SendStockpileChanged(this, m_stockpile.GetSyncList());
m_stockpile.ClearSyncList();
}
else
{
m_componentStack.DecreaseMountLevel(deconstructAmount, null, useDefaultDeconstructEfficiency: useDefaultDeconstructEfficiency);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:24,代码来源:MySlimBlock.cs
示例15: DecreaseMountLevel
public void DecreaseMountLevel(float grinderAmount, MyInventoryBase outputInventory, bool useDefaultDeconstructEfficiency = false)
{
Debug.Assert(Sync.IsServer, "This method is only meant to be called on the server!");
if (!Sync.IsServer||m_componentStack.IsFullyDismounted)
return;
if (FatBlock != null)
grinderAmount /= FatBlock.DisassembleRatio;
else
grinderAmount /= BlockDefinition.DisassembleRatio;
grinderAmount = grinderAmount * BlockDefinition.IntegrityPointsPerSec;
float oldBuildRatio = m_componentStack.BuildRatio;
DeconstructStockpile(grinderAmount, outputInventory, useDefaultDeconstructEfficiency: useDefaultDeconstructEfficiency);
float newBuildRatio = (BuildIntegrity - grinderAmount) / BlockDefinition.MaxIntegrity;
//Call Integrity Changed if owner is nobody or is not local player
if (BlockDefinition.RatioEnoughForDamageEffect(BuildLevelRatio))
{
if (FatBlock != null && FatBlock.OwnerId != 0 && FatBlock.OwnerId != MySession.Static.LocalPlayerId)
{
FatBlock.OnIntegrityChanged(BuildIntegrity, Integrity, false, MySession.Static.LocalPlayerId);
}
}
long toolOwner = 0;
if (outputInventory != null && outputInventory.Entity != null)
{
var inventoryOwner = outputInventory.Entity;
var moduleOwner = inventoryOwner as IMyComponentOwner<MyIDModule>;
var character = inventoryOwner as MyCharacter;
if (moduleOwner == null)
{
if (character != null)
{
Debug.Assert(character.ControllerInfo.Controller != null, "Controller was null on the character in DecreaseMountLevel!");
if (character.ControllerInfo.Controller == null)
toolOwner = character.ControllerInfo.ControllingIdentityId;
}
}
else
{
MyIDModule module;
if (moduleOwner.GetComponent(out module))
toolOwner = module.Owner;
}
}
UpdateHackingIndicator(newBuildRatio, oldBuildRatio, toolOwner);
bool modelChangeNeeded = BlockDefinition.ModelChangeIsNeeded(m_componentStack.BuildRatio, oldBuildRatio);
MyIntegrityChangeEnum integrityChangeType = MyIntegrityChangeEnum.Damage;
if (modelChangeNeeded)
{
UpdateVisual();
if (FatBlock != null)
{
int buildProgressID = CalculateCurrentModelID();
if ((buildProgressID == -1) || (BuildLevelRatio == 0f))
{
integrityChangeType = MyIntegrityChangeEnum.ConstructionEnd;
}
else if (buildProgressID == BlockDefinition.BuildProgressModels.Length - 1)
{
integrityChangeType = MyIntegrityChangeEnum.ConstructionBegin;
}
else
{
integrityChangeType = MyIntegrityChangeEnum.ConstructionProcess;
}
}
PlayConstructionSound(integrityChangeType, true);
CreateConstructionSmokes();
}
if (CubeGrid.GridSystems.GasSystem != null)
{
CubeGrid.GridSystems.GasSystem.Pressurize();
}
if (MyFakes.ENABLE_GENERATED_BLOCKS && !BlockDefinition.IsGeneratedBlock && BlockDefinition.GeneratedBlockDefinitions != null && BlockDefinition.GeneratedBlockDefinitions.Length > 0)
{
UpdateProgressGeneratedBlocks(oldBuildRatio);
}
CubeGrid.SendIntegrityChanged(this, integrityChangeType, toolOwner);
CubeGrid.OnIntegrityChanged(this);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:92,代码来源:MySlimBlock.cs
示例16: IncreaseMountLevel
public void IncreaseMountLevel(float welderMountAmount, long welderOwnerPlayerId, MyInventoryBase outputInventory = null, float maxAllowedBoneMovement = 0.0f, bool isHelping = false, MyOwnershipShareModeEnum sharing = MyOwnershipShareModeEnum.Faction)
{
ProfilerShort.Begin("MySlimBlock.IncreaseMountLevel");
welderMountAmount *= BlockDefinition.IntegrityPointsPerSec;
MySession.Static.PositiveIntegrityTotal += welderMountAmount;
if (MySession.Static.CreativeMode)
{
ClearConstructionStockpile(outputInventory);
}
else
{
MyEntity inventoryOwner = null;
if (outputInventory != null && outputInventory.Container != null)
inventoryOwner = outputInventory.Container.Entity as MyEntity;
if (inventoryOwner != null && inventoryOwner.InventoryOwnerType() == MyInventoryOwnerTypeEnum.Character)
{
MoveItemsFromConstructionStockpile(outputInventory, MyItemFlags.Damaged);
}
}
float oldPercentage = m_componentStack.BuildRatio;
float oldDamage = CurrentDamage;
//Add ownership check in order for the IntegrityChanged not to be called many times
if (BlockDefinition.RatioEnoughForOwnership(BuildLevelRatio))
{
if (FatBlock != null && FatBlock.OwnerId == 0 && outputInventory != null && !isHelping)
{
FatBlock.OnIntegrityChanged(BuildIntegrity, Integrity, true, welderOwnerPlayerId, sharing);
}
}
if (MyFakes.SHOW_DAMAGE_EFFECTS && FatBlock != null && !BlockDefinition.RatioEnoughForDamageEffect((Integrity + welderMountAmount) / MaxIntegrity))
{//stop effect
FatBlock.SetDamageEffect(false);
}
bool removeDecals = false;
if (m_stockpile != null)
{
m_stockpile.ClearSyncList();
m_componentStack.IncreaseMountLevel(welderMountAmount, m_stockpile);
CubeGrid.SendStockpileChanged(this, m_stockpile.GetSyncList());
m_stockpile.ClearSyncList();
}
else
{
m_componentStack.IncreaseMountLevel(welderMountAmount, null);
}
if (m_componentStack.IsFullIntegrity)
{
ReleaseConstructionStockpile();
removeDecals = true;
}
ProfilerShort.Begin("ModelChange");
MyIntegrityChangeEnum integrityChangeType = MyIntegrityChangeEnum.Damage;
if (BlockDefinition.ModelChangeIsNeeded(oldPercentage, m_componentStack.BuildRatio) || BlockDefinition.ModelChangeIsNeeded(m_componentStack.BuildRatio, oldPercentage))
{
removeDecals = true;
if (FatBlock != null)
{
// this needs to be detected here because for cubes the following call to UpdateVisual() set FatBlock to null when the construction is complete
if (m_componentStack.IsFunctional)
{
integrityChangeType = MyIntegrityChangeEnum.ConstructionEnd;
}
}
UpdateVisual();
if (FatBlock != null)
{
int buildProgressID = CalculateCurrentModelID();
if (buildProgressID == 0)
{
integrityChangeType = MyIntegrityChangeEnum.ConstructionBegin;
}
else if (!m_componentStack.IsFunctional)
{
integrityChangeType = MyIntegrityChangeEnum.ConstructionProcess;
}
}
PlayConstructionSound(integrityChangeType);
CreateConstructionSmokes();
if (CubeGrid.GridSystems.GasSystem != null)
{
CubeGrid.GridSystems.GasSystem.Pressurize();
}
}
ProfilerShort.End();
if (HasDeformation)
CubeGrid.SetBlockDirty(this);
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:101,代码来源:MySlimBlock.cs
示例17: PasteGridInternal
protected bool PasteGridInternal(MyInventoryBase buildInventory, bool deactivate, List<MyObjectBuilder_CubeGrid> pastedBuilders = null, List<MyCubeGrid> touchingGrids = null,
UpdateAfterPasteCallback updateAfterPasteCallback = null, bool multiBlock = false)
{
if (m_copiedGrids.Count == 0)
return false;
if ((m_copiedGrids.Count > 0) && !IsActive)
{
Activate();
return true;
}
if (!CanBePlaced)
{
MyGuiAudio.PlaySound(MyGuiSounds.HudUnable);
return false;
}
if (!IsWithinWorldLimits())
{
MyGuiAudio.PlaySound(MyGuiSounds.HudUnable);
MyHud.Notifications.Add(MyNotificationSingletons.ShipOverLimits);
return false;
}
if (m_previewGrids.Count == 0)
return false;
foreach (var grid in m_copiedGrids)
{
foreach (var block in grid.CubeBlocks)
{
block.BuiltBy = MySession.Static.LocalPlayerId;
}
}
bool missingBlockDefinitions = false;
if (ShowModdedBlocksWarning)
{
missingBlockDefinitions = !CheckPastedBlocks();
}
if (missingBlockDefinitions)
{
AllowSwitchCameraMode = false;
var messageBox = MyGuiSandbox.CreateMessageBox(
styleEnum: MyMessageBoxStyleEnum.Info,
buttonType: MyMessageBoxButtonsType.YES_NO,
messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextDoYouWantToPasteGridWithMissingBlocks),
messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionWarning),
callback: (result) =>
{
if (result == MyGuiScreenMessageBox.ResultEnum.YES)
{
PasteInternal(buildInventory, missingBlockDefinitions, deactivate, pastedBuilders, updateAfterPasteCallback: updateAfterPasteCallback, multiBlock: multiBlock);
}
AllowSwitchCameraMode = true;
});
MyGuiSandbox.AddScreen(messageBox);
return false;
}
return PasteInternal(buildInventory, missingBlockDefinitions, deactivate, pastedBuilders: pastedBuilders, touchingGrids: touchingGrids,
updateAfterPasteCallback: updateAfterPasteCallback, multiBlock: multiBlock);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:65,代码来源:MyGridClipboard.cs
示例18: PasteInternal
private bool PasteInternal(MyInventoryBase buildInventory, bool missingDefinitions, bool deactivate, List<MyObjectBuilder_CubeGrid> pastedBuilders = null, List<MyCubeGrid> touchingGrids = null,
UpdateAfterPasteCallback updateAfterPasteCallback = null, bool multiBlock = false)
{
var copiedLocalGrids = new List<MyObjectBuilder_CubeGrid>();
foreach (var gridCopy in m_copiedGrids)
{
copiedLocalGrids.Add((MyObjectBuilder_CubeGrid)gridCopy.Clone());
}
var grid = copiedLocalGrids[0];
bool isMergeNeeded = IsSnapped && SnapMode == SnapMode.Base6Directions && m_hitEntity is MyCubeGrid && grid != null && ((MyCubeGrid)m_hitEntity).GridSizeEnum == grid.GridSizeEnum;
if (isMergeNeeded && !IsMergeWithinWorldLimits())
{
MyGuiAudio.PlaySound(MyGuiSounds.HudUnable);
MyHud.Notifications.Add(MyNotificationSingletons.ShipOverLimits);
return false;
}
MyGuiAudio.PlaySound(MyGuiSounds.HudPlaceBlock);
MyCubeGrid hitGrid = null;
if(isMergeNeeded)
{
hitGrid = m_hitEntity as MyCubeGrid;
}
isMergeNeeded |= touchingGrids != null && touchingGrids.Count > 0;
if(hitGrid == null && touchingGrids != null && touchingGrids.Count > 0)
{
hitGrid = touchingGrids[0];
}
int i = 0;
foreach (var gridBuilder in copiedLocalGrids)
{
gridBuilder.CreatePhysics = true;
gridBuilder.EnableSmallToLargeConnections = true;
gridBuilder.PositionAndOrientation = new MyPositionAndOrientation(m_previewGrids[i].WorldMatrix);
gridBuilder.PositionAndOrientation.Value.Orientation.Normalize();
i++;
}
long inventoryOwnerId = 0;
if (buildInventory != null)
{
if (MyFakes.ENABLE_MEDIEVAL_INVENTORY)
{
inventoryOwnerId = buildInventory.Entity.EntityId;
}
else if( buildInventory is MyInventory)
{
inventoryOwnerId = (buildInventory as MyInventory).Owner.EntityId;
}
}
bool isAdmin = MySession.Static.IsAdminModeEnabled(Sync.MyId);
if (isMergeNeeded && hitGrid != null)
{
hitGrid.PasteBlocksToGrid(copiedLocalGrids, inventoryOwnerId, multiBlock, isAdmin);
}
//TODO: GZA - This is connected with creational clipboards used to create new grids in space. Should be removed later.
else if(CreationMode)
{
MyMultiplayer.RaiseStaticEvent(s => MyCubeGrid.TryCreateGrid_Implementation, CubeSize, IsStatic, copiedLocalGrids[0].PositionAndOrientation.Value, inventoryOwnerId, isAdmin);
CreationMode = false;
}
else if (MySession.Static.CreativeMode || MySession.Static.HasAdminRights)
{
bool anyGridInGround = false;
bool anyGridIsSmall = false;
foreach (var prevGrid in m_previewGrids)
{
anyGridIsSmall |= prevGrid.GridSizeEnum == MyCubeSize.Small;
var settings = m_settings.GetGridPlacementSettings(prevGrid.GridSizeEnum, prevGrid.IsStatic);
anyGridInGround |= MyCubeGrid.IsAabbInsideVoxel(prevGrid.PositionComp.WorldMatrix, (BoundingBoxD)prevGrid.PositionComp.LocalAABB, settings);
}
bool smallInMedieval = false;
if (MyPerGameSettings.Game == GameEnum.ME_GAME)
{
MyCubeGrid hitEntGrid = m_hitEntity as MyCubeGrid;
if (hitEntGrid != null)
smallInMedieval = anyGridIsSmall && (hitEntGrid.GridSizeEnum == MyCubeSize.Large);
}
foreach (var gridOb in copiedLocalGrids)
{
gridOb.IsStatic = smallInMedieval || anyGridInGround || (MySession.Static.EnableConvertToStation && gridOb.IsStatic);
}
if (!MySandboxGame.IsDedicated)
{
MyHud.PushRotatingWheelVisible();
}
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:101,代码来源:MyGridClipboard.cs
示例19: MoveItemsFromConstructionStockpile
/// <summary>
/// Moves items with the given flags from the construction inventory to the character.
/// If the flags are None, all items are moved.
/// </summary>
public void MoveItemsFromConstructionStockpile(MyInventoryBase toInventory, MyItemFlags flags = MyItemFlags.None)
{
if (m_stockpile == null) return;
Debug.Assert(toInventory != null);
if (toInventory == null) return;
m_tmpItemList.Clear();
foreach (var item in m_stockpile.GetItems())
{
if (flags == MyItemFlags.None || (item.Content.Flags & flags) != 0)
m_tmpItemList.Add(item);
}
m_stockpile.ClearSyncList();
foreach (var item in m_tmpItemList)
{
var amount = toInventory.ComputeAmountThatFits(item.Content.GetId()).ToIntSafe();
amount = Math.Min(amount, item.Amount);
toInventory.AddItems(amount, item.Content);
m_stockpile.RemoveItems(amount, item.Content);
}
CubeGrid.SendStockpileChanged(this, m_stockpile.GetSyncList());
m_stockpile.ClearSyncList();
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MySlimBlock.cs
示例20: OnInventoryComponentRemoved
protected virtual void OnInventoryComponentRemoved(MyInventoryBase inventory) { }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:1,代码来源:MyEntity.cs
注:本文中的VRage.Game.Entity.MyInventoryBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论