本文整理汇总了C#中Sandbox.Game.EntityComponents.MyResourceSourceComponent类的典型用法代码示例。如果您正苦于以下问题:C# MyResourceSourceComponent类的具体用法?C# MyResourceSourceComponent怎么用?C# MyResourceSourceComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyResourceSourceComponent类属于Sandbox.Game.EntityComponents命名空间,在下文中一共展示了MyResourceSourceComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MySolarPanel
public MySolarPanel()
{
SourceComp = new MyResourceSourceComponent();
m_soundEmitter = new MyEntity3DSoundEmitter(this, true);
NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
}
示例2: MyGasTank
public MyGasTank()
{
CreateTerminalControls();
SourceComp = new MyResourceSourceComponent();
ResourceSink = new MyResourceSinkComponent(2);
}
示例3: MyBattery
public MyBattery(MyCharacter owner)
{
m_owner = owner;
SyncObject = new MySyncBattery(this);
ResourceSink = new MyResourceSinkComponent();
ResourceSource = new MyResourceSourceComponent();
}
示例4: MyReactor
public MyReactor()
{
CreateTerminalControls();
SourceComp = new MyResourceSourceComponent();
m_remainingPowerCapacity.ValueChanged += (x) => RemainingCapacityChanged();
m_remainingPowerCapacity.ValidateNever();
}
示例5: MyGasGenerator
public MyGasGenerator()
{
#if XB1 // XB1_SYNC_NOREFLECTION
m_useConveyorSystem = SyncType.CreateAndAddProp<bool>();
#endif // XB1
CreateTerminalControls();
SourceComp = new MyResourceSourceComponent(2);
ResourceSink = new MyResourceSinkComponent();
}
示例6: MyPhysicalDistributionGroup
public MyPhysicalDistributionGroup(MyDefinitionId typeId, MyResourceSourceComponent tempConnectedSource)
{
SinksByPriority = null; SourcesByPriority = null; SinkSourcePairs = null; FirstEndpoint = null;
SinkDataByPriority = null; SourceDataByPriority = null; StockpilingStorage = null; OtherStorage = null;
InputOutputData = new MyTuple<MySinkGroupData, MySourceGroupData>();
MaxAvailableResources = 0f; ResourceState = MyResourceStateEnum.NoPower;
AllocateData();
InitFromTempConnected(typeId, tempConnectedSource);
}
示例7: MyAirVent
public MyAirVent()
{
#if XB1 // XB1_SYNC_NOREFLECTION
m_isDepressurizing = SyncType.CreateAndAddProp<bool>();
#endif // XB1
CreateTerminalControls();
ResourceSink = new MyResourceSinkComponent(2);
SourceComp = new MyResourceSourceComponent();
m_isDepressurizing.ValueChanged += (x) => SetDepressurizing();
}
示例8: MyReactor
public MyReactor()
{
#if XB1 // XB1_SYNC_NOREFLECTION
m_remainingPowerCapacity = SyncType.CreateAndAddProp<float>();
m_useConveyorSystem = SyncType.CreateAndAddProp<bool>();
#endif // XB1
CreateTerminalControls();
SourceComp = new MyResourceSourceComponent();
m_remainingPowerCapacity.ValueChanged += (x) => RemainingCapacityChanged();
m_remainingPowerCapacity.ValidateNever();
}
示例9: RemoveSourceLazy
private void RemoveSourceLazy(MyResourceSourceComponent source)
{
foreach (var resourceTypeId in source.ResourceTypes)
{
MyDefinitionId typeId = resourceTypeId;
var sourcesOfType = GetSourcesOfType(ref typeId, source.Group);
if (sourcesOfType == null)
{
Debug.Fail("SourcesOfType is null on removal of " + typeId.ToString());
continue;
}
var typeIndex = GetTypeIndex(ref typeId);
if (!sourcesOfType.Remove(source))
{
int foundIndex = -1;
for (int pairIndex = 0; pairIndex < m_dataPerType[typeIndex].InputOutputList.Count; ++pairIndex)
{
if (m_dataPerType[typeIndex].InputOutputList[pairIndex].Item2 != source)
continue;
foundIndex = pairIndex;
break;
}
if (foundIndex != -1)
{
var matchingSink = m_dataPerType[typeIndex].InputOutputList[foundIndex].Item1;
m_dataPerType[typeIndex].InputOutputList.RemoveAtFast(foundIndex);
m_dataPerType[typeIndex].SinksByPriority[GetPriority(matchingSink)].Add(matchingSink);
}
}
m_dataPerType[typeIndex].NeedsRecompute = true;
m_dataPerType[typeIndex].GroupsDirty = true;
--m_dataPerType[typeIndex].SourceCount;
if (m_dataPerType[typeIndex].SourceCount == 0)
{
m_dataPerType[typeIndex].SourcesEnabled= MyMultipleEnabledEnum.NoObjects;
}
else if (m_dataPerType[typeIndex].SourceCount== 1)
{
var firstSourceOfType = GetFirstSourceOfType(ref typeId);
if (firstSourceOfType != null)
ChangeSourcesState(typeId, (firstSourceOfType.Enabled) ? MyMultipleEnabledEnum.AllEnabled : MyMultipleEnabledEnum.AllDisabled, MySession.Static.LocalPlayerId);
else
{
// Bug Fix - When battery is on grid it somehow leaves Sources = 1 even tought that no sources are present
--m_dataPerType[typeIndex].SourceCount;
m_dataPerType[typeIndex].SourcesEnabled = MyMultipleEnabledEnum.NoObjects;
}
}
else if (m_dataPerType[typeIndex].SourcesEnabled == MyMultipleEnabledEnum.Mixed)
{
// We were in mixed state and need to check whether we still are.
m_dataPerType[typeIndex].SourcesEnabledDirty = true;
}
m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
}
source.ProductionEnabledChanged -= source_ProductionEnabledChanged;
source.MaxOutputChanged -= source_MaxOutputChanged;
source.HasCapacityRemainingChanged -= source_HasRemainingCapacityChanged;
}
示例10: AddSourceLazy
private void AddSourceLazy(MyResourceSourceComponent source)
{
foreach (var resourceType in source.ResourceTypes)
{
var typeId = resourceType;
if(!m_initializedTypes.Contains(typeId))
InitializeNewType(ref typeId);
var sourcesOfType = GetSourcesOfType(ref typeId, source.Group);
if (sourcesOfType == null)
{
Debug.Fail("SourcesOfType is null on add of " + typeId.ToString());
continue;
}
int typeIndex = GetTypeIndex(ref typeId);
Debug.Assert(!sourcesOfType.Contains(source));
Debug.Assert(MatchesInfiniteCapacity(sourcesOfType, source), "All producers in the same group must have same 'infinite capacity' state.");
MyResourceSinkComponent matchingSink = null;
if (source.Container != null)
{
foreach (var sinks in m_dataPerType[typeIndex].SinksByPriority)
{
foreach (var sink in sinks)
{
if (sink.Container == null)
continue;
var sourceInContainer = sink.Container.Get<MyResourceSourceComponent>();
if (sourceInContainer == source)
{
m_dataPerType[typeIndex].InputOutputList.Add(MyTuple.Create(sink, source));
matchingSink = sink;
break;
}
}
if (matchingSink == null)
continue;
sinks.Remove(matchingSink);
break;
}
}
if (matchingSink == null)
sourcesOfType.Add(source);
m_dataPerType[typeIndex].NeedsRecompute = true;
m_dataPerType[typeIndex].GroupsDirty = true;
++m_dataPerType[typeIndex].SourceCount;
if (m_dataPerType[typeIndex].SourceCount == 1)
{
// This is the only source we have, so the state of all is the same as of this one.
m_dataPerType[typeIndex].SourcesEnabled = (source.Enabled) ? MyMultipleEnabledEnum.AllEnabled : MyMultipleEnabledEnum.AllDisabled;
}
else if ((m_dataPerType[typeIndex].SourcesEnabled == MyMultipleEnabledEnum.AllEnabled && !source.Enabled) || (m_dataPerType[typeIndex].SourcesEnabled == MyMultipleEnabledEnum.AllDisabled && source.Enabled))
{
m_dataPerType[typeIndex].SourcesEnabled = MyMultipleEnabledEnum.Mixed;
}
m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
}
source.HasCapacityRemainingChanged += source_HasRemainingCapacityChanged;
source.MaxOutputChanged += source_MaxOutputChanged;
source.ProductionEnabledChanged += source_ProductionEnabledChanged;
}
示例11: MyReactor
public MyReactor()
{
m_soundEmitter = new MyEntity3DSoundEmitter(this);
SourceComp = new MyResourceSourceComponent();
}
示例12: source_ProductionEnabledChanged
private void source_ProductionEnabledChanged(MyDefinitionId changedResourceTypeId, MyResourceSourceComponent obj)
{
int typeIndex = GetTypeIndex(ref changedResourceTypeId);
m_dataPerType[typeIndex].NeedsRecompute = true;
m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
m_dataPerType[typeIndex].SourcesEnabledDirty = true;
if (m_dataPerType[typeIndex].SourceCount == 1)
RecomputeResourceDistribution(ref changedResourceTypeId);
}
示例13: RemoveSource
public void RemoveSource(MyResourceSourceComponent source)
{
Debug.Assert(source != null);
lock (m_sourcesToAdd)
{
if (m_sourcesToAdd.Contains(source))
{
m_sourcesToAdd.Remove(source);
RemoveTypesFromChanges(source.ResourceTypes);
return;
}
}
lock (m_sourcesToRemove)
{
m_sourcesToRemove.Add(source);
}
foreach (var resourceType in source.ResourceTypes)
{
int existingCount;
if (!m_changedTypes.TryGetValue(resourceType, out existingCount))
m_changedTypes.Add(resourceType, 1);
else
m_changedTypes[resourceType] = existingCount+1;
}
}
示例14: GetPriority
static internal int GetPriority(MyResourceSourceComponent source)
{
return m_sourceSubtypeToPriority[source.Group];
}
示例15: source_HasRemainingCapacityChanged
private void source_HasRemainingCapacityChanged(MyDefinitionId changedResourceTypeId, MyResourceSourceComponent source)
{
int typeIndex = GetTypeIndex(ref changedResourceTypeId);
m_dataPerType[typeIndex].NeedsRecompute = true;
m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
}