当前位置: 首页>>代码示例>>C#>>正文


C# Entities.MyEntity类代码示例

本文整理汇总了C#中Sandbox.Game.Entities.MyEntity的典型用法代码示例。如果您正苦于以下问题:C# MyEntity类的具体用法?C# MyEntity怎么用?C# MyEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MyEntity类属于Sandbox.Game.Entities命名空间,在下文中一共展示了MyEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        public bool Update(MyPlayer player, MyEntity entity) //returns if lost
        {
            //MySessionComponentMission.Static.TryCreateFromDefault(Id);

            //if (IsLocal(player.Id))
            //    UpdateLocal(player.Id);

            if (!Sync.IsServer)
                return false;

            MyMissionTriggers mtrig;
            if (!MissionTriggers.TryGetValue(player.Id, out mtrig))
            {
                //Debug.Assert(false,"Bad ID for update in missionTriggers");
                mtrig = TryCreateFromDefault(player.Id, false);
            }
            mtrig.UpdateWin(player, entity);
            if (!mtrig.Won)
                mtrig.UpdateLose(player, entity);
            else
            {
                m_someoneWon = true;
                MyAnalyticsHelper.ReportTutorialEnd();
            }
            return mtrig.Lost;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:26,代码来源:MySessionComponentMissionTriggers.cs

示例2: Update

 public override bool Update(MyEntity me)
 {
     if (MySession.Static.IsScenario)
         if (m_limit <= DateTime.UtcNow - MyScenarioSystem.Static.ServerStartGameTime)
             m_IsTrue = true;
     return IsTrue;
 }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:7,代码来源:MyTriggerTimeLimit.cs

示例3: Update

 public override ChangeInfo Update(MyEntity owner, long playerID = 0)
 {
     if (MyCubeBuilder.Static==null)
         return ChangeInfo.None;
     var blockDefinition = MyCubeBuilder.Static.IsActivated ? MyCubeBuilder.Static.ToolbarBlockDefinition : null;
     if ((MyCubeBuilder.Static.BlockCreationIsActivated || MyCubeBuilder.Static.MultiBlockCreationIsActivated) && blockDefinition != null && (!MyFakes.ENABLE_BATTLE_SYSTEM || !MySession.Static.Battle))
     {
         var blockDef = (this.Definition as Sandbox.Definitions.MyCubeBlockDefinition);
         if (blockDefinition.BlockPairName == blockDef.BlockPairName)
         {
             WantsToBeSelected = true;
         }
         else if (blockDef.BlockStages != null && blockDef.BlockStages.Contains(blockDefinition.Id))
         {
             WantsToBeSelected = true;
         }
         else
         {
             WantsToBeSelected = false;
         }
     }
     else
     {
         WantsToBeSelected = false;
     }
     return ChangeInfo.None;
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:27,代码来源:MyToolbarItemCubeBlock.cs

示例4: Spawn

        public MyEntity Spawn(MyFixedPoint amount, MatrixD worldMatrix, MyEntity owner = null)
        {
            if (Content is MyObjectBuilder_BlockItem)
            {
                Debug.Assert(MyFixedPoint.IsIntegral(amount), "Spawning fractional number of grids!");

                var blockItem = Content as MyObjectBuilder_BlockItem;
                var builder = MyObjectBuilderSerializer.CreateNewObject(typeof(MyObjectBuilder_CubeGrid)) as MyObjectBuilder_CubeGrid;
                builder.GridSizeEnum = MyCubeSize.Small;
                builder.IsStatic = false;
                builder.PersistentFlags |= MyPersistentEntityFlags2.InScene | MyPersistentEntityFlags2.Enabled;
                builder.PositionAndOrientation = new MyPositionAndOrientation(worldMatrix);

                var block = MyObjectBuilderSerializer.CreateNewObject(blockItem.BlockDefId) as MyObjectBuilder_CubeBlock;
                builder.CubeBlocks.Add(block);

                MyCubeGrid firstGrid = null;
                for (int i = 0; i < amount; ++i)
                {
                    builder.EntityId = MyEntityIdentifier.AllocateId();
                    block.EntityId = MyEntityIdentifier.AllocateId();
                    MyCubeGrid newGrid = MyEntities.CreateFromObjectBuilder(builder) as MyCubeGrid;
                    firstGrid = firstGrid ?? newGrid;
                    MyEntities.Add(newGrid);
                    Sandbox.Game.Multiplayer.MySyncCreate.SendEntityCreated(builder);
                }
                return firstGrid;
            }
            else
                return MyFloatingObjects.Spawn(new MyPhysicalInventoryItem(amount, Content),worldMatrix, owner != null ? owner.Physics : null);
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:31,代码来源:MyPhysicalInventoryItem.cs

示例5: voxelMap_OnClose

        private void voxelMap_OnClose(MyEntity entity)
        {
            var voxelMap = entity as MyVoxelMap;
            if (voxelMap == null) return;

            m_navigationMeshes.Remove(voxelMap);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:7,代码来源:MyVoxelPathfinding.cs

示例6: Unregister

		public override void Unregister(MyEntity entity, Vector3I forwardVector)
		{
			base.Unregister(entity, forwardVector);
			var thrust = entity as MyThrust;
			if (thrust == null)
				return;

			thrust.EnabledChanged -= thrust_EnabledChanged;
			thrust.SlimBlock.ComponentStack.IsFunctionalChanged -= ComponentStack_IsFunctionalChanged;

            // Need to recalculate the slowdown factor. Maybe save different levels of the factors and just revert back to previous one
		    SlowdownFactor = 0f;
		    foreach (var direction in Base6Directions.IntDirections)
		    {
		        foreach (var dataByType in m_dataByFuelType)
		        {
		            foreach (var entityInDirection in dataByType.ThrustsByDirection[direction])
		            {
		                var thrustInDirection = entityInDirection as MyThrust;
		                if (thrustInDirection == null)
		                    continue;

		                SlowdownFactor = Math.Max(thrustInDirection.BlockDefinition.SlowdownFactor, SlowdownFactor);
		            }
		        }
		    }
		}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:27,代码来源:MyThrusterBlockThrustComponent.cs

示例7: AddShotgun

        //  Not used apparently
        public static void AddShotgun(MyProjectileAmmoDefinition ammoDefinition, MyEntity ignorePhysObject, Vector3 origin, Vector3 initialVelocity, Vector3 directionNormalized, bool groupStart, float thicknessMultiplier, MyEntity weapon, float frontBillboardSize, MyEntity ownerEntity = null, float projectileCountMultiplier = 1)
        {
            MyProjectile newProjectile = m_projectiles.Allocate();
            if (newProjectile != null)
            {
                //newProjectile.Start(
                //    ammoDefinition,
                //    ignorePhysObject,
                //    origin,
                //    initialVelocity,
                //    directionNormalized,
                //    groupStart,
                //    thicknessMultiplier,
                //    1,
                //    weapon,
                //    projectileCountMultiplier
                //    );

            //    newProjectile.BlendByCameraDirection = true;
            //    newProjectile.FrontBillboardMaterial = "ShotgunParticle";
            //    newProjectile.LengthMultiplier = 2;
            //    newProjectile.FrontBillboardSize = frontBillboardSize;
             //   newProjectile.OwnerEntity = ownerEntity != null ? ownerEntity : ignorePhysObject;
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:26,代码来源:MyProjectiles.cs

示例8: Update

 public override bool Update(MyEntity me)
 {
     bool isSomethingAlive=false;
     foreach(var item in m_blocks)
     {
         if (item.Value == BlockState.MessageShown)
             continue;
         if (item.Key.SlimBlock.IsDestroyed)
         {
             m_blocksHelper.Add(item.Key);
             continue;
         }
         isSomethingAlive = true;
     }
     if (!isSomethingAlive)
         m_IsTrue = true;
     if (m_blocksHelper.Count()>0)
     {
         foreach(var block in m_blocksHelper)
             m_blocks[block] = BlockState.Destroyed;
         m_blocksHelper.Clear();
         m_needsSingleMessage = true;
     }
     return base.Update(me);
 }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:25,代码来源:MyTriggerBlockDestroyed.cs

示例9: SetTarget

 public void SetTarget(MyEntity entity, Vector3? relativeTarget = null)
 {
     m_mode = AimingMode.TARGET;
     m_aimTarget = entity;
     m_relativeTarget = relativeTarget;
     Update();
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyBotAiming.cs

示例10: Update

 public override bool Update(MyPlayer player, MyEntity me)
 {
     if (me!=null)
         if (Vector3D.DistanceSquared(me.PositionComp.GetPosition(), TargetPos) < m_maxDistance2)
             m_IsTrue = true;
     return IsTrue;
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyTriggerPositionReached.cs

示例11: SetTarget

 public void SetTarget(MyEntity entity, Vector3? relativeTarget = null)
 {
     m_followMovement = false;
     m_aimTarget = entity;
     m_relativeTarget = relativeTarget;
     Update();
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:7,代码来源:MyBotAiming.cs

示例12: m_entity_OnClose

 void m_entity_OnClose(MyEntity obj)
 {
     if (m_shotSmoke != null)
     {
         MyParticlesManager.RemoveParticleEffect(m_shotSmoke);
         m_shotSmoke = null;
     }
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:8,代码来源:MyLargeBarrelBase.cs

示例13: CalculateForceMultiplier

	    protected override float CalculateForceMultiplier(MyEntity thrustEntity)
	    {


	        float forceMultiplier = 1.0f;

	        return forceMultiplier;
	    }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:8,代码来源:MyJetpackThrustComponent.cs

示例14: MyEntities_OnEntityAdd

        private void MyEntities_OnEntityAdd(MyEntity entity)
        {
            var voxelMap = entity as MyVoxelMap;
            if (voxelMap == null) return;

            m_navigationMeshes.Add(voxelMap, new MyVoxelNavigationMesh(voxelMap, m_coordinator, MyAIComponent.Static.Pathfinding.NextTimestampFunction));
            RegisterVoxelMapEvents(voxelMap);
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:8,代码来源:MyVoxelPathfinding.cs

示例15: Update

        public override ChangeInfo Update(MyEntity owner, long playerID = 0)
        {
            bool thisWeaponIsCurrent = false;
            bool shipHasThisWeapon = false;
            var character = MySession.LocalCharacter;
            bool characterHasThisWeapon = character != null && (character.GetInventory().ContainItems(1, Definition.Id) || MyPerGameSettings.EnableWeaponWithoutInventory);
            ChangeInfo changed = ChangeInfo.None;

            if (characterHasThisWeapon)
            {
                var currentWeapon = character.CurrentWeapon;
                if (currentWeapon != null)
                    thisWeaponIsCurrent = MyDefinitionManager.Static.GetPhysicalItemForHandItem(currentWeapon.DefinitionId).Id == Definition.Id;
                if (thisWeaponIsCurrent && currentWeapon is MyAutomaticRifleGun)
                {
                    int amount = character.CurrentWeapon.GetAmmunitionAmount();
                    if (m_lastAmmoCount != amount)
                    {
                        m_lastAmmoCount = amount;
                        IconText.Clear().AppendInt32(amount);
                        changed |= ChangeInfo.IconText;
                    }
                }
            }

            var shipControler = MySession.ControlledEntity as MyShipController;
            if (shipControler != null && shipControler.GridSelectionSystem.WeaponSystem != null)
            {
            //    var shipWeaponType = shipControler.GetWeaponType(Definition.Id.TypeId);
            //    shipHasThisWeapon = shipWeaponType.HasValue && shipControler.GridSelectionSystem.WeaponSystem.HasGunsOfId(shipWeaponType.Value);
                shipHasThisWeapon = shipControler.GridSelectionSystem.WeaponSystem.HasGunsOfId(Definition.Id);
                if (shipHasThisWeapon)
                {
                    IMyGunObject<MyDeviceBase> gunObject = shipControler.GridSelectionSystem.WeaponSystem.GetGun(Definition.Id);
                    if (gunObject.GunBase is MyGunBase)
                    {
                        int ammo = 0;
                        foreach (var gun in shipControler.GridSelectionSystem.WeaponSystem.GetGunsById(Definition.Id))
                        {
                            ammo += gun.GetAmmunitionAmount();
                        }
                        if (ammo != m_lastAmmoCount)
                        {
                            m_lastAmmoCount = ammo;
                            IconText.Clear().AppendInt32(ammo);
                            changed |= ChangeInfo.IconText;
                        }
                    }
                }

                thisWeaponIsCurrent = shipControler.GridSelectionSystem.GetGunId() == Definition.Id;
            }

            changed |= SetEnabled(characterHasThisWeapon || shipHasThisWeapon);
            WantsToBeSelected = thisWeaponIsCurrent;
            m_needsWeaponSwitching = !thisWeaponIsCurrent;
            return changed;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:58,代码来源:MyToolbarItemWeapon.cs


注:本文中的Sandbox.Game.Entities.MyEntity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。