/// <inheritdoc /> public override string GetText(Appearance appearance, AppearanceComponent?component) { var character = appearance.Character; var pronounProvider = _pronouns.GetPronounProvider(character); return(pronounProvider.GetForm(this.Form)); }
private void UpdateMagazineAppearance(AppearanceComponent?appearance, bool magLoaded, int count, int capacity) { // Copy the magazine's appearance data appearance?.SetData(AmmoVisuals.MagLoaded, magLoaded); appearance?.SetData(AmmoVisuals.HasAmmo, count != 0); appearance?.SetData(AmmoVisuals.AmmoCount, count); appearance?.SetData(AmmoVisuals.AmmoMax, capacity); }
private void UpdateAppearance(EntityUid uid, GasMixerComponent?mixer = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref mixer, ref appearance, false)) { return; } appearance.SetData(FilterVisuals.Enabled, mixer.Enabled); }
private void UpdateAppearance(EntityUid uid, AppearanceComponent?appearance = null, KitchenSpikeComponent?component = null) { if (!Resolve(uid, ref component, ref appearance, false)) { return; } appearance.SetData(KitchenSpikeVisuals.Status, (component.MeatParts > 0) ? KitchenSpikeStatus.Bloody : KitchenSpikeStatus.Empty); }
/// <inheritdoc /> public override string GetText(Appearance appearance, AppearanceComponent?component) { if (component is null) { throw new ArgumentNullException(nameof(component)); } return(component.Pattern.ToString().Humanize().Transform(To.LowerCase)); }
private void SetTypingIndicatorEnabled(EntityUid uid, bool isEnabled, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref appearance, false)) { return; } appearance.SetData(TypingIndicatorVisuals.IsTyping, isEnabled); }
private void UpdateLight(EntityUid uid, PoweredLightComponent?light = null, ApcPowerReceiverComponent?powerReceiver = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref light, ref powerReceiver, ref appearance)) { return; } // check if light has bulb var bulbUid = GetBulb(uid, light); if (bulbUid == null || !EntityManager.TryGetComponent(bulbUid.Value, out LightBulbComponent? lightBulb)) { SetLight(uid, false, light: light); powerReceiver.Load = 0; appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Empty); return; } else { powerReceiver.Load = (light.On && lightBulb.State == LightBulbState.Normal) ? lightBulb.PowerUse : 0; switch (lightBulb.State) { case LightBulbState.Normal: if (powerReceiver.Powered && light.On) { SetLight(uid, true, lightBulb.Color, light); appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.On); var time = _gameTiming.CurTime; if (time > light.LastThunk + ThunkDelay) { light.LastThunk = time; SoundSystem.Play(Filter.Pvs(uid), light.TurnOnSound.GetSound(), uid, AudioParams.Default.WithVolume(-10f)); } } else { SetLight(uid, false, light: light); appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Off); } break; case LightBulbState.Broken: SetLight(uid, false, light: light); appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Broken); break; case LightBulbState.Burned: SetLight(uid, false, light: light); appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Burned); break; } } }
public void UpdateAppearance(GasOutletInjectorComponent component, AppearanceComponent?appearance = null) { if (!Resolve(component.Owner, ref appearance, false)) { return; } appearance.SetData(OutletInjectorVisuals.Enabled, component.Enabled); }
private void UpdateVisuals(EntityUid uid, MousetrapComponent?mousetrap = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref mousetrap, ref appearance, false)) { return; } appearance.SetData(MousetrapVisuals.Visual, mousetrap.IsActive ? MousetrapVisuals.Armed : MousetrapVisuals.Unarmed); }
private void UpdateDirAppearance(EntityUid uid, Direction dir, PinpointerComponent?pinpointer = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref pinpointer, ref appearance)) { return; } appearance.SetData(PinpointerVisuals.TargetDirection, dir); }
/// <inheritdoc /> public override string GetText(Appearance appearance, AppearanceComponent?component) { if (component is null) { throw new ArgumentNullException(nameof(component)); } return(this.Pluralize ? component.Bodypart.Humanize().Pluralize().Transform(To.LowerCase) : component.Bodypart.Humanize().Transform(To.LowerCase)); }
private void UpdateAppearance(EntityUid uid, PinpointerComponent?pinpointer = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref pinpointer, ref appearance)) { return; } appearance.SetData(PinpointerVisuals.IsActive, pinpointer.IsActive); appearance.SetData(PinpointerVisuals.TargetDistance, pinpointer.DistanceToTarget); }
private void UpdateAmmoBoxAppearance(EntityUid uid, AmmoBoxComponent ammoBox, AppearanceComponent?appearanceComponent = null) { if (!Resolve(uid, ref appearanceComponent, false)) { return; } appearanceComponent.SetData(MagazineBarrelVisuals.MagLoaded, true); appearanceComponent.SetData(AmmoVisuals.AmmoCount, ammoBox.AmmoLeft); appearanceComponent.SetData(AmmoVisuals.AmmoMax, ammoBox.Capacity); }
/// <inheritdoc /> public override string GetText(Appearance appearance, AppearanceComponent?component) { if (component is null) { return(string.Empty); } return(component.Chirality == Chirality.Center ? string.Empty : component.Chirality.Humanize().Transform(To.LowerCase)); }
private void UpdateAppearance(EntityUid uid, LightBulbComponent?bulb = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref bulb, ref appearance, logMissing: false)) { return; } // try to update appearance and color appearance.SetData(LightBulbVisuals.State, bulb.State); appearance.SetData(LightBulbVisuals.Color, bulb.Color); }
private void UpdateAppearance(EntityUid uid, ItemCabinetComponent?cabinet = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref cabinet, ref appearance, false)) { return; } appearance.SetData(ItemCabinetVisuals.IsOpen, cabinet.Opened); appearance.SetData(ItemCabinetVisuals.ContainsItem, cabinet.CabinetSlot.HasItem); }
public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true, StandingStateComponent?standingState = null, AppearanceComponent?appearance = null, SharedHandsComponent?hands = null) { // TODO: This should actually log missing comps... if (!Resolve(uid, ref standingState, false)) { return(false); } // Optional component. Resolve(uid, ref appearance, ref hands, false); if (!standingState.Standing) { return(true); } // This is just to avoid most callers doing this manually saving boilerplate // 99% of the time you'll want to drop items but in some scenarios (e.g. buckling) you don't want to. // We do this BEFORE downing because something like buckle may be blocking downing but we want to drop hand items anyway // and ultimately this is just to avoid boilerplate in Down callers + keep their behavior consistent. if (dropHeldItems && hands != null) { RaiseLocalEvent(uid, new DropHandItemsEvent(), false); } var msg = new DownAttemptEvent(); RaiseLocalEvent(uid, msg, false); if (msg.Cancelled) { return(false); } standingState.Standing = false; standingState.Dirty(); RaiseLocalEvent(uid, new DownedEvent(), false); // Seemed like the best place to put it appearance?.SetData(RotationVisuals.RotationState, RotationState.Horizontal); // Currently shit is only downed by server but when it's predicted we can probably only play this on server / client if (playSound) { SoundSystem.Play(Filter.Pvs(uid), standingState.DownSoundCollection.GetSound(), uid, AudioHelpers.WithVariation(0.25f)); } return(true); }
private void UpdateAppearance(EntityUid uid, Solution solution, AppearanceComponent?appearanceComponent = null) { if (!EntityManager.EntityExists(uid) || !Resolve(uid, ref appearanceComponent, false)) { return; } var filledVolumeFraction = solution.CurrentVolume.Float() / solution.MaxVolume.Float(); appearanceComponent.SetData(SolutionContainerVisuals.VisualState, new SolutionContainerVisualState(solution.Color, filledVolumeFraction)); }
public void UpdateAppearance( EntityUid uid, SubFloorHideComponent?hideComp = null, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref hideComp, ref appearance, false)) { return; } appearance.SetData(SubFloorVisuals.Covered, hideComp.IsUnderCover); appearance.SetData(SubFloorVisuals.ScannerRevealed, hideComp.RevealedBy.Count != 0); }
private void UpdateAppearance(EntityUid uid, FireExtinguisherComponent comp, AppearanceComponent?appearance = null) { if (!Resolve(uid, ref appearance, false)) { return; } if (comp.HasSafety) { appearance.SetData(FireExtinguisherVisuals.Safety, comp.Safety); } }
/// <inheritdoc /> public override string GetText(Appearance appearance, AppearanceComponent?component) { if (component is null) { throw new ArgumentNullException(nameof(component)); } if (this.UsePattern) { return(component.PatternColour?.ToString() ?? string.Empty); } return(component.BaseColour.ToString()); }
/// <inheritdoc /> public override async Task <string> GetTextAsync(Appearance appearance, AppearanceComponent?component) { var result = await _lua.ExecuteSnippetAsync ( this.Snippet, (nameof(appearance), appearance), ("character", appearance.Character), (nameof(component), component) ); return(result.IsSuccess ? result.Entity : $"[{result.Error.Message}]"); }
protected override void Initialize() { base.Initialize(); if (_ammoPrototype != null) { _ammoContainer = Owner.EnsureContainer <ContainerSlot>($"{Name}-ammo-container"); } if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearanceComponent)) { _appearanceComponent = appearanceComponent; } Dirty(); }
public bool Stand(EntityUid uid, StandingStateComponent?standingState = null, AppearanceComponent?appearance = null) { // TODO: This should actually log missing comps... if (!Resolve(uid, ref standingState, false)) { return(false); } // Optional component. Resolve(uid, ref appearance, false); if (standingState.Standing) { return(true); } var msg = new StandAttemptEvent(); RaiseLocalEvent(uid, msg, false); if (msg.Cancelled) { return(false); } standingState.Standing = true; Dirty(standingState); RaiseLocalEvent(uid, new StoodEvent(), false); appearance?.SetData(RotationVisuals.RotationState, RotationState.Vertical); if (TryComp(uid, out FixturesComponent? fixtureComponent)) { foreach (var key in standingState.ChangedFixtures) { if (fixtureComponent.Fixtures.TryGetValue(key, out var fixture)) { fixture.CollisionMask |= StandingCollisionLayer; } } } standingState.ChangedFixtures.Clear(); return(true); }
public bool TryGetAppearanceComponent ( Bodypart bodypart, Chirality chirality, [NotNullWhen(true)] out AppearanceComponent? component ) { component = null; if (!HasComponent(bodypart, chirality)) { return false; } component = GetAppearanceComponent(bodypart, chirality); return true; }
private void Scrub(GasVentScrubberComponent scrubber, AppearanceComponent?appearance, TileAtmosphere?tile, PipeNode outlet) { // Cannot scrub if tile is null or air-blocked. if (tile?.Air == null) { return; } // Cannot scrub if pressure too high. if (outlet.Air.Pressure >= 50 * Atmospherics.OneAtmosphere) { return; } if (scrubber.PumpDirection == ScrubberPumpDirection.Scrubbing) { appearance?.SetData(ScrubberVisuals.State, scrubber.WideNet ? ScrubberState.WideScrub : ScrubberState.Scrub); var transferMoles = MathF.Min(1f, (scrubber.VolumeRate / tile.Air.Volume) * tile.Air.TotalMoles); // Take a gas sample. var removed = tile.Air.Remove(transferMoles); // Nothing left to remove from the tile. if (MathHelper.CloseTo(removed.TotalMoles, 0f)) { return; } // TODO: Entity system dependency Get <AtmosphereSystem>().ScrubInto(removed, outlet.Air, scrubber.FilterGases); // Remix the gases. tile.AssumeAir(removed); } else if (scrubber.PumpDirection == ScrubberPumpDirection.Siphoning) { appearance?.SetData(ScrubberVisuals.State, ScrubberState.Siphon); var transferMoles = tile.Air.TotalMoles * (scrubber.VolumeRate / tile.Air.Volume); var removed = tile.Air.Remove(transferMoles); outlet.AssumeAir(removed); tile.Invalidate(); } }
public bool Stand(EntityUid uid, StandingStateComponent?standingState = null, AppearanceComponent?appearance = null) { // TODO: This should actually log missing comps... if (!Resolve(uid, ref standingState, false)) { return(false); } // Optional component. Resolve(uid, ref appearance, false); if (standingState.Standing) { return(true); } var msg = new StandAttemptEvent(); RaiseLocalEvent(uid, msg, false); if (msg.Cancelled) { return(false); } standingState.Standing = true; standingState.Dirty(); RaiseLocalEvent(uid, new StoodEvent(), false); appearance?.SetData(RotationVisuals.RotationState, RotationState.Vertical); if (TryComp(uid, out FixturesComponent? fixtureComponent)) { foreach (var fixture in fixtureComponent.Fixtures.Values) { fixture.CollisionMask |= (int)CollisionGroup.VaultImpassable; } } return(true); }
private void TryDoCollideStun(EntityUid uid, StunOnCollideComponent component, EntityUid target) { if (EntityManager.TryGetComponent <StatusEffectsComponent>(target, out var status)) { StandingStateComponent?standingState = null; AppearanceComponent? appearance = null; // Let the actual methods log errors for these. Resolve(target, ref standingState, ref appearance, false); _stunSystem.TryStun(target, TimeSpan.FromSeconds(component.StunAmount), true, status); _stunSystem.TryKnockdown(target, TimeSpan.FromSeconds(component.KnockdownAmount), true, status); _stunSystem.TrySlowdown(target, TimeSpan.FromSeconds(component.SlowdownAmount), true, component.WalkSpeedMultiplier, component.RunSpeedMultiplier, status); } }
/// <inheritdoc /> public override async Task <string> GetTextAsync(Appearance appearance, AppearanceComponent?component) { if (component is null) { return(string.Empty); } var scriptPath = ContentServiceExtensions.GetLuaScriptPath(component.Transformation, this.ScriptName); var result = await _lua.ExecuteScriptAsync ( scriptPath, (nameof(appearance), appearance), ("character", appearance.Character), (nameof(component), component) ); return(result.IsSuccess ? result.Entity : $"[{result.Error.Message}]"); }
protected override void Initialize() { base.Initialize(); _powerCellContainer = ContainerHelpers.EnsureContainer <ContainerSlot>(Owner, $"{Name}-powercell-container", out var existing); if (!existing && _powerCellPrototype != null) { var powerCellEntity = Owner.EntityManager.SpawnEntity(_powerCellPrototype, Owner.Transform.Coordinates); _powerCellContainer.Insert(powerCellEntity); } if (_ammoPrototype != null) { _ammoContainer = ContainerHelpers.EnsureContainer <ContainerSlot>(Owner, $"{Name}-ammo-container"); } if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) { _appearanceComponent = appearanceComponent; } Dirty(); }