Exemple #1
0
        public MyReactor()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_remainingPowerCapacity = SyncType.CreateAndAddProp<float>();
            m_useConveyorSystem = SyncType.CreateAndAddProp<bool>();
#endif // XB1
            CreateTerminalControls();

			SourceComp = new MyResourceSourceComponent();
            m_remainingPowerCapacity.ValueChanged += (x) => RemainingCapacityChanged();
            m_remainingPowerCapacity.ValidateNever();
        }
        public MyDoor()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_currOpening = SyncType.CreateAndAddProp<float>();
            m_open = SyncType.CreateAndAddProp<bool>();
#endif // XB1
            CreateTerminalControls();

            m_currOpening.ValidateNever();
            m_currOpening.Value = 0f;
            m_currSpeed = 0f;
            m_open.ValidateNever();
            m_open.ValueChanged += x => OnStateChange();
        }
        public MyTimerBlock()
        {
            #if XB1 // XB1_SYNC_NOREFLECTION
            m_isCountingDown = SyncType.CreateAndAddProp<bool>();
            m_silent = SyncType.CreateAndAddProp<bool>();
            m_timerSync = SyncType.CreateAndAddProp<int>();
            #endif // XB1
            CreateTerminalControls();

            m_openedToolbars = new List<MyToolbar>();
            m_timerSync.ValueChanged += (x) => TimerChanged();
            m_isCountingDown.ValueChanged += (x) => CountDownChanged();
            m_isCountingDown.ValidateNever();
        }
        public MyJumpDrive()
        {
            #if XB1 // XB1_SYNC_NOREFLECTION
            m_storedPower = SyncType.CreateAndAddProp<float>();
            m_targetSync = SyncType.CreateAndAddProp<int?>();
            m_jumpDistanceRatio = SyncType.CreateAndAddProp<float>();
            m_isRecharging = SyncType.CreateAndAddProp<bool>();
            #endif // XB1
            CreateTerminalControls();

            m_isRecharging.ValueChanged += x => RaisePropertiesChanged();   //GR: Maybe not needed since called every 100 frames either way
            m_targetSync.ValueChanged += x => TargetChanged();
            m_storedPower.ValidateNever();
        }
        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());
        }
        public MyShipConnector()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            ThrowOut = SyncType.CreateAndAddProp<bool>();
            CollectAll = SyncType.CreateAndAddProp<bool>();
            Strength = SyncType.CreateAndAddProp<float>();
            m_connectionState = SyncType.CreateAndAddProp<State>();
#endif // XB1
            CreateTerminalControls();

            m_connectionState.ValueChanged += (o) => OnConnectionStateChanged();
            m_connectionState.ValidateNever(); // Never set by client
            m_manualDisconnectTime = new MyTimeSpan(-DisconnectSleepTime.Ticks);
            Strength.Validate = (o) => Strength >= 0 && Strength <= 1;
        }
        public MyCockpit()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_pilotRelativeWorld = SyncType.CreateAndAddProp<Matrix?>();
            m_attachedCharacterId = SyncType.CreateAndAddProp<long?>();
            m_storeOriginalPlayerWorldMatrix = SyncType.CreateAndAddProp<bool>();
#endif // XB1
            m_pilotClosedHandler = new Action<MyEntity>(m_pilot_OnMarkForClose);
            ResourceSink = new MyResourceSinkComponent(2);

            m_attachedCharacterId.ValueChanged += (o) => OnCharacterChanged();
            m_soundEmitter.EmitterMethods[MyEntity3DSoundEmitter.MethodsEnum.ShouldPlay2D].Add((Func<bool>)ShouldPlay2D);
            m_pilotRelativeWorld.ValidateNever();
        }
Exemple #8
0
        public MyInventory(MyFixedPoint maxVolume, MyFixedPoint maxMass, Vector3 size, MyInventoryFlags flags)
            : base("Inventory")
        {
            m_maxVolume = maxVolume;
            m_maxMass = maxMass;
            m_flags = flags;

#if !XB1 // !XB1_SYNC_NOREFLECTION
            SyncType = SyncHelpers.Compose(this);
#else // XB1
            SyncType = new SyncType(new List<SyncBase>());
            m_currentVolume = SyncType.CreateAndAddProp<MyFixedPoint>();
            m_currentMass = SyncType.CreateAndAddProp<MyFixedPoint>();
#endif // XB1
            m_currentVolume.ValueChanged += (x) => PropertiesChanged();
            m_currentVolume.ValidateNever();

            m_currentMass.ValueChanged += (x) => PropertiesChanged();
            m_currentMass.ValidateNever();

            m_inventoryNotEmptyNotification = new MyHudNotification(font: MyFontEnum.Red, priority: 2, text: MyCommonTexts.NotificationInventoryNotEmpty);

            Clear();
        }
        public MyLandingGear()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_lockModeSync = SyncType.CreateAndAddProp<LandingGearMode>();
            m_autoLock = SyncType.CreateAndAddProp<bool>();
            m_attachedState = SyncType.CreateAndAddProp<State>();
            m_breakForceSync = SyncType.CreateAndAddProp<float>();
#endif // XB1
            CreateTerminalControls();

            m_physicsChangedHandler = new Action<IMyEntity>(PhysicsChanged);
            m_attachedState.ValidateNever();
            m_attachedState.ValueChanged += x => AttachedValueChanged();
            m_autoLock.ValueChanged += x => AutolockChanged();

            m_breakForceSync.ValueChanged += x => BreakForceChanged();

            m_lockModeSync.ValidateNever();
            m_lockModeSync.ValueChanged += x => OnLockModeChanged();
        }
        public MyMechanicalConnectionBlockBase()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_connectionState = SyncType.CreateAndAddProp<State>();
            m_topAndBottomSamePhysicsBody = SyncType.CreateAndAddProp<bool>();
            m_forceWeld = SyncType.CreateAndAddProp<bool>();
            m_speedWeld = SyncType.CreateAndAddProp<bool>();
            m_weldSpeedSq = SyncType.CreateAndAddProp<float>();
#endif // XB1

            m_forceWeld.ValueChanged += (o) => OnForceWeldChanged();
            m_connectionState.ValueChanged += (o) => OnAttachTargetChanged();
            m_connectionState.Validate = ValidateTopBlockId;
            m_topAndBottomSamePhysicsBody.ValidateNever();

            m_speedWeld.Value = false;
            CreateTerminalControls();     
        }