示例#1
0
        protected override async ETTask Run(ETModel.Session session, M2C_CreateUnits message)
        {
            UnitComponent unitComponent = ETModel.Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(unitInfo.UnitId);
                unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z);

                SyncType type = Game.Scene.GetComponent <NetSyncComponent>().type;
                if (type == SyncType.Frame)
                {
                    if (PlayerComponent.Instance.MyPlayer.UnitId == unit.Id)
                    {
                        Game.Scene.GetComponent <CameraComponent>().Unit = unit;
                    }
                }
            }

            await ETTask.CompletedTask;
        }
示例#2
0
        public CashRegister(ModContentPack mod)
        {
            var type = AccessTools.TypeByName("CashRegister.Shifts.ITab_Register_Shifts");

            MpCompat.RegisterLambdaMethod(type, "GetGizmos", 1).SetContext(SyncContext.MapSelected);
            MP.RegisterSyncWorker <object>(NoSync, type, shouldConstruct: true);
            MP.RegisterSyncMethod(typeof(CashRegister), nameof(SyncedSetShifts)).ExposeParameter(1).ExposeParameter(2).ExposeParameter(3).ExposeParameter(4).ExposeParameter(5).MinTime(100);
            MpCompat.harmony.Patch(AccessTools.Method(type, "FillTab"),
                                   prefix: new HarmonyMethod(typeof(CashRegister), nameof(PreFillTab)),
                                   postfix: new HarmonyMethod(typeof(CashRegister), nameof(PostFillTab)));

            type = AccessTools.TypeByName("CashRegister.Gizmo_Radius");
            gizmoRadiusConstructor = AccessTools.GetDeclaredConstructors(type).First(x => x.GetParameters().Length == 1);
            gizmoSelectionField    = AccessTools.FieldRefAccess <Building[]>(type, "selection");
            MP.RegisterSyncMethod(AccessTools.DeclaredMethod(type, "ButtonDown"));
            MP.RegisterSyncMethod(AccessTools.DeclaredMethod(type, "ButtonUp"));
            MP.RegisterSyncMethod(AccessTools.DeclaredMethod(type, "ButtonCenter"));
            MP.RegisterSyncWorker <Gizmo>(SyncGizmoRadius, type);

            type             = AccessTools.TypeByName("CashRegister.Building_CashRegister");
            cashRegisterType = type.MakeArrayType();
            shiftsListField  = AccessTools.FieldRefAccess <IList>(type, "shifts");

            type             = AccessTools.TypeByName("CashRegister.Shifts.Shift");
            shiftConstructor = AccessTools.Constructor(type);
            timetableField   = AccessTools.FieldRefAccess <object>(type, "timetable");
            assignedField    = AccessTools.FieldRefAccess <List <Pawn> >(type, "assigned");

            type       = AccessTools.TypeByName("CashRegister.Timetable.TimetableBool");
            timesField = AccessTools.FieldRefAccess <List <bool> >(type, "times");
        }
示例#3
0
 protected override void OnSetSync(SyncType type)
 {
     if (syncType == SyncType.UpLoad)
     {
         inputModel = InputController.instance.GetModel <InputModel>(InputModel.name);
     }
 }
示例#4
0
        public static string GetSyncQueueName(SyncType syncType)
        {
            switch (syncType)
            {
            case SyncType.InventoryQuantity:
            {
                return(InventoryQuantitySyncQueue);
            }

            case SyncType.InventoryPrice:
            {
                return(InventoryPriceSyncQueue);
            }

            case SyncType.VendorQuantity:
            {
                return(VendorQuantitySyncQueue);
            }

            default:
            {
                return(null);
            }
            }
        }
示例#5
0
        internal static async Task StartSearchSync(IDurableOrchestrationClient starter,
                                                   ILogger log, SyncType syncType)

        {
            var model            = new SearchSyncInput(syncType);
            var existingInstance = await starter.GetStatusAsync(model.InstanceId);

            if (existingInstance == null)
            {
                log.LogInformation($"start new instance of {syncType}");
                await starter.StartNewAsync(SearchSyncName, model.InstanceId, model);

                return;
            }
            if (existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Failed)
            {
                log.LogInformation($"terminate existing instance");
                await starter.TerminateAsync(model.InstanceId, "the status failed");
            }

            if (existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Running)
            {
                if (existingInstance.LastUpdatedTime < DateTime.UtcNow.AddHours(-1))
                {
                    log.LogError($"issue with {syncType}");
                    await starter.TerminateAsync(model.InstanceId, $"issue with {syncType}");
                }
                else
                {
                    log.LogInformation($"{model.InstanceId} is in status {existingInstance.RuntimeStatus}");
                    return;
                }
            }
            await starter.StartNewAsync(SearchSyncName, model.InstanceId, model);
        }
示例#6
0
        public IAsyncResult LogOnAndSyncAsync(SyncType syncType)
        {
            SyncType = syncType;
            Action d = () => { Sync(); };

            return(d.BeginInvoke(SyncCompletionCallback, null));
        }
示例#7
0
        public void SetCacheTypeDb(SPList spList, SyncType syncType)
        {
            if (spList == null)
            {
                return;
            }

            string listUrl = spList.Url();

            TOut settings = this.GetSettings();
            CustomViewSettings listSettings = settings.ViewSettings.FirstOrDefault(s => s.ListUrl == listUrl);

            if (listSettings == null)
            {
                settings.ViewSettings.Add(new CustomViewSettings
                {
                    ListUrl   = listUrl,
                    CacheType = new List <SyncType> {
                        syncType
                    }
                });
            }
            else
            {
                if (!listSettings.CacheType.Contains(syncType))
                {
                    listSettings.CacheType.Add(syncType);
                }
            }

            this.SetSettings(settings);
        }
示例#8
0
        public MyShipToolBase()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_useConveyorSystem = SyncType.CreateAndAddProp <bool>();
#endif // XB1
            CreateTerminalControls();
        }
