本文整理汇总了C#中Sandbox.Game.EntityComponents.MyResourceSinkComponent.Update方法的典型用法代码示例。如果您正苦于以下问题:C# MyResourceSinkComponent.Update方法的具体用法?C# MyResourceSinkComponent.Update怎么用?C# MyResourceSinkComponent.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox.Game.EntityComponents.MyResourceSinkComponent
的用法示例。
在下文中一共展示了MyResourceSinkComponent.Update方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
base.Init(objectBuilder, cubeGrid);
ResourceSink = new MyResourceSinkComponent();
ResourceSink.Init(
BlockDefinition.ResourceSinkGroup,
BlockDefinition.RequiredPowerInput,
this.CalculateRequiredPowerInput);
ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
ResourceSink.Update();
if (Physics != null)
{
Physics.Close();
}
var detectorShape = new HkBoxShape(new Vector3(cubeGrid.GridSize / 3.0f));
var massProperties = HkInertiaTensorComputer.ComputeBoxVolumeMassProperties(detectorShape.HalfExtents, BlockDefinition.VirtualMass);
Physics = new Engine.Physics.MyPhysicsBody(this, RigidBodyFlag.RBF_DEFAULT);
Physics.IsPhantom = false;
Physics.CreateFromCollisionObject(detectorShape, Vector3.Zero, WorldMatrix, massProperties, MyPhysics.VirtualMassLayer);
Physics.Enabled = IsWorking && cubeGrid.Physics != null && cubeGrid.Physics.Enabled;
Physics.RigidBody.Activate();
detectorShape.Base.RemoveReference();
UpdateText();
NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME;
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
}
示例2: PlugIn
public void PlugIn(MyResourceSinkComponent consumer)
{
if (m_pluggedInConsumer == consumer)
return;
Debug.Assert(m_pluggedInConsumer == null, "Consumer already plugged in.");
m_pluggedInConsumer = consumer;
if (m_resourceDistributor != null)
{
m_resourceDistributor.AddSink(consumer);
consumer.Update();
}
}
示例3: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
var beaconDefinition = BlockDefinition as MyBeaconDefinition;
Debug.Assert(beaconDefinition != null);
var sinkComp = new MyResourceSinkComponent();
sinkComp.Init(
MyStringHash.GetOrCompute(beaconDefinition.ResourceSinkGroup),
MyEnergyConstants.MAX_REQUIRED_POWER_BEACON,
UpdatePowerInput);
ResourceSink = sinkComp;
RadioBroadcaster = new MyRadioBroadcaster(10000);
if (((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius != 0)
RadioBroadcaster.BroadcastRadius = ((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius;
base.Init(objectBuilder, cubeGrid);
sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
sinkComp.Update();
RadioBroadcaster.OnBroadcastRadiusChanged += OnBroadcastRadiusChanged;
m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large;
m_light = MyLights.AddLight();
m_light.Start(MyLight.LightTypeEnum.PointLight, 1.5f);
m_light.LightOwner = m_largeLight ? MyLight.LightOwnerEnum.LargeShip : MyLight.LightOwnerEnum.SmallShip;
m_light.UseInForwardRender = true;
m_light.Range = 1;
m_light.GlareOn = true;
m_light.GlareIntensity = m_largeLight ? 2 : 1;
m_light.GlareQuerySize = m_largeLight ? 15f : 0.2f;
m_light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Distant;
m_light.GlareMaterial = m_largeLight ? "GlareLsLight"
: "GlareSsLight";
m_light.GlareMaxDistance = GLARE_MAX_DISTANCE;
if (m_largeLight)
m_lightPositionOffset = new Vector3(0f, CubeGrid.GridSize * 0.5f, 0f);
else
m_lightPositionOffset = Vector3.Zero;
UpdateLightPosition();
AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(ResourceSink,this));
AnimationRunning = true;
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
IsWorkingChanged += MyBeacon_IsWorkingChanged;
ShowOnHUD = false;
UpdateText();
}
示例4: Init
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
{
base.Init(builder, cubeGrid);
//m_subpartsSize = 0.5f * (0.5f * SlimBlock.CubeGrid.GridSize - 0.3f);
var doorDefinition = BlockDefinition as MyDoorDefinition;
MyStringHash resourceSinkGroup;
if (doorDefinition != null)
{
MaxOpen = doorDefinition.MaxOpen;
m_openSound = new MySoundPair(doorDefinition.OpenSound);
m_closeSound = new MySoundPair(doorDefinition.CloseSound);
resourceSinkGroup = MyStringHash.GetOrCompute(doorDefinition.ResourceSinkGroup);
}
else
{
MaxOpen = 1.2f;
m_openSound = new MySoundPair("BlockDoorSmallOpen");
m_closeSound = new MySoundPair("BlockDoorSmallClose");
resourceSinkGroup = MyStringHash.GetOrCompute("Doors");
}
var ob = (MyObjectBuilder_Door)builder;
m_open = ob.State;
m_currOpening = ob.Opening;
var sinkComp = new MyResourceSinkComponent();
sinkComp.Init(
resourceSinkGroup,
MyEnergyConstants.MAX_REQUIRED_POWER_DOOR,
() => (Enabled && IsFunctional) ? sinkComp.MaxRequiredInput : 0f);
sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
sinkComp.Update();
ResourceSink = sinkComp;
if (!Enabled || !ResourceSink.IsPowered)
UpdateSlidingDoorsPosition(true);
OnStateChange();
if (m_open)
{
// required when reinitializing a door after the armor beneath it is destroyed
if (Open && (m_currOpening == MaxOpen))
UpdateSlidingDoorsPosition(true);
}
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
}
示例5: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
SyncFlag = true;
var sinkComp = new MyResourceSinkComponent();
sinkComp.Init(
BlockDefinition.ResourceSinkGroup,
m_powerNeeded,
this.CalculateRequiredPowerInput);
ResourceSink = sinkComp;
base.Init(objectBuilder, cubeGrid);
NeedsUpdate = MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;
var remoteOb = (MyObjectBuilder_RemoteControl)objectBuilder;
m_savedPreviousControlledEntityId = remoteOb.PreviousControlledEntityId;
sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
sinkComp.RequiredInputChanged += Receiver_RequiredInputChanged;
sinkComp.Update();
m_autoPilotEnabled.Value = remoteOb.AutoPilotEnabled;
m_dockingModeEnabled.Value = remoteOb.DockingModeEnabled;
m_currentFlightMode.Value = (FlightMode)remoteOb.FlightMode;
m_currentDirection.Value = (Base6Directions.Direction)remoteOb.Direction;
m_autopilotSpeedLimit.Value = remoteOb.AutopilotSpeedLimit;
m_bindedCamera.Value = remoteOb.BindedCamera;
m_waypointThresholdDistance.Value = remoteOb.WaypointThresholdDistance;
m_currentAutopilotSpeedLimit = m_autopilotSpeedLimit;
m_stuckDetection = new MyStuckDetection(0.03f, 0.01f, this.CubeGrid.PositionComp.WorldAABB);
if (remoteOb.Coords == null || remoteOb.Coords.Count == 0)
{
if (remoteOb.Waypoints == null)
{
m_waypoints = new List<MyAutopilotWaypoint>();
CurrentWaypoint = null;
}
else
{
m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Waypoints.Count);
for (int i = 0; i < remoteOb.Waypoints.Count; i++)
{
m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Waypoints[i], this));
}
}
}
else
{
m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Coords.Count);
for (int i = 0; i < remoteOb.Coords.Count; i++)
{
m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Coords[i], remoteOb.Names[i], this));
}
if (remoteOb.AutoPilotToolbar != null && m_currentFlightMode == FlightMode.OneWay)
{
m_waypoints[m_waypoints.Count - 1].SetActions(remoteOb.AutoPilotToolbar.Slots);
}
}
if (remoteOb.CurrentWaypointIndex == -1 || remoteOb.CurrentWaypointIndex >= m_waypoints.Count)
{
CurrentWaypoint = null;
}
else
{
CurrentWaypoint = m_waypoints[remoteOb.CurrentWaypointIndex];
}
UpdatePlanetWaypointInfo();
m_actionToolbar = new MyToolbar(MyToolbarType.ButtonPanel, pageCount: 1);
m_actionToolbar.DrawNumbers = false;
m_actionToolbar.Init(null, this);
m_selectedGpsLocations = new List<IMyGps>();
m_selectedWaypoints = new List<MyAutopilotWaypoint>();
UpdateText();
AddDebugRenderComponent(new MyDebugRenderComponentRemoteControl(this));
m_useCollisionAvoidance.Value = remoteOb.CollisionAvoidance;
for (int i = 0; i < TERRAIN_HEIGHT_DETECTION_SAMPLES; i++)
{
m_terrainHeightDetection[i] = 0.0f;
}
}
示例6: MyGridConveyorSystem
public MyGridConveyorSystem(MyCubeGrid grid)
{
m_grid = grid;
m_lineEndpoints = null;
m_linePoints = null;
m_deserializedLines = null;
ResourceSink = new MyResourceSinkComponent();
ResourceSink.Init(
MyStringHash.GetOrCompute("Conveyors"),
CONVEYOR_SYSTEM_CONSUMPTION,
CalculateConsumption);
ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
ResourceSink.Update();
}
示例7: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
var medicalRoomDefinition = BlockDefinition as MyMedicalRoomDefinition;
MyStringHash resourceSinkGroup;
if (medicalRoomDefinition != null)
{
m_idleSound = new MySoundPair(medicalRoomDefinition.IdleSound);
m_progressSound = new MySoundPair(medicalRoomDefinition.ProgressSound);
resourceSinkGroup = MyStringHash.GetOrCompute(medicalRoomDefinition.ResourceSinkGroup);
}
else
{
m_idleSound = new MySoundPair("BlockMedical");
m_progressSound = new MySoundPair("BlockMedicalProgress");
resourceSinkGroup = MyStringHash.GetOrCompute("Utility");
}
SinkComp = new MyResourceSinkComponent();
SinkComp.Init(
resourceSinkGroup,
MyEnergyConstants.MAX_REQUIRED_POWER_MEDICAL_ROOM,
() => (Enabled && IsFunctional) ? SinkComp.MaxRequiredInput : 0f);
SinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
base.Init(objectBuilder, cubeGrid);
m_rechargeSocket = new MyRechargeSocket();
NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
SteamUserId = (objectBuilder as MyObjectBuilder_MedicalRoom).SteamUserId;
if (SteamUserId != 0) //backward compatibility
{
MyPlayer controller = Sync.Players.GetPlayerById(new MyPlayer.PlayerId(SteamUserId));
if (controller != null)
{
IDModule.Owner = controller.Identity.IdentityId;
IDModule.ShareMode = MyOwnershipShareModeEnum.Faction;
}
}
SteamUserId = 0;
m_takeSpawneeOwnership = (objectBuilder as MyObjectBuilder_MedicalRoom).TakeOwnership;
m_setFactionToSpawnee = (objectBuilder as MyObjectBuilder_MedicalRoom).SetFaction;
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
InitializeConveyorEndpoint();
SinkComp.Update();
AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(SinkComp, this));
if (this.CubeGrid.CreatePhysics)
Components.Add<MyRespawnComponent>(new MyRespawnComponent());
m_healingAllowed = medicalRoomDefinition.HealingAllowed;
m_refuelAllowed = medicalRoomDefinition.RefuelAllowed;
m_suitChangeAllowed = medicalRoomDefinition.SuitChangeAllowed;
m_customWardrobesEnabled = medicalRoomDefinition.CustomWardrobesEnabled;
m_forceSuitChangeOnRespawn = medicalRoomDefinition.ForceSuitChangeOnRespawn;
m_customWardrobeNames = medicalRoomDefinition.CustomWardrobeNames;
m_respawnSuitName = medicalRoomDefinition.RespawnSuitName;
m_spawnWithoutOxygenEnabled = medicalRoomDefinition.SpawnWithoutOxygenEnabled;
RespawnAllowed = medicalRoomDefinition.RespawnAllowed;
}
示例8: Init
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
{
ResourceSink = new MyResourceSinkComponent();
ResourceSink.Init(
MyStringHash.GetOrCompute(BlockDefinition.ResourceSinkGroup),
BlockDefinition.PowerConsumptionMoving,
UpdatePowerInput);
base.Init(builder, cubeGrid);
var ob = (MyObjectBuilder_AirtightDoorGeneric)builder;
m_open.Value = ob.Open;
m_currOpening = ob.CurrOpening;
m_openingSpeed = BlockDefinition.OpeningSpeed;
m_sound = new MySoundPair(BlockDefinition.Sound);
m_subpartMovementDistance = BlockDefinition.SubpartMovementDistance;
if (!Enabled || !ResourceSink.IsPoweredByType(MyResourceDistributorComponent.ElectricityId))
UpdateDoorPosition();
OnStateChange();
ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
ResourceSink.Update();
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
ResourceSink.Update();
}
示例9: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
SyncFlag = true;
var sinkComp = new MyResourceSinkComponent();
sinkComp.Init(
MyStringHash.GetOrCompute(BlockDefinition.ResourceSinkGroup),
BlockDefinition.RequiredPowerInput,
CalculateRequiredPowerInput);
sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
sinkComp.RequiredInputChanged += Receiver_RequiredInputChanged;
ResourceSink = sinkComp;
base.Init(objectBuilder, cubeGrid);
NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;
sinkComp.Update();
var ob = objectBuilder as MyObjectBuilder_CameraBlock;
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
IsWorkingChanged += MyCameraBlock_IsWorkingChanged;
IsInFirstPersonView = true;
if (ob.IsActive)
{
m_requestActivateAfterLoad = true;
ob.IsActive = false;
}
OnChangeFov(ob.Fov);
UpdateText();
}
示例10: Init
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
{
ResourceSink = new MyResourceSinkComponent();
ResourceSink.Init(
BlockDefinition.ResourceSinkGroup,
BlockDefinition.PowerInputLasing,
UpdatePowerInput);
Broadcaster = new MyLaserBroadcaster();
Receiver = new MyLaserReceiver();
base.Init(objectBuilder, cubeGrid);
MyObjectBuilder_LaserAntenna ob = (MyObjectBuilder_LaserAntenna)objectBuilder;
State=(StateEnum)(ob.State & 0x7);
m_IsPermanent = (ob.State & 0x8) != 0;
m_targetId = ob.targetEntityId;
m_lastKnownTargetName.Append(ob.LastKnownTargetName);
if (ob.gpsTarget!=null)
m_termGpsCoords=ob.gpsTarget;
m_termGpsName.Clear().Append(ob.gpsTargetName);
m_rotation = ob.HeadRotation.X;
m_elevation = ob.HeadRotation.Y;
m_targetCoords = ob.LastTargetPosition;
m_maxRange = BlockDefinition.MaxRange;
m_needLineOfSight = BlockDefinition.RequireLineOfSight;
if (BlockDefinition != null)
{
m_minElevationRadians = MathHelper.ToRadians(NormalizeAngle(BlockDefinition.MinElevationDegrees));
m_maxElevationRadians = MathHelper.ToRadians(NormalizeAngle(BlockDefinition.MaxElevationDegrees));
if (m_minElevationRadians > m_maxElevationRadians)
{
m_minElevationRadians -= MathHelper.TwoPi;
}
m_minAzimuthRadians = MathHelper.ToRadians(NormalizeAngle(BlockDefinition.MinAzimuthDegrees));
m_maxAzimuthRadians = MathHelper.ToRadians(NormalizeAngle(BlockDefinition.MaxAzimuthDegrees));
if (m_minAzimuthRadians > m_maxAzimuthRadians)
{
m_minAzimuthRadians -= MathHelper.TwoPi;
}
ClampRotationAndElevation();
}
InitializationMatrix = PositionComp.LocalMatrix;
ResourceSink.IsPoweredChanged += IsPoweredChanged;
ResourceSink.Update();
OnClose += delegate { OnClosed(); };
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
if (SlimBlock.CubeGrid.GridSize > 1.5f)//large grid variant has wider limit
m_MinElevation = -30 * (float)Math.PI / 180;
Receiver.Enabled = IsWorking;
UpdateEmissivity();
UpdateMyStateText();
NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
}
示例11: Init
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
{
var sinkComp = new MyResourceSinkComponent();
sinkComp.Init(
BlockDefinition.ResourceSinkGroup,
BlockDefinition.PowerConsumptionMoving,
UpdatePowerInput);
ResourceSink = sinkComp;
base.Init(builder, cubeGrid);
var ob = (MyObjectBuilder_AdvancedDoor)builder;
m_open.Value = ob.Open;
sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
sinkComp.Update();
if (!Enabled || !ResourceSink.IsPowered)
UpdateDoorPosition();
OnStateChange();
if (m_open)
UpdateDoorPosition();
SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
ResourceSink.Update();
}