Пример #1
0
        // ReSharper disable once InconsistentNaming
        private static void InitPatch(MyLaserAntenna __instance)
        {
            var definition = __instance.BlockDefinition;
            var maxRange   = definition.MaxRange >= 0 ? definition.MaxRange : _infiniteRange;

            _range.GetSync <float>(__instance).ValueChangedInRange(1, maxRange);
        }
Пример #2
0
        public void UpdateHud(bool showMyself = false)
        {
            if (MySandboxGame.IsDedicated || MyHud.MinimalHud)
            {
                return;
            }

            Clear();

            foreach (var broadcaster in m_relayedBroadcasters)
            {
                MyEntity entity = (MyEntity)broadcaster.Entity;
                if (entity != null)
                {
                    if (!showMyself && entity == Entity)
                    {
                        continue; //do not show myself
                    }
                    bool friendly = true;
                    if (broadcaster.Entity is IMyComponentOwner <MyIDModule> )
                    {
                        MyIDModule broadcasterId;
                        if ((broadcaster.Entity as IMyComponentOwner <MyIDModule>).GetComponent(out broadcasterId))
                        {
                            VRage.Game.MyRelationsBetweenPlayerAndBlock relation = broadcasterId.GetUserRelationToOwner(MySession.Static.LocalPlayerId);
                            if (relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies || relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Neutral)
                            {
                                friendly = false;
                            }
                        }
                    }

                    MyLaserAntenna la = broadcaster.Entity as MyLaserAntenna;
                    if (la != null && la.ShowOnHUD == false)
                    {
                        continue;
                    }

                    foreach (var hudParams in entity.GetHudParams(friendly))
                    {
                        MyEntity hudParamsEntity = hudParams.Entity as MyEntity;
                        if (!m_entitiesOnHud.Contains(hudParamsEntity))
                        {
                            m_entitiesOnHud.Add(hudParamsEntity);
                            if (hudParams.BlinkingTime > 0)
                            {
                                MyHud.HackingMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                            else
                            if (!MyHud.HackingMarkers.MarkerEntities.ContainsKey(hudParamsEntity))
                            {
                                MyHud.LocationMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                        }
                    }
                }
            }
        }
        static void ChangePermSuccess(ref ChangePermMsg msg, MyNetworkClient sender)
        {
            MyEntity entity;

            MyEntities.TryGetEntityById(msg.EntityId, out entity);
            MyLaserAntenna la = (entity as MyLaserAntenna);

            if (la == null)
            {
                return;
            }
            la.DoSetIsPerm(msg.IsPerm != 0);
        }
        static void ChangePermRequest(ref ChangePermMsg msg, MyNetworkClient sender)
        {
            MyEntity entity;

            MyEntities.TryGetEntityById(msg.EntityId, out entity);
            MyLaserAntenna la = (entity as MyLaserAntenna);

            if (la == null)
            {
                return;
            }
            if (la.DoSetIsPerm(msg.IsPerm != 0))
            {
                Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
            }
        }
        static void PasteCoordinatesSuccess(ref CoordinatesPasted msg, MyNetworkClient sender)
        {
            MyEntity entity;

            MyEntities.TryGetEntityById(msg.EntityId, out entity);
            MyLaserAntenna la = (entity as MyLaserAntenna);

            if (la == null)
            {
                return;
            }
            la.DoPasteCoords(msg.Coordinates);
            if (Sync.IsServer)
            {
                Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
            }
        }
 public MySyncLaserAntenna(MyLaserAntenna id)
 {
     m_Parent = id;
 }
Пример #7
0
        public void UpdateHud(bool showMyself = false)
        {
            if (MySandboxGame.IsDedicated || MyHud.MinimalHud || MyHud.CutsceneHud)
            {
                return;
            }

            Clear();

            foreach (var broadcaster in m_relayedBroadcasters)
            {
                MyEntity entity = (MyEntity)broadcaster.Entity;
                if (entity != null)
                {
                    //Also ignore entity if it is preview entity or else it will update hud
                    if (entity.GetTopMostParent() is MyCubeGrid && entity.GetTopMostParent().IsPreview)
                    {
                        continue;
                    }

                    if (!showMyself && entity == Entity)
                    {
                        continue; //do not show myself
                    }
                    bool friendly = true;
                    if (broadcaster.Entity is IMyComponentOwner <MyIDModule> )
                    {
                        MyIDModule broadcasterId;
                        if ((broadcaster.Entity as IMyComponentOwner <MyIDModule>).GetComponent(out broadcasterId))
                        {
                            VRage.Game.MyRelationsBetweenPlayerAndBlock relation = broadcasterId.GetUserRelationToOwner(MySession.Static.LocalPlayerId);
                            if (relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies || relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Neutral)
                            {
                                friendly = false;
                            }
                        }
                    }

                    MyLaserAntenna la = broadcaster.Entity as MyLaserAntenna;
                    if (la != null && la.ShowOnHUD == false)
                    {
                        continue;
                    }

                    foreach (var hudParams in entity.GetHudParams(friendly))
                    {
                        MyEntity hudParamsEntity = hudParams.Entity as MyEntity;
                        if (!m_entitiesOnHud.Contains(hudParamsEntity))
                        {
                            m_entitiesOnHud.Add(hudParamsEntity);
                            if (hudParams.BlinkingTime > 0)
                            {
                                MyHud.HackingMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                            else
                            if (!MyHud.HackingMarkers.MarkerEntities.ContainsKey(hudParamsEntity))
                            {
                                MyHud.LocationMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                        }
                    }
                }
            }

            //manually draw markers for players that are out of range or have broadcasting turned off
            if (MySession.Static.AdminSettings.HasFlag(AdminSettingsEnum.ShowPlayers))
            {
                foreach (var player in MySession.Static.Players.GetOnlinePlayers())
                {
                    MyCharacter character = player.Character;
                    if (character == null)
                    {
                        continue;
                    }

                    var hudParams = character.GetHudParams(false);
                    foreach (var param in hudParams)
                    {
                        MyEntity hudEntity = (MyEntity)param.Entity;
                        if (m_entitiesOnHud.Contains(hudEntity))
                        {
                            continue;
                        }

                        m_entitiesOnHud.Add(hudEntity);

                        MyHud.LocationMarkers.RegisterMarker(hudEntity, param);
                    }
                }
            }
        }