示例#9
0
        public async Task UnSubscribe(long idGroup, SyncType syncType)
        {
            string dictionaryKey = DictionaryKey(idGroup, syncType);

            connectedToGroups.Remove(dictionaryKey);
            await Groups.RemoveFromGroupAsync(Context.ConnectionId, dictionaryKey);
        }
示例#10
0
        public MyShipWelder()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_helpOthers = SyncType.CreateAndAddProp <bool>();
#endif // XB1
            CreateTerminalControls();
        }
        private bool IsPreviousMessage(SyncType syncType, string inventoryId, Message msg, string warehouse)
        {
            bool result = false;
            var  reader = new StreamReader(msg.BodyStream);

            try
            {
                var json   = reader.ReadToEnd();
                var msgObj = JsonConvert.DeserializeObject <KCMSMQMessage>(json);

                if (KCMSMQQueueHelper.ParseSyncName(msgObj.Query) == syncType)
                {
                    //should be only one inserted
                    var firstInserted = (JToken)msgObj.Inserted.FirstOrDefault();
                    if (firstInserted != null && firstInserted.SelectToken(INVENTORY_ID)?.ToString() == inventoryId &&
                        firstInserted.SelectToken("WarehouseID")?.ToString() == warehouse)
                    {
                        result = true;
                    }
                }
            }
            finally
            {
                reader.Dispose();
            }

            return(result);
        }
示例#12
0
 private void OnSyncItemMasterChangeAction(Product item, SyncType type)
 {
     if (SyncItemMasterChangeEvent != null)
     {
         SyncItemMasterChangeEvent(item, type);
     }
 }
示例#13
0
        /// <summary>
        /// Syncs the rotation.
        /// </summary>
        /// <returns>The rotation.</returns>
        /// <param name="targetId">Target identifier.</param>
        /// <param name="type">Type.</param>
        /// <param name="objId">Object identifier.</param>
        /// <param name="rotation">Rotation.</param>
        public void SyncRotation(string targetId, SyncType type, string objId, Vector3 rotation)
        {
            string     rid;
            MqttHelper mqttHelper = ChooseMqtt(type, out rid);

            if (mqttHelper == null)
            {
                return;
            }

            SyncRotate headRotate = new SyncRotate();

            headRotate.type = type;
            headRotate.id   = objId;
            headRotate.rx   = rotation.x;
            headRotate.ry   = rotation.y;
            headRotate.rz   = rotation.z;
            headRotate.time = TimeHelper.GetTimestamp();

            //Debug.Log("SyncRotation type:" + type + "objid:" + objId + " rot:" + rotation + " time:" + headRotate.time);
            if (_lastRotTime >= headRotate.time)
            {
                Debug.Log("SyncRotation 顺序错误 cur:" + headRotate.time + " last:" + _lastRotTime);
            }
            _lastRotTime = headRotate.time;
            byte[] cmd = EncodeStruct <SyncRotate>(headRotate);
            if (targetId == null)
            {
                SendCmdMessage(mqttHelper, rid, NetCmdIdClient.SyncRotate, cmd);
            }
            else
            {
                SendCmdMessage(mqttHelper, targetId, NetCmdIdClient.SyncRotate, cmd);
            }
        }
示例#14
0
        /// <summary>
        /// 同步动画
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="objId">对象id, 数字人时穿null</param>
        /// <param name="animId">动画id</param>
        public void SyncAnimation(SyncType type, string objId, int animId)
        {
            string     rid;
            MqttHelper mqttHelper = ChooseMqtt(type, out rid);

            if (mqttHelper == null)
            {
                return;
            }

            SyncAnim syncAnim = new SyncAnim();

            syncAnim.type = type;
            if (type == SyncType.VirtualMan)
            {
                syncAnim.id = this.uid;
            }
            else
            {
                syncAnim.id = objId;
            }
            syncAnim.amimid = animId;
            syncAnim.time   = TimeHelper.GetTimestamp();

            byte[] cmd = EncodeStruct <SyncAnim>(syncAnim);

            SendCmdMessage(mqttHelper, rid, NetCmdIdClient.SyncAnim, cmd);
        }
示例#15
0
        public MyBatteryBlock()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_isFull          = SyncType.CreateAndAddProp <bool>();
            m_onlyRecharge    = SyncType.CreateAndAddProp <bool>();
            m_onlyDischarge   = SyncType.CreateAndAddProp <bool>();
            m_semiautoEnabled = SyncType.CreateAndAddProp <bool>();
            m_producerEnabled = SyncType.CreateAndAddProp <bool>();
            m_storedPower     = SyncType.CreateAndAddProp <float>();
#endif // XB1
            CreateTerminalControls();

            SourceComp   = new MyResourceSourceComponent();
            ResourceSink = new MyResourceSinkComponent();
            m_semiautoEnabled.ValueChanged += (x) => UpdateMaxOutputAndEmissivity();
            m_onlyRecharge.ValueChanged    += (x) => { if (m_onlyRecharge.Value)
                                                       {
                                                           m_onlyDischarge.Value = false;
                                                       }
                                                       UpdateMaxOutputAndEmissivity(); };
            m_onlyDischarge.ValueChanged += (x) => { if (m_onlyDischarge.Value)
                                                     {
                                                         m_onlyRecharge.Value = false;
                                                     }
                                                     UpdateMaxOutputAndEmissivity(); };

            m_producerEnabled.ValueChanged += (x) => ProducerEnadChanged();
            m_storedPower.ValueChanged     += (x) => CapacityChanged();
        }
示例#16
0
        /// <summary>
        /// 同步位置
        /// </summary>
        /// <param name="targetId">目标id</param>
        /// <param name="type">同步类型</param>
        /// <param name="objId">对象id</param>
        /// <param name="position">位置</param>
        public void SyncPosition(string targetId, SyncType type, string objId, Vector3 position)
        {
            string     rid;
            MqttHelper mqttHelper = ChooseMqtt(type, out rid);

            if (mqttHelper == null)
            {
                return;
            }

            SyncPos headPos = new SyncPos();

            headPos.type = type;
            headPos.id   = objId;
            headPos.px   = position.x;
            headPos.py   = position.y;
            headPos.pz   = position.z;
            headPos.time = TimeHelper.GetTimestamp();

            //Debug.Log("SyncPosition type:" + type + "objid:" + objId + " pos:" + position + " time:" + headPos.time);
            if (_lastPosTime >= headPos.time)
            {
                //Debug.Log("SyncPosition 顺序错误 cur:" + headPos.time + " last:" + _lastPosTime);
            }
            _lastPosTime = headPos.time;
            byte[] cmd = EncodeStruct <SyncPos>(headPos);
            if (targetId == null)
            {
                SendCmdMessage(mqttHelper, rid, NetCmdIdClient.SyncPos, cmd);
            }
            else
            {
                SendCmdMessage(mqttHelper, targetId, NetCmdIdClient.SyncPos, cmd);
            }
        }
示例#17
0
 public Syncer(SyncType type)
 {
     Type = type;
     Resources = new ConcurrentDictionary<Guid, List<Resource>>();
     Buffer = new ConcurrentDictionary<Guid, Activity>();
     EventType = new ConcurrentDictionary<Guid, ActivityEvent>(); 
 }
示例#18
0
        public MySmallGatlingGun()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_useConveyorSystem = SyncType.CreateAndAddProp <bool>();
#endif // XB1
            CreateTerminalControls();

            m_rotationAngle        = MyUtils.GetRandomRadian();
            m_lastTimeShoot        = MyConstants.FAREST_TIME_IN_PAST;
            m_smokeLastTime        = MyConstants.FAREST_TIME_IN_PAST;
            m_smokesToGenerate     = 0;
            m_cannonMotorEndPlayed = true;
            m_rotationTimeout      = (float)MyGatlingConstants.ROTATION_TIMEOUT + MyUtils.GetRandomFloat(-500, +500);

            m_soundEmitter = new MyEntity3DSoundEmitter(this, true);

#if XB1// XB1_SYNC_NOREFLECTION
            m_gunBase = new MyGunBase(SyncType);
#else // !XB1
            m_gunBase = new MyGunBase();
#endif // !XB1

            NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;
            Render.NeedsDrawFromParent = true;

            Render = new MyRenderComponentSmallGatlingGun();
            AddDebugRenderComponent(new MyDebugRenderComponentSmallGatlingGun(this));

#if !XB1 // !XB1_SYNC_NOREFLECTION
            SyncType.Append(m_gunBase);
#endif // !XB1
        }
示例#19
0
        private void ServiceBridge(SyncType syncType, bool full = false)
        {
            if (useNominalSyncHoldoffTimer)
            {
                nominalSyncHoldoffTimer.Reset();
            }

            switch (syncType)
            {
            default:
            case SyncType.From1To2Then2To1:
                Sync1To2(full);
                Sync2To1(full);
                break;

            case SyncType.From1To2:
                Sync1To2(full);
                break;

            case SyncType.From2To1:
                Sync2To1(full);
                break;

            case SyncType.From2To1Then1To2:
                Sync2To1(full);
                Sync1To2(full);
                break;
            }
        }
 public MySmallMissileLauncher()
 {
     m_gunBase                 = new MyGunBase();
     m_soundEmitter            = new MyEntity3DSoundEmitter(this, true);
     m_useConveyorSystem.Value = true;
     SyncType.Append(m_gunBase);
 }
示例#21
0
        /// <summary>
        /// 根据链接状态, 优先选择数字人服务器
        /// </summary>
        /// <param name="rid">返回的房间id</param>
        /// <returns>返回的mqtt</returns>
        private MqttHelper ChooseMqtt(SyncType type, out string rid)
        {
            MqttHelper mqttHelper = null;

            rid = "";
            if (type == SyncType.VirtualMan && virtualManNetState == NetState.Connect)
            {
                mqttHelper = virtualManMqtt;
                rid        = virtualManRid;
            }
            else if (type == SyncType.SpectatorView && spectatorViewNetState == NetState.Connect)
            {
                mqttHelper = spectatorViewMqtt;
                rid        = spectatorViewRid;
            }
            else if (type == SyncType.Other)
            {
                if (virtualManNetState == NetState.Connect)
                {
                    mqttHelper = virtualManMqtt;
                    rid        = virtualManRid;
                }
                else if (spectatorViewNetState == NetState.Connect)
                {
                    mqttHelper = spectatorViewMqtt;
                    rid        = spectatorViewRid;
                }
            }

            return(mqttHelper);
        }
示例#22
0
        public int AddPath(string path, string destinationPath, SyncType syncType, FileType fileType)
        {
            lock (this.myLockingObject)
            {
                int ogCount = this.Settings.Count;

                try
                {
                    this.Settings.Add(new Setting
                    {
                        Path            = path,
                        DestinationPath = destinationPath,
                        SyncType        = syncType,
                        FileType        = fileType
                    });
                }
                catch (Exception e)
                {
                    while (this.Settings.Count > ogCount)
                    {
                        this.Settings.RemoveAt(this.Settings.Count - 1);
                    }
                    throw e;
                }

                fireUpdatedEvent();
                return(this.Settings.Count - 1);
            }
        }
示例#23
0
        public MyMotorSuspension()
        {
#if XB1                                                                // XB1_SYNC_NOREFLECTION
            m_dummyDisplacement = SyncType.CreateAndAddProp <float>(); //<== from base class

            m_steerAngle       = SyncType.CreateAndAddProp <float>();
            m_brake            = SyncType.CreateAndAddProp <bool>();
            m_damping          = SyncType.CreateAndAddProp <float>();
            m_strenth          = SyncType.CreateAndAddProp <float>();
            m_friction         = SyncType.CreateAndAddProp <float>();
            m_height           = SyncType.CreateAndAddProp <float>();
            m_suspensionTravel = SyncType.CreateAndAddProp <float>();
            m_speedLimit       = SyncType.CreateAndAddProp <float>();
            m_maxSteerAngle    = SyncType.CreateAndAddProp <float>();
            m_steerSpeed       = SyncType.CreateAndAddProp <float>();
            m_steerReturSpeed  = SyncType.CreateAndAddProp <float>();
            m_invertSteer      = SyncType.CreateAndAddProp <bool>();
            m_invertPropulsion = SyncType.CreateAndAddProp <bool>();
            m_power            = SyncType.CreateAndAddProp <float>();
            m_steering         = SyncType.CreateAndAddProp <bool>();
            m_propulsion       = SyncType.CreateAndAddProp <bool>();
#endif // XB1
            CreateTerminalControls();

            m_brake.ValueChanged            += (x) => UpdateBrake();
            m_friction.ValueChanged         += (x) => FrictionChanged();
            m_damping.ValueChanged          += (x) => DampingChanged();
            m_strenth.ValueChanged          += (x) => StrenghtChanged();
            m_height.ValueChanged           += (x) => ReattachConstraint();
            m_suspensionTravel.ValueChanged += (x) => ReattachConstraint();
        }
