Esempio n. 1
0
        public static bool IsRecievedByPlayer(MyCubeBlock cubeBlock)
        {
            MyCharacter localCharacter = MySession.Static.LocalCharacter;

            if (localCharacter == null)
            {
                return(false);
            }
            MyRadioReceiver radioReceiver = localCharacter.RadioReceiver;

            return(MyAntennaSystem.Static.CheckConnection((MyDataReceiver)radioReceiver, (VRage.Game.Entity.MyEntity)cubeBlock, localCharacter.GetPlayerIdentityId(), false));
        }
Esempio n. 2
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            m_radioBroadcaster = new MyRadioBroadcaster(this);
            MyObjectBuilder_RadioAntenna antennaBuilder = (MyObjectBuilder_RadioAntenna)objectBuilder;

            if (antennaBuilder.BroadcastRadius != 0)
            {
                m_radioBroadcaster.BroadcastRadius = antennaBuilder.BroadcastRadius;
            }
            else
            {
                m_radioBroadcaster.BroadcastRadius = CubeGrid.GridSizeEnum == MyCubeSize.Large ? 10000 : 500;
            }
            RadioBroadcaster.WantsToBeEnabled = antennaBuilder.EnableBroadcasting;

            m_showShipName  = antennaBuilder.ShowShipName;
            m_radioReceiver = new MyRadioReceiver(this);

            m_radioBroadcaster.OnBroadcastRadiusChanged += OnBroadcastRadiusChanged;

            var antennaDefinition = BlockDefinition as MyRadioAntennaDefinition;

            Debug.Assert(antennaDefinition != null);

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                antennaDefinition.ResourceSinkGroup,
                MyEnergyConstants.MAX_REQUIRED_POWER_ANTENNA,
                UpdatePowerInput);
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink = sinkComp;
            ResourceSink.Update();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            if (Sync.IsServer)
            {
                this.IsWorkingChanged  += UpdatePirateAntenna;
                this.CustomNameChanged += UpdatePirateAntenna;
                this.OwnershipChanged  += UpdatePirateAntenna;
                UpdatePirateAntenna(this);
            }

            ShowOnHUD = false;

            NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME;
        }
Esempio n. 3
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            RadioBroadcaster = new MyRadioBroadcaster();
            RadioReceiver    = new MyRadioReceiver();

            var antennaDefinition = BlockDefinition as MyRadioAntennaDefinition;

            Debug.Assert(antennaDefinition != null);

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                antennaDefinition.ResourceSinkGroup,
                MyEnergyConstants.MAX_REQUIRED_POWER_ANTENNA,
                UpdatePowerInput);
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            MyObjectBuilder_RadioAntenna antennaBuilder = (MyObjectBuilder_RadioAntenna)objectBuilder;

            if (antennaBuilder.BroadcastRadius != 0)
            {
                RadioBroadcaster.BroadcastRadius = antennaBuilder.BroadcastRadius;
            }
            else
            {
                RadioBroadcaster.BroadcastRadius = CubeGrid.GridSizeEnum == MyCubeSize.Large ? 10000 : 500;
            }
            ResourceSink.Update();
            RadioBroadcaster.WantsToBeEnabled = antennaBuilder.EnableBroadcasting;

            m_showShipName.Value = antennaBuilder.ShowShipName;

            //if (Sync.IsServer)
            //{
            //    this.IsWorkingChanged += UpdatePirateAntenna;
            //    this.CustomNameChanged += UpdatePirateAntenna;
            //    this.OwnershipChanged += UpdatePirateAntenna;
            //    UpdatePirateAntenna(this);
            //}

            ShowOnHUD = false;

            m_gizmoColor = MySandboxGame.IsDirectX11 ? new Vector4(0.2f, 0.2f, 0.0f, 0.5f) : new Vector4(0.1f, 0.1f, 0.0f, 0.1f);

            NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }
Esempio n. 4
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            m_radioBroadcaster = new MyRadioBroadcaster(this);
            MyObjectBuilder_RadioAntenna antennaBuilder = (MyObjectBuilder_RadioAntenna)objectBuilder;

            if (antennaBuilder.BroadcastRadius != 0)
            {
                m_radioBroadcaster.BroadcastRadius = antennaBuilder.BroadcastRadius;
            }
            else
            {
                m_radioBroadcaster.BroadcastRadius = CubeGrid.GridSizeEnum == MyCubeSize.Large ? 10000 : 500;
            }
            RadioBroadcaster.WantsToBeEnabled = antennaBuilder.EnableBroadcasting;

            m_showShipName  = antennaBuilder.ShowShipName;
            m_radioReceiver = new MyRadioReceiver(this);

            m_radioBroadcaster.OnBroadcastRadiusChanged += OnBroadcastRadiusChanged;

            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                MyEnergyConstants.MAX_REQUIRED_POWER_ANTENNA,
                UpdatePowerInput);
            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;
            PowerReceiver.Update();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            ShowOnHUD = false;

            NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME;
        }
        public MyCharacter()
        {
            ControllerInfo.ControlAcquired += OnControlAcquired;
            ControllerInfo.ControlReleased += OnControlReleased;

            RadioReceiver = new MyRadioReceiver();
            Components.Add<MyDataBroadcaster>(new MyRadioBroadcaster());
            RadioBroadcaster.BroadcastRadius = 200;
            CustomNameWithFaction = new StringBuilder();
            PositionComp = new MyCharacterPosition();
            (PositionComp as MyPositionComponent).WorldPositionChanged = WorldPositionChanged;

            Render = new MyRenderComponentCharacter();
            Render.EnableColorMaskHsv = true;
            Render.NeedsDraw = true;
            Render.CastShadows = true;
            Render.NeedsResolveCastShadow = false;
            Render.SkipIfTooSmall = false;

            SinkComp = new MyResourceSinkComponent();
#if !XB1 // !XB1_SYNC_NOREFLECTION
            SyncType = SyncHelpers.Compose(this);
#else // XB1
            SyncType = new SyncType(new List<SyncBase>());
            m_currentAmmoCount = SyncType.CreateAndAddProp<int>();
            m_currentMagazineAmmoCount = SyncType.CreateAndAddProp<int>();
            m_controlInfo = SyncType.CreateAndAddProp<Sandbox.Game.World.MyPlayer.PlayerId>();
            m_localHeadPosition = SyncType.CreateAndAddProp<Vector3>();
            m_animLeaning = SyncType.CreateAndAddProp<float>();
            m_animTurningSpeed = SyncType.CreateAndAddProp<float>();
            m_localHeadTransform = SyncType.CreateAndAddProp<MyTransform>();
            m_localHeadTransformTool = SyncType.CreateAndAddProp<MyTransform>();
            m_isPromoted = SyncType.CreateAndAddProp<bool>();
            //m_weaponPosition = SyncType.CreateAndAddProp<Vector3>();
#endif // XB1


            AddDebugRenderComponent(new MyDebugRenderComponentCharacter(this));

            if (MyPerGameSettings.CharacterDetectionComponent != null)
                Components.Add<MyCharacterDetectorComponent>((MyCharacterDetectorComponent)Activator.CreateInstance(MyPerGameSettings.CharacterDetectionComponent));
            else
                Components.Add<MyCharacterDetectorComponent>(new MyCharacterRaycastDetectorComponent());

            m_currentAmmoCount.ValidateNever();
            m_currentMagazineAmmoCount.ValidateNever();

            m_controlInfo.ValueChanged += (x) => ControlChanged();
            m_controlInfo.ValidateNever();
            m_isPromoted.ValidateNever();

            m_isShooting = new bool[(int)MyEnum<MyShootActionEnum>.Range.Max + 1];

            //m_weaponPosition.Value = Vector3D.Zero;

            m_localHeadTransformTool.ValueChanged += (x) => ToolHeadTransformChanged();
            //Components.Add<MyCharacterDetectorComponent>(new MyCharacterShapecastDetectorComponent());
        }
