public CarGroup( int startIndex, int endIndex, List <TrainCar> cars, float maxStress, float?maxCouplerStress, Job?job, Track?nextDestination, float minBrakePipePressure, float minBrakeReservoirPressure, float maxBrakeCylinderPressure, float maxBrakeFactor, IEnumerable <char> brakeModes) { this.startIndex = startIndex; this.endIndex = endIndex; this.cars = cars; this.maxStress = maxStress; this.maxCouplerStress = maxCouplerStress; this.job = job; this.nextDestination = nextDestination; this.minBrakePipePressure = minBrakePipePressure; this.minBrakeReservoirPressure = minBrakeReservoirPressure; this.maxBrakeCylinderPressure = maxBrakeCylinderPressure; this.maxBrakeFactor = maxBrakeFactor; this.brakeModes = brakeModes.ToList(); if (this.brakeModes.Count == 0) { this.brakeModes.Add(' '); } }
private void DoJobSpecials(Job?job, EntityUid entity) { foreach (var jobSpecial in job?.Prototype.Special ?? Array.Empty <JobSpecial>()) { jobSpecial.AfterEquip(entity); } }
/// <summary> コマンド実行<オーバーレイジョブフィルタ設定コマンド> </summary> /// <param name="para"> コマンドパラメーター </param> private void _OverlayJobFilterExecute(Job?para) { if (!para.HasValue) { return; } this.OverlayControlModule.SetJobFilter(this.OverlayDataModel, para.Value); }
public Task <Job?> GetAsync(JobIdentifier id, CancellationToken cancel) { Job?job = null; if (_jobs.ContainsKey(id.Id)) { job = _jobs[id.Id]; } return(Task.FromResult(job)); }
/// <summary> /// If a job is available, returns it. Otherwise, returns null. /// </summary> /// <returns>The the descriptor of the next job, if available.</returns> public async Task <JobDescriptor?> TryNextAsync() { Job?job = await _adapter.TryNextAsync(); if (job == null) { return(null); } return(ToJobDescriptor(job)); }
public void AddJob(Job?job) { if (!_isRunning) { throw new InvalidOperationException("Attempt to perform job with stopped job manager."); } if (job == default) { throw new ArgumentException("Attempt to add null job.", nameof(job)); } _pendingJobs.Enqueue(job); _gate.Set(); }
private Color JobColor(Job?job) { if (job == null) { return(Color.white); } return(job.State switch { JobState.Available => Color.yellow, JobState.InProgress => Color.white, JobState.Completed => Color.green, _ => Color.red, });
/// <summary> /// Attempts to spawn a player character onto the given station. /// </summary> /// <param name="station">Station to spawn onto.</param> /// <param name="job">The job to assign, if any.</param> /// <param name="profile">The character profile to use, if any.</param> /// <param name="stationSpawning">Resolve pattern, the station spawning component for the station.</param> /// <returns>The resulting player character, if any.</returns> /// <exception cref="ArgumentException">Thrown when the given station is not a station.</exception> /// <remarks> /// This only spawns the character, and does none of the mind-related setup you'd need for it to be playable. /// </remarks> public EntityUid?SpawnPlayerCharacterOnStation(EntityUid?station, Job?job, HumanoidCharacterProfile?profile, StationSpawningComponent?stationSpawning = null) { if (station != null && !Resolve(station.Value, ref stationSpawning)) { throw new ArgumentException("Tried to use a non-station entity as a station!", nameof(station)); } var ev = new PlayerSpawningEvent(job, profile, station); RaiseLocalEvent(ev); DebugTools.Assert(ev.SpawnResult is { Valid: true } or null); return(ev.SpawnResult); }
public async Task FailedAsync(string id, Exception?ex) { if (!long.TryParse(id, out long jobId)) { throw new ArgumentException("The ID must be an integral value", nameof(id)); } Job?job = await _context.Jobs.Where(j => j.Id == jobId).SingleOrDefaultAsync(); if (job != null) { job.Status = JobStatus.Failed; await _context.SaveChangesAsync(); } }
public async Task <JobDescriptor?> GetJobOrDefaultAsync(string id) { if (!long.TryParse(id, out long jobId)) { throw new ArgumentException("The ID must be an integral value", nameof(id)); } Job?job = await _context.Jobs.Where(j => j.Id == jobId).SingleOrDefaultAsync(); if (job == null) { return(null); } return(ToJobDescriptor(job)); }
public async Task DeleteJobAsync(string id) { if (!long.TryParse(id, out long jobId)) { throw new ArgumentException("The ID must be an integral value", nameof(id)); } Job?job = await _context.Jobs.Where(j => j.Id == jobId).SingleOrDefaultAsync(); if (job == null) { return; } _context.Jobs.Remove(job); await _context.SaveChangesAsync(); }
public override void Clear() { if (this.Icon_ != null) { this.Icon_.Clear(); } this.ID_ = null; this.Flags_ = null; this.StackSize_ = null; this.Type_ = null; this.ResourceID_ = null; this.ValidTargets_ = null; this.Name_ = null; this.Description_ = null; this.LogNameSingular_ = null; this.LogNamePlural_ = null; this.Element_ = null; this.StorageSlots_ = null; this.ActivationTime_ = null; this.Level_ = null; this.Slots_ = null; this.Races_ = null; this.Jobs_ = null; this.SuperiorLevel_ = null; this.ShieldSize_ = null; this.Damage_ = null; this.Delay_ = null; this.DPS_ = null; this.Skill_ = null; this.JugSize_ = null; this.iLevel_ = null; this.MaxCharges_ = null; this.CastingTime_ = null; this.UseDelay_ = null; this.ReuseDelay_ = null; this.PuppetSlot_ = null; this.ElementCharge_ = null; this.InstinctCost_ = null; this.Icon_ = null; this.Unknown1_ = null; this.Unknown2_ = null; this.Unknown3_ = null; this.Unknown4_ = null; this.Unknown5_ = null; }
public override JobData?GetJobData(string?jobId) { if (jobId == null) { throw new ArgumentNullException(nameof(jobId)); } if (Guid.TryParse(jobId, out Guid _) == false) { return(null); } try { Documents.Job data = Storage.Container.ReadItemWithRetries <Documents.Job>(jobId, PartitionKeys.Job); InvocationData invocationData = data.InvocationData; invocationData.Arguments = data.Arguments; Job?job = null; JobLoadException?loadException = null; try { job = invocationData.DeserializeJob(); } catch (JobLoadException ex) { loadException = ex; } return(new JobData { Job = job, State = data.StateName, CreatedAt = data.CreatedOn, LoadException = loadException }); } catch (CosmosException ex) when(ex.StatusCode == HttpStatusCode.NotFound) { /* ignored */ } catch (AggregateException ex) when(ex.InnerException is CosmosException { StatusCode: HttpStatusCode.NotFound })
private async Task Manager() { while (!_cancel?.IsCancellationRequested ?? false) { ReflectPoolSize(); Job?job = await GetJobOrDefault().ConfigureAwait(false); if (job == null) { break; } await ScheduleAndWaitFreeWorker(job).ConfigureAwait(false); } foreach (ITranslator translator in _translators) { translator.Dispose(); } }
//TODO: Figure out if everything in the player spawning region belongs somewhere else. #region Player spawning helpers /// <summary> /// Spawns in a player's mob according to their job and character information at the given coordinates. /// Used by systems that need to handle spawning players. /// </summary> /// <param name="coordinates">Coordinates to spawn the character at.</param> /// <param name="job">Job to assign to the character, if any.</param> /// <param name="profile">Appearance profile to use for the character.</param> /// <param name="station">The station this player is being spawned on.</param> /// <returns>The spawned entity</returns> public EntityUid SpawnPlayerMob( EntityCoordinates coordinates, Job?job, HumanoidCharacterProfile?profile, EntityUid?station) { // If we're not spawning a humanoid, we're gonna exit early without doing all the humanoid stuff. if (job?.JobEntity != null) { var jobEntity = EntityManager.SpawnEntity(job.JobEntity, coordinates); MakeSentientCommand.MakeSentient(jobEntity, EntityManager); DoJobSpecials(job, jobEntity); _identity.QueueIdentityUpdate(jobEntity); return(jobEntity); } var entity = EntityManager.SpawnEntity( _prototypeManager.Index <SpeciesPrototype>(profile?.Species ?? SpeciesManager.DefaultSpecies).Prototype, coordinates); if (job?.StartingGear != null) { var startingGear = _prototypeManager.Index <StartingGearPrototype>(job.StartingGear); EquipStartingGear(entity, startingGear, profile); if (profile != null) { EquipIdCard(entity, profile.Name, job.Prototype, station); } } if (profile != null) { _humanoidAppearanceSystem.UpdateFromProfile(entity, profile); EntityManager.GetComponent <MetaDataComponent>(entity).EntityName = profile.Name; if (profile.FlavorText != "" && _configurationManager.GetCVar(CCVars.FlavorText)) { EntityManager.AddComponent <DetailExaminableComponent>(entity).Content = profile.FlavorText; } } DoJobSpecials(job, entity); _identity.QueueIdentityUpdate(entity); return(entity); }
private async Async.Task <Task> OnStart(Task task) { if (task.EndTime == null) { task = task with { EndTime = DateTimeOffset.UtcNow + TimeSpan.FromHours(task.Config.Task.Duration) }; var jobOperations = _context.JobOperations; Job?job = await jobOperations.Get(task.JobId); if (job != null) { await jobOperations.OnStart(job); } } return(task); }
public Test( int int_var, float float_var, string str_var, bool bool_var, Job enum_var, Dog cls_var, int?nullable_int, Job?nullable_enum, Dog nullable_cls, dynamic dynamic, List <float> lst_var, List <Dog> lst_nullable_dog, List <dynamic> lst_dynamic, List <int> tup_var, List <dynamic> tup_dynamic, Dictionary <int, string> dct_int_str, Dictionary <string, dynamic> dct_str_dynamic, Dictionary <Job, float> dct_enum_float, List <Dictionary <string, Job?> > nested ) { this.int_var = int_var; this.float_var = float_var; this.str_var = str_var; this.bool_var = bool_var; this.enum_var = enum_var; this.cls_var = cls_var; this.nullable_int = nullable_int; this.nullable_enum = nullable_enum; this.nullable_cls = nullable_cls; this.dynamic = dynamic; this.lst_var = lst_var; this.lst_nullable_dog = lst_nullable_dog; this.lst_dynamic = lst_dynamic; this.tup_var = tup_var; this.tup_dynamic = tup_dynamic; this.dct_int_str = dct_int_str; this.dct_str_dynamic = dct_str_dynamic; this.dct_enum_float = dct_enum_float; this.nested = nested; }
public Task Adapter_TryClaimJob_ShouldSucceed() { return(SqliteInMemoryHelper.UsingSculleryContextAsync(async context => { var storeAdapter = new SqlJobStoreAdapter(context); var testStore = new EntityFrameworkJobStore(context, null, storeAdapter); var jobManager = new JobManager(testStore); var jobRunner = new JobRunner(null !); await jobManager.EnqueueAsync(() => TestJobs.Job1(1)); await jobManager.EnqueueAsync(() => TestJobs.Job1(2)); Job?job1 = await storeAdapter.GetCandidateJobAsync(); Job?job2 = await storeAdapter.GetCandidateJobAsync(); bool result1 = await storeAdapter.TryClaimJobAsync(job1 !); Assert.True(result1); // Claim succeeded bool result2 = await storeAdapter.TryClaimJobAsync(job2 !); Assert.False(result2); // Claim failed })); }
public CarGroup( int startIndex, int endIndex, List <TrainCar> cars, float maxStress, Job?job, Track?nextDestination, float minBrakePipePressure, float minBrakeReservoirPressure, float maxBrakeCylinderPressure, float maxBrakeFactor) { this.startIndex = startIndex; this.endIndex = endIndex; this.cars = cars; this.maxStress = maxStress; this.job = job; this.nextDestination = nextDestination; this.minBrakePipePressure = minBrakePipePressure; this.minBrakeReservoirPressure = minBrakeReservoirPressure; this.maxBrakeCylinderPressure = maxBrakeCylinderPressure; this.maxBrakeFactor = maxBrakeFactor; }
//TODO: Figure out if everything in the player spawning region belongs somewhere else. #region Player spawning helpers /// <summary> /// Spawns in a player's mob according to their job and character information at the given coordinates. /// Used by systems that need to handle spawning players. /// </summary> /// <param name="coordinates">Coordinates to spawn the character at.</param> /// <param name="job">Job to assign to the character, if any.</param> /// <param name="profile">Appearance profile to use for the character.</param> /// <param name="station">The station this player is being spawned on.</param> /// <returns>The spawned entity</returns> public EntityUid SpawnPlayerMob( EntityCoordinates coordinates, Job?job, HumanoidCharacterProfile?profile, EntityUid?station) { var entity = EntityManager.SpawnEntity( _prototypeManager.Index <SpeciesPrototype>(profile?.Species ?? SpeciesManager.DefaultSpecies).Prototype, coordinates); if (job?.StartingGear != null) { var startingGear = _prototypeManager.Index <StartingGearPrototype>(job.StartingGear); EquipStartingGear(entity, startingGear, profile); if (profile != null) { EquipIdCard(entity, profile.Name, job.Prototype, station); } } if (profile != null) { _humanoidAppearanceSystem.UpdateFromProfile(entity, profile); EntityManager.GetComponent <MetaDataComponent>(entity).EntityName = profile.Name; if (profile.FlavorText != "" && _configurationManager.GetCVar(CCVars.FlavorText)) { EntityManager.AddComponent <DetailExaminableComponent>(entity).Content = profile.FlavorText; } } foreach (var jobSpecial in job?.Prototype.Special ?? Array.Empty <JobSpecial>()) { jobSpecial.AfterEquip(entity); } return(entity); }
// This will be called from the Simulation thread public void SimulationUpdate() { if (_route == default(Route)) { _route = Interlocked.Exchange(ref _pendingRoute, default); if (_route != default(Route)) { _currentRouteIndex = 0; } } if (_job == default) { _job = Interlocked.Exchange(ref _pendingJob, default); if (_job != default) { _currentActivity = 0; _currentStep = 0; SetRouteRequired(); } } }
private void Run() { _isRunning = true; #if DEBUG Started?.Invoke(this, EventArgs.Empty); #endif while (!_terminated) { Job?job = GetNextJob(); while (job != default) { IMap map = _mapProvider.Current(); // All the people available to handle the job IJobFit[] fits = _jobFitProvider.GetAvailable(); // Of those, the people who could possibly handle the job // (ie - has the right skill) fits = FilterSuitable(job, fits); if (fits.Length == 0) { // No one available to handle the job // Re-queue it and leave AddJob(job); break; } // Now we calculate the distance to the job for everyone // left, eventually blocking until the pathing is complete. StartPathing(map, job, fits); // Non-path fitness is "suitability" for the job. ie - Those // with higher skills are more fit than those with lower skills. CalculateNonPathFit(job, fits); while (!PathingComplete() && !_terminated) { _gate.WaitOne(); } IJobFit handler = fits[FindJobFit(fits)]; if (handler == default(IJobFit)) { // We couldn't find a handler for this job so we should // put it in the blocked jobs to be re-queued periodically // TODO: create a blocked job queue } else { Job?oldJob = handler.AssignJob(job); if (oldJob != default) { // We assigned them a new job before they started the // old one, so requeue this one AddJob(oldJob); } } if (!_terminated) { ClearFoundRoutes(); job = GetNextJob(); } else { job = default; } } if (!_terminated) { _gate.WaitOne(1000); // Automatically unlock after 1s just in case } } _isRunning = false; #if DEBUG Stopped?.Invoke(this, EventArgs.Empty); #endif }
/// <summary> 実行可能確認<オーバーレイジョブフィルタ設定コマンド> </summary> /// <param name="para"> コマンドパラメーター </param> /// <returns> 実行可能: ture / 実行不可能: false </returns> private bool _CanOverlayJobFilterExecute(Job?para) { return(true); }
public bool Read(BinaryReader BR, Type T) { this.Clear(); try { byte[] ItemBytes = BR.ReadBytes(0xC00); FFXIEncryption.Rotate(ItemBytes, 5); BR = new BinaryReader(new MemoryStream(ItemBytes, false)); BR.BaseStream.Seek(0x280, SeekOrigin.Begin); Graphic G = new Graphic(); int GraphicSize = BR.ReadInt32(); if (GraphicSize < 0 || !G.Read(BR) || BR.BaseStream.Position != 0x280 + 4 + GraphicSize) { BR.Close(); return(false); } this.Icon_ = G; BR.BaseStream.Seek(0, SeekOrigin.Begin); } catch { return(false); } // Common Fields (14 bytes) this.ID_ = BR.ReadUInt32(); this.Flags_ = (ItemFlags)BR.ReadUInt16(); this.StackSize_ = BR.ReadUInt16(); // 0xe0ff for Currency, which kinda suggests this is really 2 separate bytes this.Type_ = (ItemType)BR.ReadUInt16(); this.ResourceID_ = BR.ReadUInt16(); this.ValidTargets_ = (ValidTarget)BR.ReadUInt16(); // Extra Fields (22/30/10/6/2 bytes for Armor/Weapon/Puppet/Item/UsableItem) if (T == Type.Armor || T == Type.Weapon) { this.Level_ = BR.ReadUInt16(); this.Slots_ = (EquipmentSlot)BR.ReadUInt16(); this.Races_ = (Race)BR.ReadUInt16(); this.Jobs_ = (Job)BR.ReadUInt32(); this.SuperiorLevel_ = BR.ReadUInt16(); if (T == Type.Armor) { this.ShieldSize_ = BR.ReadUInt16(); } else { // Weapon this.Unknown4_ = BR.ReadUInt16(); this.Damage_ = BR.ReadUInt16(); this.Delay_ = BR.ReadInt16(); this.DPS_ = BR.ReadUInt16(); this.Skill_ = (Skill)BR.ReadByte(); this.JugSize_ = BR.ReadByte(); this.Unknown1_ = BR.ReadUInt32(); } this.MaxCharges_ = BR.ReadByte(); this.CastingTime_ = BR.ReadByte(); this.UseDelay_ = BR.ReadUInt16(); this.ReuseDelay_ = BR.ReadUInt32(); this.Unknown2_ = BR.ReadUInt16(); this.iLevel_ = BR.ReadUInt16(); this.Unknown3_ = BR.ReadUInt32(); } else if (T == Type.PuppetItem) { this.PuppetSlot_ = (PuppetSlot)BR.ReadUInt16(); this.ElementCharge_ = BR.ReadUInt32(); this.Unknown3_ = BR.ReadUInt32(); } else if (T == Type.Instinct) { BR.ReadUInt32(); BR.ReadUInt32(); BR.ReadUInt16(); this.InstinctCost_ = BR.ReadUInt16(); BR.ReadUInt16(); BR.ReadUInt32(); BR.ReadUInt32(); BR.ReadUInt32(); } else if (T == Type.Item) { switch (this.Type_.Value) { case ItemType.Flowerpot: case ItemType.Furnishing: case ItemType.Mannequin: this.Element_ = (Element)BR.ReadUInt16(); this.StorageSlots_ = BR.ReadInt32(); this.Unknown3_ = BR.ReadUInt32(); break; default: this.Unknown2_ = BR.ReadUInt16(); this.Unknown3_ = BR.ReadUInt32(); this.Unknown3_ = BR.ReadUInt32(); break; } } else if (T == Type.UsableItem) { this.ActivationTime_ = BR.ReadUInt16(); this.Unknown1_ = BR.ReadUInt32(); this.Unknown3_ = BR.ReadUInt32(); this.Unknown4_ = BR.ReadUInt32(); } else if (T == Type.Currency) { this.Unknown2_ = BR.ReadUInt16(); } else if (T == Type.Slip) { this.Unknown1_ = BR.ReadUInt16(); for (int counter = 0; counter < 17; counter++) { BR.ReadUInt32(); } } else if (T == Type.Monipulator) { this.Unknown1_ = BR.ReadUInt16(); for (int counter = 0; counter < 24; counter++) { BR.ReadInt32(); } } // Next Up: Strings (variable size) long StringBase = BR.BaseStream.Position; uint StringCount = BR.ReadUInt32(); if (StringCount > 9) { // Sanity check, for safety - 0 strings is fine for now this.Clear(); return(false); } FFXIEncoding E = new FFXIEncoding(); string[] Strings = new string[StringCount]; for (byte i = 0; i < StringCount; ++i) { long Offset = StringBase + BR.ReadUInt32(); uint Flag = BR.ReadUInt32(); if (Offset < 0 || Offset + 0x20 > 0x280 || (Flag != 0 && Flag != 1)) { this.Clear(); return(false); } // Flag seems to be 1 if the offset is not actually an offset. Could just be padding to make StringCount unique per language, or it could be an indication // of the pronoun to use (a/an/the/...). The latter makes sense because of the increased number of such flags for french and german. if (Flag == 0) { BR.BaseStream.Position = Offset; Strings[i] = this.ReadString(BR, E); if (Strings[i] == null) { this.Clear(); return(false); } BR.BaseStream.Position = StringBase + 4 + 8 * (i + 1); } } // Assign the strings to the proper fields switch (StringCount) { case 1: this.Name_ = Strings[0]; break; case 2: // Japanese this.Name_ = Strings[0]; this.Description_ = Strings[1]; break; case 5: // English this.Name_ = Strings[0]; // unused: Strings[1] this.LogNameSingular_ = Strings[2]; this.LogNamePlural_ = Strings[3]; this.Description_ = Strings[4]; break; case 6: // French this.Name_ = Strings[0]; // unused: Strings[1] // unused: Strings[2] this.LogNameSingular_ = Strings[3]; this.LogNamePlural_ = Strings[4]; this.Description_ = Strings[5]; break; case 9: // German this.Name_ = Strings[0]; // unused: Strings[1] // unused: Strings[2] // unused: Strings[3] this.LogNameSingular_ = Strings[4]; // unused: Strings[5] // unused: Strings[6] this.LogNamePlural_ = Strings[7]; this.Description_ = Strings[8]; break; } BR.Close(); return(true); }
protected override void LoadField(string Field, System.Xml.XmlElement Node) { switch (Field) { // "Simple" Fields case "activation-time": this.ActivationTime_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "casting-time": this.CastingTime_ = (byte)this.LoadUnsignedIntegerField(Node); break; case "damage": this.Damage_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "delay": this.Delay_ = (short)this.LoadSignedIntegerField(Node); break; case "description": this.Description_ = this.LoadTextField(Node); break; case "dps": this.DPS_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "element": this.Element_ = (Element)this.LoadHexField(Node); break; case "element-charge": this.ElementCharge_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "flags": this.Flags_ = (ItemFlags)this.LoadHexField(Node); break; case "id": this.ID_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "iLevel:": this.iLevel_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "instinct-cost:": this.iLevel_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "jobs": this.Jobs_ = (Job)this.LoadHexField(Node); break; case "jug-size": this.JugSize_ = (byte)this.LoadUnsignedIntegerField(Node); break; case "level": this.Level_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "log-name-plural": this.LogNamePlural_ = this.LoadTextField(Node); break; case "log-name-singular": this.LogNameSingular_ = this.LoadTextField(Node); break; case "max-charges": this.MaxCharges_ = (byte)this.LoadUnsignedIntegerField(Node); break; case "name": this.Name_ = this.LoadTextField(Node); break; case "puppet-slot": this.PuppetSlot_ = (PuppetSlot)this.LoadHexField(Node); break; case "races": this.Races_ = (Race)this.LoadHexField(Node); break; case "resource-id": this.ResourceID_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "reuse-delay": this.ReuseDelay_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "superior-level": this.SuperiorLevel_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "shield-size": this.ShieldSize_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "skill": this.Skill_ = (Skill)this.LoadHexField(Node); break; case "slots": this.Slots_ = (EquipmentSlot)this.LoadHexField(Node); break; case "stack-size": this.StackSize_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "storage-slots": this.StorageSlots_ = (int)this.LoadSignedIntegerField(Node); break; case "type": this.Type_ = (ItemType)this.LoadHexField(Node); break; case "unknown-1": this.Unknown1_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "unknown-2": this.Unknown2_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "unknown-3": this.Unknown3_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "unknown-4": this.Unknown4_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "use-delay": this.UseDelay_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "valid-targets": this.ValidTargets_ = (ValidTarget)this.LoadHexField(Node); break; // Sub-Things case "icon": if (this.Icon_ == null) { this.Icon_ = new Graphic(); } this.LoadThingField(Node, this.Icon_); break; } }
protected override void LoadField(string Field, System.Xml.XmlElement Node) { switch (Field) { // "Simple" Fields case "activation-time": this.ActivationTime_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "casting-time": this.CastingTime_ = (byte)this.LoadUnsignedIntegerField(Node); break; case "damage": this.Damage_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "delay": this.Delay_ = (short)this.LoadSignedIntegerField(Node); break; case "description": this.Description_ = this.LoadTextField(Node); break; case "dps": this.DPS_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "element": this.Element_ = (Element)this.LoadHexField(Node); break; case "element-charge": this.ElementCharge_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "flags": this.Flags_ = (ItemFlags)this.LoadHexField(Node); break; case "id": this.ID_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "iLevel:": this.iLevel_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "instinct-cost:": this.iLevel_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "jobs": this.Jobs_ = (Job)this.LoadHexField(Node); break; case "jug-size": this.JugSize_ = (byte)this.LoadUnsignedIntegerField(Node); break; case "level": this.Level_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "log-name-plural": this.LogNamePlural_ = this.LoadTextField(Node); break; case "log-name-singular": this.LogNameSingular_ = this.LoadTextField(Node); break; case "max-charges": this.MaxCharges_ = (byte)this.LoadUnsignedIntegerField(Node); break; case "name": this.Name_ = this.LoadTextField(Node); break; case "puppet-slot": this.PuppetSlot_ = (PuppetSlot)this.LoadHexField(Node); break; case "races": this.Races_ = (Race)this.LoadHexField(Node); break; case "resource-id": this.ResourceID_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "reuse-delay": this.ReuseDelay_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "superior-level": this.SuperiorLevel_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "shield-size": this.ShieldSize_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "skill": this.Skill_ = (Skill)this.LoadHexField(Node); break; case "slots": this.Slots_ = (EquipmentSlot)this.LoadHexField(Node); break; case "stack-size": this.StackSize_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "storage-slots": this.StorageSlots_ = (int)this.LoadSignedIntegerField(Node); break; case "type": this.Type_ = (ItemType)this.LoadHexField(Node); break; case "unknown-1": this.Unknown1_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "unknown-2": this.Unknown2_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "unknown-3": this.Unknown3_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "unknown-4": this.Unknown4_ = (uint)this.LoadUnsignedIntegerField(Node); break; case "use-delay": this.UseDelay_ = (ushort)this.LoadUnsignedIntegerField(Node); break; case "valid-targets": this.ValidTargets_ = (ValidTarget)this.LoadHexField(Node); break; // Sub-Things case "icon": if (this.Icon_ == null) { this.Icon_ = new Graphic(); } this.LoadThingField(Node, this.Icon_); break; } }
public bool Read(BinaryReader BR, Type T) { this.Clear(); try { byte[] ItemBytes = BR.ReadBytes(0xC00); FFXIEncryption.Rotate(ItemBytes, 5); BR = new BinaryReader(new MemoryStream(ItemBytes, false)); BR.BaseStream.Seek(0x280, SeekOrigin.Begin); Graphic G = new Graphic(); int GraphicSize = BR.ReadInt32(); if (GraphicSize < 0 || !G.Read(BR) || BR.BaseStream.Position != 0x280 + 4 + GraphicSize) { BR.Close(); return false; } this.Icon_ = G; BR.BaseStream.Seek(0, SeekOrigin.Begin); } catch { return false; } // Common Fields (14 bytes) this.ID_ = BR.ReadUInt32(); this.Flags_ = (ItemFlags)BR.ReadUInt16(); this.StackSize_ = BR.ReadUInt16(); // 0xe0ff for Currency, which kinda suggests this is really 2 separate bytes this.Type_ = (ItemType)BR.ReadUInt16(); this.ResourceID_ = BR.ReadUInt16(); this.ValidTargets_ = (ValidTarget)BR.ReadUInt16(); // Extra Fields (22/30/10/6/2 bytes for Armor/Weapon/Puppet/Item/UsableItem) if (T == Type.Armor || T == Type.Weapon) { this.Level_ = BR.ReadUInt16(); this.Slots_ = (EquipmentSlot)BR.ReadUInt16(); this.Races_ = (Race)BR.ReadUInt16(); this.Jobs_ = (Job)BR.ReadUInt32(); this.SuperiorLevel_ = BR.ReadUInt16(); if (T == Type.Armor) { this.ShieldSize_ = BR.ReadUInt16(); } else { // Weapon this.Unknown4_ = BR.ReadUInt16(); this.Damage_ = BR.ReadUInt16(); this.Delay_ = BR.ReadInt16(); this.DPS_ = BR.ReadUInt16(); this.Skill_ = (Skill)BR.ReadByte(); this.JugSize_ = BR.ReadByte(); this.Unknown1_ = BR.ReadUInt32(); } this.MaxCharges_ = BR.ReadByte(); this.CastingTime_ = BR.ReadByte(); this.UseDelay_ = BR.ReadUInt16(); this.ReuseDelay_ = BR.ReadUInt32(); this.Unknown2_ = BR.ReadUInt16(); this.iLevel_ = BR.ReadUInt16(); this.Unknown3_ = BR.ReadUInt32(); } else if (T == Type.PuppetItem) { this.PuppetSlot_ = (PuppetSlot)BR.ReadUInt16(); this.ElementCharge_ = BR.ReadUInt32(); this.Unknown3_ = BR.ReadUInt32(); } else if (T == Type.Instinct) { BR.ReadUInt32(); BR.ReadUInt32(); BR.ReadUInt16(); this.InstinctCost_ = BR.ReadUInt16(); BR.ReadUInt16(); BR.ReadUInt32(); BR.ReadUInt32(); BR.ReadUInt32(); } else if (T == Type.Item) { switch (this.Type_.Value) { case ItemType.Flowerpot: case ItemType.Furnishing: case ItemType.Mannequin: this.Element_ = (Element)BR.ReadUInt16(); this.StorageSlots_ = BR.ReadInt32(); this.Unknown3_ = BR.ReadUInt32(); break; default: this.Unknown2_ = BR.ReadUInt16(); this.Unknown3_ = BR.ReadUInt32(); this.Unknown3_ = BR.ReadUInt32(); break; } } else if (T == Type.UsableItem) { this.ActivationTime_ = BR.ReadUInt16(); this.Unknown1_ = BR.ReadUInt32(); this.Unknown3_ = BR.ReadUInt32(); this.Unknown4_ = BR.ReadUInt32(); } else if (T == Type.Currency) { this.Unknown2_ = BR.ReadUInt16(); } else if (T == Type.Slip) { this.Unknown1_ = BR.ReadUInt16(); for (int counter = 0; counter < 17; counter++) { BR.ReadUInt32(); } } else if (T == Type.Monipulator) { this.Unknown1_ = BR.ReadUInt16(); for (int counter = 0; counter < 24; counter++) { BR.ReadInt32(); } } // Next Up: Strings (variable size) long StringBase = BR.BaseStream.Position; uint StringCount = BR.ReadUInt32(); if (StringCount > 9) { // Sanity check, for safety - 0 strings is fine for now this.Clear(); return false; } FFXIEncoding E = new FFXIEncoding(); string[] Strings = new string[StringCount]; for (byte i = 0; i < StringCount; ++i) { long Offset = StringBase + BR.ReadUInt32(); uint Flag = BR.ReadUInt32(); if (Offset < 0 || Offset + 0x20 > 0x280 || (Flag != 0 && Flag != 1)) { this.Clear(); return false; } // Flag seems to be 1 if the offset is not actually an offset. Could just be padding to make StringCount unique per language, or it could be an indication // of the pronoun to use (a/an/the/...). The latter makes sense because of the increased number of such flags for french and german. if (Flag == 0) { BR.BaseStream.Position = Offset; Strings[i] = this.ReadString(BR, E); if (Strings[i] == null) { this.Clear(); return false; } BR.BaseStream.Position = StringBase + 4 + 8 * (i + 1); } } // Assign the strings to the proper fields switch (StringCount) { case 1: this.Name_ = Strings[0]; break; case 2: // Japanese this.Name_ = Strings[0]; this.Description_ = Strings[1]; break; case 5: // English this.Name_ = Strings[0]; // unused: Strings[1] this.LogNameSingular_ = Strings[2]; this.LogNamePlural_ = Strings[3]; this.Description_ = Strings[4]; break; case 6: // French this.Name_ = Strings[0]; // unused: Strings[1] // unused: Strings[2] this.LogNameSingular_ = Strings[3]; this.LogNamePlural_ = Strings[4]; this.Description_ = Strings[5]; break; case 9: // German this.Name_ = Strings[0]; // unused: Strings[1] // unused: Strings[2] // unused: Strings[3] this.LogNameSingular_ = Strings[4]; // unused: Strings[5] // unused: Strings[6] this.LogNamePlural_ = Strings[7]; this.Description_ = Strings[8]; break; } BR.Close(); return true; }
public ErrorArgs(Exception e, Job?job = default) : this(e, e.Message, job) { }
public PlayerSpawningEvent(Job?job, HumanoidCharacterProfile?humanoidCharacterProfile, EntityUid?station) { Job = job; HumanoidCharacterProfile = humanoidCharacterProfile; Station = station; }
public ErrorArgs(Exception?e, string message, Job?job = default) { Exception = e; Message = message; Job = job; }
private IEnumerable <CarGroup> GetCarGroups(IEnumerable <TrainCar> cars, bool individual) { Job? prevJob = null; Track?prevDestTrack = null; int startIndex = 0; float maxStress = 0f; var firstCar = cars.First(); var groupCars = new List <TrainCar>() { firstCar }; float minBrakePipePressure = firstCar.brakeSystem.brakePipePressure; float minBrakeReservoirPressure = GetAuxReservoirPressure(firstCar); float maxBrakeCylinderPressure = GetBrakeCylinderPressure(firstCar); float maxBrakeFactor = firstCar.brakeSystem.brakingFactor; int i = 0; foreach (var car in cars) { float carStress = car.GetComponent <TrainStress>().derailBuildUp; Job? job = JobChainController.GetJobOfCar(car); Track? nextDestination = GetNextDestinationTrack(job, car.logicCar); BrakeSystem brakeSystem = car.brakeSystem; float pipePressure = brakeSystem.brakePipePressure; float auxReservoirPressure = GetAuxReservoirPressure(car); float brakeCylinderPressure = GetBrakeCylinderPressure(car); if (individual || nextDestination == null || nextDestination != prevDestTrack || job != prevJob) { // complete previous group if (i > 0) { yield return(new CarGroup( startIndex, i, groupCars, maxStress, prevJob, prevDestTrack, minBrakePipePressure, minBrakeReservoirPressure, maxBrakeCylinderPressure, maxBrakeFactor)); } // start new group startIndex = i; groupCars = new List <TrainCar>() { car }; prevJob = job; prevDestTrack = nextDestination; maxStress = carStress; minBrakePipePressure = pipePressure; minBrakeReservoirPressure = auxReservoirPressure; maxBrakeCylinderPressure = brakeCylinderPressure; maxBrakeFactor = brakeSystem.brakingFactor; } else { groupCars.Add(car); if (carStress > maxStress) { maxStress = carStress; } if (pipePressure < minBrakePipePressure) { minBrakeReservoirPressure = auxReservoirPressure; } if (auxReservoirPressure < minBrakeReservoirPressure) { minBrakeReservoirPressure = auxReservoirPressure; } if (brakeCylinderPressure > maxBrakeCylinderPressure) { maxBrakeCylinderPressure = brakeCylinderPressure; } if (brakeSystem.brakingFactor > maxBrakeFactor) { maxBrakeFactor = brakeSystem.brakingFactor; } } i++; } // complete last group yield return(new CarGroup( startIndex, i, groupCars, maxStress, prevJob, prevDestTrack, minBrakePipePressure, minBrakeReservoirPressure, maxBrakeCylinderPressure, maxBrakeFactor)); }
public ErrorArgs(string message, Job?job = default) : this(null, message, job) { }
public override void Clear() { if (this.Icon_ != null) { this.Icon_.Clear(); } this.ID_ = null; this.Flags_ = null; this.StackSize_ = null; this.Type_ = null; this.ResourceID_ = null; this.ValidTargets_ = null; this.Name_ = null; this.Description_ = null; this.LogNameSingular_ = null; this.LogNamePlural_ = null; this.Element_ = null; this.StorageSlots_ = null; this.ActivationTime_ = null; this.Level_ = null; this.Slots_ = null; this.Races_ = null; this.Jobs_ = null; this.SuperiorLevel_ = null; this.ShieldSize_ = null; this.Damage_ = null; this.Delay_ = null; this.DPS_ = null; this.Skill_ = null; this.JugSize_ = null; this.iLevel_ = null; this.MaxCharges_ = null; this.CastingTime_ = null; this.UseDelay_ = null; this.ReuseDelay_ = null; this.PuppetSlot_ = null; this.ElementCharge_ = null; this.InstinctCost_ = null; this.Icon_ = null; this.Unknown1_ = null; this.Unknown2_ = null; this.Unknown3_ = null; this.Unknown4_ = null; }