示例#24
0
 public SyncObject(string referenceID, DateTime modifyDate, SyncType syncType, string url)
 {
     _referenceID = referenceID;
     _modifyDate  = modifyDate;
     _syncType    = syncType;
     _url         = url;
 }
        /// <summary>
        /// Gets supported values by element.
        /// </summary>
        /// <param name="element">SyncType element.</param>
        /// <returns>Array of supported values.</returns>
        static private string _GetSupportedValues(SyncType element)
        {
            string supportedValues = null;

            switch (element)
            {
            case SyncType.ActiveSync:
                supportedValues = Properties.Resources.SyncTypeActiveSyncSupportedValues;
                break;

            case SyncType.EMail:
                supportedValues = Properties.Resources.SyncTypeEMailSupportedValues;
                break;

            case SyncType.Folder:
                supportedValues = Properties.Resources.SyncTypeFolderSupportedValues;
                break;

            case SyncType.None:
                supportedValues = Properties.Resources.SyncTypeNoneSupportedValues;
                break;

            case SyncType.WMServer:
                supportedValues = Properties.Resources.SyncTypeWMServerSupportedValues;
                break;

            default:
                Debug.Assert(false);     // NOTE: not supported
                break;
            }

            return(supportedValues);
        }
示例#26
0
 private void OnSyncItemCategoryChangeAction(Category item, SyncType type)
 {
     if (SyncItemCategoryChangeEvent != null)
     {
         SyncItemCategoryChangeEvent(item, type);
     }
 }
示例#27
0
        public MyFracturedPiece()
            : base()
        {
            //EntityId = MyEntityIdentifier.AllocateId();

            //TODO: Synchronize through manager to avoid performance hits
            SyncFlag = true;

            base.PositionComp           = new MyFracturePiecePositionComponent();
            base.Render                 = new MyRenderComponentFracturedPiece();
            base.Render.NeedsDraw       = true;
            base.Render.PersistentFlags = MyPersistentEntityFlags2.Enabled;
            AddDebugRenderComponent(new MyFracturedPieceDebugDraw(this));
            UseDamageSystem = false;
            NeedsUpdate     = MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
#if !XB1 // !XB1_SYNC_NOREFLECTION
            SyncType = SyncHelpers.Compose(this);
#else // XB1
            SyncType = new SyncType(new List <SyncBase>());
            m_fallSoundShouldPlay = SyncType.CreateAndAddProp <bool>();
            m_fallSoundString     = SyncType.CreateAndAddProp <string>();
#endif // XB1
            m_fallSoundShouldPlay.Value     = false;
            m_fallSoundString.Value         = "";
            m_fallSoundString.ValueChanged += (x) => SetFallSound();
        }
        private ViewOverrider(SPList spList, SPQuery spQuery, SPUser currentUser)
        {
            SyncType syncType = SyncType.SpList;

            this._syncProvider = new SpSyncProvider(syncType);
            this._camlXmlQuery = CamlXmlView.TryParse <CamlXmlView>(spQuery.ViewXml);
            this._currentUser  = currentUser;
            this._spList       = spList;

            this._head = new HeadList
            {
                Heads = new List <Head>
                {
                    new Head
                    {
                        Position     = "Top",
                        ColumnGroups = new List <ColumnGroup>
                        {
                            new ColumnGroup
                            {
                                Hide = true
                            }
                        }
                    }
                }
            };

            this._sqlFilterString         = this.BuildSqlFilterString();
            this._settingsAllreadyCreated = true;
        }
        private void Sync(SyncType syncType)
        {
            switch (syncType)
            {
            case SyncType.Health:
                _uiView.Health = _playerModel.Health;
                return;

            case SyncType.Armor:
                _uiView.Armor = _playerModel.Armor;
                return;

            case SyncType.AttackValue:
                _uiView.AttackValue = _playerModel.AttackValue;
                return;

            case SyncType.VampireValue:
                _uiView.VampireValue = _playerModel.VampireValue;
                return;

            case SyncType.StatsPanel:
                _uiView.PlayerPanelHierarchy = _playerModel.PlayerPanelHierarchy;
                return;

            default:
                throw new ArgumentOutOfRangeException("syncType", syncType, null);
            }
        }
 public Smi FromSync(SyncAttr sync)
 {
     start    = sync.start;
     syncType = sync.startType;
     FromAttr(sync.text);
     return(this);
 }
示例#31
0
        public MyDoorBase()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_open = SyncType.CreateAndAddProp <bool>();
#endif // XB1
            CreateTerminalControls();
        }
示例#32
0
        public MySyncedBlock()
        {
#if !XB1 // !XB1_SYNC_NOREFLECTION
            SyncType = SyncHelpers.Compose(this);
#else // XB1
            SyncType = new SyncType(new List<SyncBase>());
#endif // XB1
        }
示例#33
0
 public Synchronizer(SyncType type, long seed)
 {
     _type = type;
     _rng = new RNG(seed);
     _index = 0;
     _state = null;
     _pinned = false;
 }
 public SyncData GetSyncData(string id, SyncType syncType)
 {
     if (ContainsScreen(id))
     {
         return _syncInfoTable[id].SyncDatas.FirstOrDefault(s => s.SyncType == syncType);
     }
     else
     {
         return null;
     }
 }
示例#35
0
		public void Create(string name, SyncType type, bool apply)
		{
			Synchronizer sync;
			if (!_syncTable.TryGetValue(name, out sync))
				sync = _syncTable[name] = 
					new Synchronizer(type, _sb.RNG.NextRaw())
					{
						Pinned = _pinQueue.Remove(name)
					};
			if (apply) _sb.CurrentBlockAttribs.Sync = sync;
		}
示例#36
0
        public void Sync(string seed, SyncType type)
        {
            Synchronizer sync;
            if (!_synchronizers.TryGetValue(seed, out sync))
            {
                sync = _synchronizers[seed] = new Synchronizer(type, RNG.GetRaw(seed.Hash(), RNG.Seed));
                if (_pinQueue.Contains(seed)) sync.Pinned = true;
                _pinQueue.Remove(seed);
            }

            NextAttribs.Sync = sync;
        }
示例#37
0
        internal bool xUpdate(SyncType xType)
        {
            if (!xLoaded)
                return false;
            try
            {
                xRef.xIO.Position = Offset;
                xRef.xIO.Write(xSettingID);
                xRef.xIO.Position += 4;
                xRef.xIO.Write(xContentID);
                xRef.xIO.Position += 7;
                switch (ContentType)
                {
                    case SettingType.Context:
                    case SettingType.Binary:
                        {
                            byte[] xIn = (byte[])xdata;
                            int currentsize = (0x18 + xIn.Length);
                            if (currentsize < xSize)
                                xRef.xFreeEnts.Add(new FreeSpaceEntry(xRef, xOffset + xIn.Length, xSize - currentsize));
                            else if (currentsize > xSize)
                            {
                                int pos = xRef.AllocateData(currentsize);
                                if (pos == -1)
                                    return false;
                                xRef.xIO.Position = pos + xRef.HeaderSize;
                                xRef.xIO.Write(xSettingID);
                                xRef.xIO.Write(new byte[4]);
                                xRef.xIO.Write(xContentID);
                                xRef.xIO.Write(new byte[7]);
                                xRef.xFreeEnts.Add(new FreeSpaceEntry(xRef, xOffset, xSize));
                                xOffset = pos;
                            }
                            xSize = currentsize;
                            xRef.xIO.Write(((byte[])xdata).Length);
                            xRef.xIO.Write(Var2);
                            xRef.xIO.Write((byte[])xdata);
                            xRef.xIO.Flush();
                        }
                        break;

                    case SettingType.Unicode:
                        {
                            string xIn = (string)xdata;
                            int stringlen = ((xIn.Length + 1) * 2);
                            int currentsize = (0x18 + stringlen);
                            if (currentsize < xSize)
                                xRef.xFreeEnts.Add(new FreeSpaceEntry(xRef, xOffset + stringlen, xSize - currentsize));
                            else if (currentsize > xSize)
                            {
                                int pos = xRef.AllocateData(currentsize);
                                if (pos == -1)
                                    return false;
                                xRef.xIO.Position = pos + xRef.HeaderSize;
                                xRef.xIO.Write(xSettingID);
                                xRef.xIO.Write(new byte[4]);
                                xRef.xIO.Write(xContentID);
                                xRef.xIO.Write(new byte[7]);
                                xRef.xFreeEnts.Add(new FreeSpaceEntry(xRef, xOffset, xSize));
                                xOffset = pos;
                            }
                            xSize = currentsize;
                            xRef.xIO.Write(stringlen);
                            xRef.xIO.Write(Var2);
                            xRef.xIO.Write((string)xdata, StringForm.Unicode);
                            xRef.xIO.Write((short)0);
                            xRef.xIO.Flush();
                        }
                        break;

                    case SettingType.DateTime:
                        xRef.xIO.Write((long)xdata);
                        xRef.xIO.Flush();
                        return true;

                    case SettingType.Float:
                        xRef.xIO.Write((float)xdata);
                        xRef.xIO.Flush();
                        break;

                    case SettingType.Double:
                        xRef.xIO.Write((double)xdata);
                        xRef.xIO.Flush();
                        break;

                    case SettingType.UInt32:
                        if (xdata.GetType().ToString().ToLower() == "system.uint32")
                            xRef.xIO.Write((uint)xdata);
                        else
                            xRef.xIO.Write((int)xdata);
                        xRef.xIO.Flush();
                        break;

                    case SettingType.Int64:
                        xRef.xIO.Write((long)xdata);
                        xRef.xIO.Flush();
                        break;

                    default:
                        return true;
                }
                if (xType != SyncType.None)
                    return xRef.UpdateSync(NameSpace.Setting, ID, xType) & xRef.UpdateHeader();
                return xRef.UpdateHeader();
            }
            catch { return false; }
        }
示例#38
0
        public void Save(SyncType syncType)
        {

            using (SsepsIISynEntities ents = new SsepsIISynEntities())
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    switch (syncType)
                    {
                        case SyncType.Consolidate:
                            if (SiteConfigServices.IsManagedMDA(MdaId))
                            {
                                //If approved, then move the Assignment to history
                                //TODO test this well later
                                SendEmployeeAssignmentToHistory();
                                ClearTransData();
                            }
                            else
                            {
                                InsertEmployee();
                                InsertEmployeeAssignment();
                                InsertPayItems();
                                InsertEmployeeBankAccount();
                                InsertEmployeeEvent();
                            }
                            break;
                        case SyncType.Approval:
                            if (SiteConfigServices.IsManagedMDA(MdaId))
                            {
                                if (State == SyncState.Rejected)//Rejected
                                {
                                    UndoEmployeeBankAccount();
                                    UndoPayItems();
                                    UndoEmployeeAssignment();
                                    UndoEmployee();
                                }
                                //ClearTransData();
                            }
                            break;
                    }
                    scope.Complete();
                }
            }
        }
示例#39
0
        public MyTerminalBlock()
        {
            CustomName = new StringBuilder();
            DetailedInfo = new StringBuilder();
            CustomInfo = new StringBuilder();
            CustomNameWithFaction = new StringBuilder();

            SyncType = SyncHelpers.Compose(this);
            SyncType.PropertyChanged += sync => RaisePropertiesChanged();
        }
示例#40
0
 public static DateTime GetLastSyncTime(string exportPath,Department department,SyncType syncType)
 {
     DateTime lastSyncTime = DateTime.MinValue;
     string[] syncTimeFiles = Directory.GetFiles(exportPath, "*.synctime");
     string mark = "_Status";
     if(syncType == SyncType.SyncUp)
     {
         mark += "SyncUp";
     }
     if (syncType == SyncType.SyncDown)
     {
         mark += "SyncDown";
     }
     foreach (string file in syncTimeFiles)
     {
         if(file.IndexOf(department.DepartmentId + mark) >=0 )
         {
             Stream stream = File.OpenRead(file);
             BinaryFormatter formatter = new BinaryFormatter();
             lastSyncTime  = (DateTime)formatter.Deserialize(stream);
             stream.Close();
         }
     }
     return lastSyncTime;
 }
示例#41
0
 public static void WriteSyncTableTitle(StringBuilder sbLog, string tableName, SyncType type, string condition)
 {
     sbLog.AppendLine(string.Format("同步表:{0}; 同步方式:{1}; 同步条件:{2};", tableName, EnumHelper.GetFieldDescription(typeof(SyncType), (int)type), condition));
 }
 public MyPropertySyncStateGroup(IMyReplicable ownerReplicable, SyncType syncType)
 {
     Owner = ownerReplicable;
     syncType.PropertyChanged += Notify;
     m_properties = syncType.Properties;
 }
示例#43
0
        public MyInventory(MyFixedPoint maxVolume, MyFixedPoint maxMass, Vector3 size, MyInventoryFlags flags, MyEntity owner)
            : base("Inventory")
        {
            m_maxVolume = maxVolume;
            m_maxMass = maxMass;
            m_flags = flags;

            SyncType = SyncHelpers.Compose(this);
            m_currentVolume.ValueChanged += (x) => PropertiesChanged();
            m_currentVolume.ValidateNever();

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

            Clear();

            //Debug.Assert(owner != null, "Inventory must have always owner!"); - nope, this can be deserialized and therefore owner can be set to null..

            if (owner != null)
            {
                MyInventoryBase inventory;
                if ((owner as MyEntity).Components.TryGet<MyInventoryBase>(out inventory) && inventory is IMyComponentAggregate)
                {
                    IMyComponentAggregate aggregate = inventory as IMyComponentAggregate;
                    if (!aggregate.ChildList.Contains(this))
                    {
                        aggregate.AddComponent(this);
                    }
                }
                else if (inventory != null)
                {
                    MyInventoryAggregate aggregate = new MyInventoryAggregate();
                    (owner as MyEntity).Components.Add<MyInventoryBase>(aggregate);
                    aggregate.AddComponent(inventory);
                    aggregate.AddComponent(this);
                }
                else
                {
                    (owner as MyEntity).Components.Add<MyInventoryBase>(this);
                }
            }
        }
示例#44
0
 public MyGunBase(SyncType syncType)
示例#45
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();
        }
        /// <summary>
        /// Gets supported values by element.
        /// </summary>
        /// <param name="element">SyncType element.</param>
        /// <returns>Array of supported values.</returns>
        private static string _GetSupportedValues(SyncType element)
        {
            string supportedValues = null;
            switch (element)
            {
                case SyncType.ActiveSync:
                    supportedValues = Properties.Resources.SyncTypeActiveSyncSupportedValues;
                    break;
                case SyncType.EMail:
                    supportedValues = Properties.Resources.SyncTypeEMailSupportedValues;
                    break;
                case SyncType.Folder:
                    supportedValues = Properties.Resources.SyncTypeFolderSupportedValues;
                    break;
                case SyncType.None:
                    supportedValues = Properties.Resources.SyncTypeNoneSupportedValues;
                    break;
                case SyncType.WMServer:
                    supportedValues = Properties.Resources.SyncTypeWMServerSupportedValues;
                    break;
                default:
                    Debug.Assert(false); // NOTE: not supported
                    break;
            }

            return supportedValues;
        }
示例#47
0
        /// <summary>
        /// Synchronizes the files in the source and the destination 
        /// </summary>
        /// <param name="sourcePath">Path of the source</param>
        /// <param name="destinationPath">path of the destination</param>
        public void Synchronize(string sourcePath, string destinationPath,SyncType syncType)
        {
            //count the number of files in the directories
            int nfiles = 0;
            //foreach (string[] directory in drive.source)
            //{
            //    nfiles += directoryFiles(directory[0]);
            //}

            if (syncType == SyncType.USBToPCDeleteSource)
            {
                MoveFolderAsync(destinationPath, sourcePath);
            }
            else if (syncType == SyncType.USBToPCKeepSource)
            {
                CopyFolderAsync(destinationPath, sourcePath);
            }
            else if (syncType == SyncType.PCToUSBDeleteSource)
            {
                MoveFolderAsync(sourcePath, destinationPath);
            }
            else if (syncType == SyncType.PCToUSBKeepSource)
            {
                CopyFolderAsync(sourcePath, destinationPath);
            }
            else if (syncType == SyncType.TwoWay)
            {
                CopyFolderAsync(sourcePath, destinationPath);
            }
            
            string[] dirs = Directory.GetDirectories(sourcePath);
            foreach (String dir in dirs)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(dir);
                Synchronize(dir, Path.Combine(destinationPath, dirInfo.Name),syncType);
                string value = Path.Combine(destinationPath, dirInfo.Name);
            }


        }
示例#48
0
 /// <summary>
 /// Updates the data
 /// </summary>
 /// <param name="xType"></param>
 /// <returns></returns>
 public bool Update(SyncType xType)
 {
     if (!xRef.ParseCheck())
         return false;
     return (xUpdate(xType) & !(xRef.xActive = false));
 }
