Example #1
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            MyBeaconDefinition blockDefinition = base.BlockDefinition as MyBeaconDefinition;

            if (blockDefinition.EmissiveColorPreset == MyStringHash.NullOrEmpty)
            {
                blockDefinition.EmissiveColorPreset = MyStringHash.GetOrCompute("Beacon");
            }
            MyResourceSinkComponent component = new MyResourceSinkComponent(1);

            component.Init(MyStringHash.GetOrCompute(blockDefinition.ResourceSinkGroup), 0.02f, new Func <float>(this.UpdatePowerInput));
            base.ResourceSink     = component;
            this.RadioBroadcaster = new MyRadioBroadcaster(blockDefinition.MaxBroadcastRadius / 10f);
            MyObjectBuilder_Beacon beacon = (MyObjectBuilder_Beacon)objectBuilder;

            if (beacon.BroadcastRadius > 0f)
            {
                this.RadioBroadcaster.BroadcastRadius = beacon.BroadcastRadius;
            }
            this.RadioBroadcaster.BroadcastRadius = MathHelper.Clamp(this.RadioBroadcaster.BroadcastRadius, 1f, blockDefinition.MaxBroadcastRadius);
            this.HudText.Clear();
            if (beacon.HudText != null)
            {
                this.HudText.Append(beacon.HudText);
            }
            base.Init(objectBuilder, cubeGrid);
            component.IsPoweredChanged += new Action(this.Receiver_IsPoweredChanged);
            component.Update();
            MyRadioBroadcaster radioBroadcaster = this.RadioBroadcaster;

            radioBroadcaster.OnBroadcastRadiusChanged = (Action)Delegate.Combine(radioBroadcaster.OnBroadcastRadiusChanged, new Action(this.OnBroadcastRadiusChanged));
            this.m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large;
            this.m_light      = MyLights.AddLight();
            if (this.m_light != null)
            {
                this.m_light.Start(this.DisplayNameText);
                this.m_light.Range            = this.m_largeLight ? 2f : 0.3f;
                this.m_light.GlareOn          = false;
                this.m_light.GlareQuerySize   = this.m_largeLight ? 1.5f : 0.3f;
                this.m_light.GlareQueryShift  = this.m_largeLight ? 1f : 0.2f;
                this.m_light.GlareType        = MyGlareTypeEnum.Normal;
                this.m_light.GlareMaxDistance = GLARE_MAX_DISTANCE;
                MyDefinitionId    id         = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), blockDefinition.Flare);
                MyFlareDefinition definition = MyDefinitionManager.Static.GetDefinition(id) as MyFlareDefinition;
                this.m_flare = definition ?? new MyFlareDefinition();
                this.m_light.GlareIntensity = this.m_flare.Intensity;
                this.m_light.GlareSize      = this.m_flare.Size;
                this.m_light.SubGlares      = this.m_flare.SubGlares;
            }
            this.m_lightPositionOffset = this.m_largeLight ? new Vector3(0f, base.CubeGrid.GridSize * 0.3f, 0f) : Vector3.Zero;
            this.UpdateLightPosition();
            this.m_restartTimeMeasure = false;
            this.AnimationRunning     = true;
            base.SlimBlock.ComponentStack.IsFunctionalChanged += new Action(this.ComponentStack_IsFunctionalChanged);
            base.IsWorkingChanged += new Action <MyCubeBlock>(this.MyBeacon_IsWorkingChanged);
            base.ShowOnHUD         = false;
            this.UpdateText();
        }
Example #2
0
        public MyRenderComponentCharacter()
        {
            MyDefinitionId    id         = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), "Jetpack");
            MyFlareDefinition definition = MyDefinitionManager.Static.GetDefinition(id) as MyFlareDefinition;

            this.m_flareJetpack = definition ?? new MyFlareDefinition();
            id                   = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), "Headlamp");
            definition           = MyDefinitionManager.Static.GetDefinition(id) as MyFlareDefinition;
            this.m_flareHeadlamp = definition ?? new MyFlareDefinition();
        }
        public override void Init(VRage.ObjectBuilders.MyObjectBuilder_EntityBase objectBuilder)
        {
            _objectBuilder = objectBuilder;
            _beacon        = (Entity as IMyBeacon);
            Instance       = this;

            if (_beacon != null && _beacon.BlockDefinition.SubtypeId.Equals("JumpInhibitor"))
            {
                _logicEnabled = true;
                NeedsUpdate  |= MyEntityUpdateEnum.EACH_10TH_FRAME;
                NeedsUpdate  |= MyEntityUpdateEnum.EACH_FRAME;
            }


            if (_beacon != null && _beacon.BlockDefinition.SubtypeId.Equals("JumpInhibitorSmall"))
            {
                _logicEnabled       = true;
                Entity.NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
            }


            if (_beacon != null && _beacon.BlockDefinition.SubtypeId.Equals("JumpInhibitor"))
            {
                var bs = new BeaconStorage()
                {
                    Beacon       = _beacon,
                    Effect       = effect,
                    RingRotation = 0,
                    Once         = false
                };
                store.Add(bs);
            }

            var b = _beacon as MyCubeBlock;

            if (b != null)
            {
                var               def             = b.BlockDefinition as MyBeaconDefinition;
                MyDefinitionId    id              = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), def.Flare);
                MyFlareDefinition flareDefinition = MyDefinitionManager.Static.GetDefinition(id) as MyFlareDefinition;

                flareDefinition.Intensity = 0;
            }
        }