GenerateRandomEdgeVector() public static method

public static GenerateRandomEdgeVector ( ) : Vector3D
return Vector3D
Ejemplo n.º 1
0
        public static void SendClientMessage(ulong steamId, string message)
        {
            if (PlayerMap.Instance.GetPlayerIdsFromSteamId(steamId).Count < 1)
            {
                Log.Info(string.Format("Unable to locate playerId for user with steamId: {0}", steamId));
                return;
            }

            CubeGridEntity entity   = new CubeGridEntity(new FileInfo(Essentials.PluginPath + "CommRelay.sbc"));
            long           entityId = BaseEntity.GenerateEntityId( );

            entity.EntityId               = entityId;
            entity.DisplayName            = string.Format("CommRelayOutput{0}", PlayerMap.Instance.GetPlayerIdsFromSteamId(steamId).First( ));
            entity.PositionAndOrientation = new MyPositionAndOrientation(MathUtility.GenerateRandomEdgeVector(getPos(steamId)), Vector3.Forward, Vector3.Up);

            foreach (MyObjectBuilder_CubeBlock block in entity.BaseCubeBlocks)
            {
                MyObjectBuilder_Beacon beacon = block as MyObjectBuilder_Beacon;
                if (beacon != null)
                {
                    beacon.CustomName = message;
                }
            }

            SectorObjectManager.Instance.AddEntity(entity);
            TimedEntityCleanup.Instance.Add(entityId);
        }
Ejemplo n.º 2
0
        public static void SendBroadcastMessage(string message)
        {
            CubeGridEntity entity   = new CubeGridEntity(new FileInfo(Essentials.PluginPath + "CommRelay.sbc"));
            long           entityId = BaseEntity.GenerateEntityId( );

            entity.EntityId               = entityId;
            entity.DisplayName            = string.Format("CommRelayBroadcast{0}", m_random.Next(1, 10000));
            entity.PositionAndOrientation = new MyPositionAndOrientation(MathUtility.GenerateRandomEdgeVector(), Vector3.Forward, Vector3.Up);

            foreach (MyObjectBuilder_CubeBlock block in entity.BaseCubeBlocks)
            {
                MyObjectBuilder_Beacon beacon = block as MyObjectBuilder_Beacon;
                if (beacon != null)
                {
                    beacon.CustomName = message;
                }
            }

            SectorObjectManager.Instance.AddEntity(entity);
            TimedEntityCleanup.Instance.Add(entityId);
        }