示例#49
0
        internal bool xAddSetting(long ID, object Data, bool AutomaticOverwrite, SyncType xSync)
        {
            try
            {
                int idx = ContainsSetting(ID);
                if (idx != -1 && !AutomaticOverwrite)
                    return false;
                int xSize = 0x18;
                long pos = 0;
                SettingType xType = SettingType.Null;
                for (int i = 0; i < 2; i++)
                {
                    switch (Data.GetType().ToString().ToLower())
                    {
                        case "system.single":
                            {
                                if (i == 0)
                                    xType = SettingType.Float;
                                else
                                {
                                    xIO.Write((float)Data);
                                    xIO.Write((int)0);
                                }
                            }
                            break;

                        case "system.double":
                            {
                                if (i == 0)
                                    xType = SettingType.Double;
                                else
                                    xIO.Write((double)Data);
                            }
                            break;

                        case "system.int32":
                            {
                                if (i == 0)
                                    xType = SettingType.UInt32;
                                else
                                {
                                    xIO.Write((int)Data);
                                    xIO.Write((int)0);
                                }
                            }
                            break;

                        case "system.uint32":
                            {
                                if (i == 0)
                                    xType = SettingType.UInt32;
                                else
                                {
                                    xIO.Write((uint)Data);
                                    xIO.Write((uint)0);
                                }
                            }
                            break;

                        case "system.int64":
                            {
                                if (i == 0)
                                    xType = SettingType.Int64;
                                else
                                    xIO.Write((long)Data);
                            }
                            break;

                        case "system.datetime":
                            {
                                if (i == 0)
                                    xType = SettingType.DateTime;
                                else
                                    xIO.Write(((DateTime)Data).ToFileTime());
                            }
                            break;

                        case "system.byte[]":
                            {
                                if (i == 0)
                                {
                                    xType = SettingType.Binary;
                                    byte[] xIn = (byte[])Data;
                                    xSize += xIn.Length;
                                }
                                else
                                {
                                    byte[] xIn = (byte[])Data;
                                    xIO.Write(xIn.Length);
                                    xIO.Write(new byte[4]);
                                    xIO.Write(xIn);
                                }
                            }
                            break;

                        case "system.string":
                            {
                                if (i == 0)
                                {
                                    xType = SettingType.Unicode;
                                    string xIn = (string)Data;
                                    xSize += ((xIn.Length + 1) * 2);
                                }
                                else
                                {
                                    string xIn = (string)Data;
                                    xIO.Write((xIn.Length + 1) * 2);
                                    xIO.Write(new byte[4]);
                                    xIO.Write(xIn, StringForm.Unicode);
                                    xIO.Write((short)0);
                                }
                            }
                            break;

                        default:
                            return (xActive = false);
                    }
                    if (i == 0)
                    {
                        if (xType == SettingType.Null)
                            return false;
                        pos = AllocateData(xSize);
                        if (pos == -1)
                            return false;
                        else if (idx != -1)
                        {
                            xFreeEnts.Add(new FreeSpaceEntry(xUserSettings[idx]));
                            PatchFree();
                            xUserSettings.RemoveAt(idx);
                        }
                        xIO.Position = pos + HeaderSize;
                        xIO.Write((uint)ID);
                        xIO.Write(new byte[4]);
                        xIO.Write((byte)xType);
                        xIO.Write(new byte[7]);
                    }
                    else
                        xIO.Flush();
                }
                XDBFEntry xent = new XDBFEntry(NameSpace.Setting, ID, (int)pos, xSize, this);
                if (!xent.Valid)
                    return false;
                xUserSettings.Add(new Setting(xent));
                xUserSettings[xUserSettings.Count - 1].LoadDetails();
                if (xSync != SyncType.None)
                    UpdateSync(NameSpace.Setting, ID, xSync);
                return UpdateHeader();
            }
            catch { return false; }
        }
示例#50
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());
        }
        public MyFloatingObject()
        {
            WasRemovedFromWorld = false;
            m_soundEmitter = new MyEntity3DSoundEmitter(this);
            m_lastTimePlayedSound = MySandboxGame.TotalGamePlayTimeInMilliseconds;
            Render = new Components.MyRenderComponentFloatingObject();

#if !XB1 // !XB1_SYNC_NOREFLECTION
            SyncType = SyncHelpers.Compose(this);
#else // XB1
            SyncType = new SyncType(new List<SyncBase>());
            Amount = SyncType.CreateAndAddProp<MyFixedPoint>();
#endif // XB1

            Amount.ValueChanged += (x) => { Item.Amount = Amount.Value; UpdateInternalState(); };
        }
示例#52
0
 internal bool UpdateSync(NameSpace xNS, long ID, SyncType xType)
 {
     if (xType == SyncType.None)
         return true;
     int idx1 = -1, idx2 = -1;
     for (int i = 0; i < xIndexRecords.Count; i++)
     {
         if (xIndexRecords[i].NS != xNS)
             continue;
         idx1 = i;
         break;
     }
     for (int i = 0; i < xSyncs.Count; i++)
     {
         if (xSyncs[i].NS != xNS)
             continue;
         idx2 = i;
         break;
     }
     if (idx1 == -1 || idx2 == -1)
     {
         RecordEntry xidx = null;
         SyncEntry xsync = null;
         if (idx1 == -1)
         {
             int xsize;
             if (xNS != NameSpace.Achievement)
                 xsize = 0x10;
             else
                 xsize = (0x10 * xAchievements.Count);
             int pos = AllocateData(xsize);
             if (pos == -1)
                 return false;
             xidx = new RecordEntry(new XDBFEntry(xNS, (long)GPDIDs.IndexRecord, pos, xsize, this));
             if (xNS == NameSpace.Achievement)
             {
                 for (int i = 0; i < xAchievements.Count; i++)
                     xidx.xpairs.Add(new SyncPair(xAchievements[i].ID, i + 1));
             }
         }
         if (idx2 == -1)
         {
             int pos = AllocateData(0x18);
             if (pos == -1)
                 return false;
             xsync = new SyncEntry(new XDBFEntry(xNS, (long)GPDIDs.SyncRecord, pos, 0x18, this));
             if (xNS == NameSpace.Achievement)
             {
                 xsync.xLastSync = 0;
                 xsync.xNext = xAchievements.Count + 1;
             }
         }
         if (xidx != null)
         {
             xIndexRecords.Add(xidx);
             xIndexRecords.Sort(new Comparison<RecordEntry>(sortns));
             idx1 = xIndexRecords.IndexOf(xidx);
         }
         if (xsync != null)
         {
             xSyncs.Add(xsync);
             xSyncs.Sort(new Comparison<SyncEntry>(sortns));
             idx2 = xSyncs.IndexOf(xsync);
         }
     }
     long curnext = xSyncs[idx2].Next;
     for (int i = 0; i < xIndexRecords[idx1].xpairs.Count; i++)
     {
         if (xIndexRecords[idx1].xpairs[i].ID == ID)
             xIndexRecords[idx1].xpairs.RemoveAt(i--);
     }
     if (xType == SyncType.Server)
         xIndexRecords[idx1].xpairs.Add(new SyncPair(ID, curnext++));
     else
         xIndexRecords[idx1].xpairs.Add(new SyncPair(ID, 0));
     if (xIndexRecords[idx1].xUpdate())
     {
         xSyncs[idx2].xNext = curnext;
         return xSyncs[idx2].xUpdate();
     }
     return false;
 }
示例#53
0
        public MyInventory(MyFixedPoint maxVolume, MyFixedPoint maxMass, Vector3 size, MyInventoryFlags flags)
            : base("Inventory")
        {
            m_maxVolume = maxVolume;
            m_maxMass = maxMass;
            m_flags = flags;

            SyncType = SyncHelpers.Compose(this);
            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();
        }
示例#54
0
 /// <summary>
 /// Adds a setting with sync option
 /// </summary>
 /// <param name="ID"></param>
 /// <param name="Data"></param>
 /// <param name="AutomaticOverwrite"></param>
 /// <param name="xType"></param>
 /// <returns></returns>
 public bool AddSetting(long ID, object Data, bool AutomaticOverwrite, SyncType xType)
 {
     if (!ParseCheck())
         return false;
     return ((xAddSetting(ID, Data, AutomaticOverwrite, xType)) & !(xActive = false));
 }
示例#55
0
 public static void WriteLastSyncTime(DateTime syncTime,string exportPath,Department department,SyncType syncType)
 {
     DateTime lastSyncTime = DateTime.Now;
     string mark = "_Status";
     if (syncType == SyncType.SyncUp)
     {
         mark += "SyncUp";
     }
     if (syncType == SyncType.SyncDown)
     {
         mark += "SyncDown";
     }
     string lastSyncFile = exportPath + "\\" + department.DepartmentId + mark +".synctime";
     Stream stream = File.Open(lastSyncFile, FileMode.Create);
     BinaryFormatter formatter = new BinaryFormatter();
     formatter.Serialize(stream, syncTime);
     stream.Close();
 }
示例#56
0
        public MyFracturedPiece()
            : base()
        {
            //EntityId = MyEntityIdentifier.AllocateId();

            //TODO: Synchronize through manager to avoid performance hits
            SyncFlag = true;

            base.PositionComp = new MyFracturePiecePositionComponent();
            base.Render = new MyRenderComponentFracturedPiece();
            base.Render.NeedsDraw = true;
            base.Render.PersistentFlags = MyPersistentEntityFlags2.Enabled;
            AddDebugRenderComponent(new MyFracturedPieceDebugDraw(this));
            UseDamageSystem = false;
            NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
#if !XB1 // !XB1_SYNC_NOREFLECTION
            SyncType = SyncHelpers.Compose(this);
#else // XB1
            SyncType = new SyncType(new List<SyncBase>());
            m_fallSoundShouldPlay = SyncType.CreateAndAddProp<bool>();
            m_fallSoundString = SyncType.CreateAndAddProp<string>();
#endif // XB1
            m_fallSoundShouldPlay.Value = false;
            m_fallSoundString.Value = "";
            m_fallSoundString.ValueChanged += (x) => SetFallSound();
        }
示例#57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionStringStruct"/> struct.
 /// </summary>
 /// <remarks>Documented by Dev05, 2009-02-12</remarks>
 private ConnectionStringStruct(DatabaseType typ)
 {
     Typ = typ;
     ConnectionString = string.Empty;
     LearningModuleFolder = string.Empty;
     LmId = -1;
     ProtectedLm = false;
     Password = string.Empty;
     SessionId = new Guid();
     ReadOnly = false;
     SyncType = SyncType.NotSynchronized;
     ServerUser = null;
     ExtensionURI = string.Empty;
 }
        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());
        }
示例#59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionStringStruct"/> struct.
 /// </summary>
 /// <param name="typ">The typ.</param>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="lmId">The lm id.</param>
 /// <param name="synced">if set to <c>true</c> [synced].</param>
 /// <param name="serverUser">The server user.</param>
 /// <remarks>Documented by Dev05, 2008-12-03</remarks>
 public ConnectionStringStruct(DatabaseType typ, string connectionString, int lmId, SyncType synced, IUser serverUser)
     : this(typ)
 {
     ConnectionString = connectionString;
     LmId = lmId;
     SyncType = synced;
     ServerUser = serverUser;
 }
        public MyFracturedPiece()
            : base()
        {
            //EntityId = MyEntityIdentifier.AllocateId();

            //TODO: Synchronize through manager to avoid performance hits
            SyncFlag = true;

            base.PositionComp = new MyFracturePiecePositionComponent();
            base.Render = new MyRenderComponentFracturedPiece();
            base.Render.NeedsDraw = true;
            base.Render.PersistentFlags = MyPersistentEntityFlags2.Enabled;
            AddDebugRenderComponent(new MyFracturedPieceDebugDraw(this));
            UseDamageSystem = false;
            NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
            SyncType = SyncHelpers.Compose(this);
            m_fallSoundShouldPlay.Value = false;
            m_fallSoundString.Value = "";
            m_fallSoundString.ValueChanged += (x) => SetFallSound();
        }