Esempio n. 6
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            RadioReceiver = new MyRadioReceiver();
            RadioBroadcaster = new MyRadioBroadcaster(50);

            base.Init(objectBuilder, cubeGrid);

            MyObjectBuilder_SpaceBall sphereOb = (MyObjectBuilder_SpaceBall)objectBuilder;
            m_virtualMass.Value = sphereOb.VirtualMass;
            m_restitution.Value = sphereOb.Restitution;
            Friction = sphereOb.Friction;

            IsWorkingChanged += MySpaceBall_IsWorkingChanged;

            UpdateIsWorking();
            RefreshPhysicsBody();

            m_savedBroadcast = sphereOb.EnableBroadcast;

            ShowOnHUD = false;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }
Esempio n. 7
0
        public MyCharacter()
        {
            ControllerInfo.ControlAcquired += OnControlAcquired;
            ControllerInfo.ControlReleased += OnControlReleased;

            RadioReceiver = new MyRadioReceiver();
            Components.Add<MyDataBroadcaster>(new MyRadioBroadcaster());
            RadioBroadcaster.BroadcastRadius = 200;
            CustomNameWithFaction = new StringBuilder();
            PositionComp = new MyCharacterPosition();
            (PositionComp as MyPositionComponent).WorldPositionChanged = WorldPositionChanged;

            Render = new MyRenderComponentCharacter();
            Render.EnableColorMaskHsv = true;
            Render.NeedsDraw = true;
            Render.CastShadows = true;
            Render.NeedsResolveCastShadow = false;
            Render.SkipIfTooSmall = false;

            SinkComp = new MyResourceSinkComponent();
            SyncType = SyncHelpers.Compose(this);

            AddDebugRenderComponent(new MyDebugRenderComponentCharacter(this));

            if (MyPerGameSettings.CharacterDetectionComponent != null)
                Components.Add<MyCharacterDetectorComponent>((MyCharacterDetectorComponent)Activator.CreateInstance(MyPerGameSettings.CharacterDetectionComponent));
            else
                Components.Add<MyCharacterDetectorComponent>(new MyCharacterRaycastDetectorComponent());

            m_currentAmmoCount.ValidateNever();
            m_currentMagazineAmmoCount.ValidateNever();

            m_controlInfo.ValueChanged += (x) => ControlChanged();
            m_controlInfo.ValidateNever();
            m_isPromoted.ValidateNever();

            m_isShooting = new bool[(int)MyEnum<MyShootActionEnum>.Range.Max + 1];

            //m_weaponPosition.Value = Vector3D.Zero;

            m_localHeadTransformTool.ValueChanged += (x) => ToolHeadTransformChanged();
            //Components.Add<MyCharacterDetectorComponent>(new MyCharacterShapecastDetectorComponent());
        }
Esempio n. 8
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            RadioBroadcaster = new MyRadioBroadcaster();
            RadioReceiver = new MyRadioReceiver();

            var antennaDefinition = BlockDefinition as MyRadioAntennaDefinition;
            Debug.Assert(antennaDefinition != null);

            var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                antennaDefinition.ResourceSinkGroup,
                MyEnergyConstants.MAX_REQUIRED_POWER_ANTENNA,
                UpdatePowerInput);
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            MyObjectBuilder_RadioAntenna antennaBuilder = (MyObjectBuilder_RadioAntenna)objectBuilder;

            if (antennaBuilder.BroadcastRadius != 0)
            {
                RadioBroadcaster.BroadcastRadius = antennaBuilder.BroadcastRadius;
            }
            else
            {
                RadioBroadcaster.BroadcastRadius = CubeGrid.GridSizeEnum == MyCubeSize.Large ? 10000 : 500;
            }
            ResourceSink.Update();
            RadioBroadcaster.WantsToBeEnabled = antennaBuilder.EnableBroadcasting;

            m_showShipName.Value = antennaBuilder.ShowShipName;

            //if (Sync.IsServer)
            //{
            //    this.IsWorkingChanged += UpdatePirateAntenna;
            //    this.CustomNameChanged += UpdatePirateAntenna;
            //    this.OwnershipChanged += UpdatePirateAntenna;
            //    UpdatePirateAntenna(this);
            //}

            ShowOnHUD = false;

            m_gizmoColor = new Vector4(0.2f, 0.2f, 0.0f, 0.5f);

            NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }