Singularity, Particle Accelerator & Radiation Collectors (#2169)
* basic radiation generator * might need this * thonk * big thonk * oop * e * werks * sprite * oopsy woopsy * radiation * clean up file * makes it work, probably * minor fixes * resources * progress on component * this will no longer be necessary * radiation go brrrr * finally fix container issues * out var Co-authored-by: Remie Richards <remierichards@gmail.com> * second out fix * another out fix Co-authored-by: Remie Richards <remierichards@gmail.com> * switch case * fix switch * sound and improvements * nullable * basic containment field system * ensure alignment * fix beam placement logic * field generation fully working * fix potential crash * working containment functionality * extremely basic emitter functionality * fix radiation panel naming * emitter stuff * oopsies * fixes * some fixes * cleanup * small fix and move emitter file * add sprite resources for PA * slight rework of the singulo adds rads * pushing for smugleaf :) * added radiationpanels * some fixes for the singulo * containmentfield * pa wip * progress * pa working * emitter fix * works :) * ui works * some work on ui & pa * progress * ui work & misc fixes * GREYSCALE * pa ui polish containmentfieldgen rework * singulo rework added snapgrid * getcomponent get out * singulo rework added collisiongroups underplating & passable * yaml work: - collision boxes - singulo now unshaded * no unlit * misc changes * pa wires * add usability check * nullable enable * minor fix * power need added * reenables containment field energy drain menu close button singularity collider fix * sprite replacement * finished singulo pulling * pjb fixes * fixing sprites & minor adjustments * decrease containmentfield power * some yml adjustments * unlit layers singulogenerator * singulogen * everything works just not the powergetting on the pa i wanna die * Adds PA construction graphs, PA construction works * Snap to grid parts when completing construction * updated to newest master * inb4 i work on power * fixes upstream merge adds power need to particleaccelerator * properly implements power & apc power * Emitters are now fancy. * I have actually no idea how this happened. * Give PA a wiring LayoutId * PA is an acronym * indicators fixes hacking * Singulo is a word you blasphemous IDE. * Rewrite the PA. * Fancy names for PA parts. * Wiring fixes, strength wire cutting. * fixes projectile & ignores components * nullability errors * fixes integration tests Co-authored-by: unusualcrow <unusualcrow@protonmail.com> Co-authored-by: L.E.D <10257081+unusualcrow@users.noreply.github.com> Co-authored-by: Remie Richards <remierichards@gmail.com> Co-authored-by: Víctor Aguilera Puerto <zddm@outlook.es> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -82,7 +82,10 @@ namespace Content.Client.GameObjects.Components.HUD.Inventory
|
||||
|
||||
foreach (var (slot, entityUid) in cast.Entities)
|
||||
{
|
||||
var entity = Owner.EntityManager.GetEntity(entityUid);
|
||||
if (!Owner.EntityManager.TryGetEntity(entityUid, out var entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!_slots.ContainsKey(slot) || _slots[slot] != entity)
|
||||
{
|
||||
_slots[slot] = entity;
|
||||
|
||||
@@ -22,7 +22,11 @@ namespace Content.Client.GameObjects.Components.Nutrition
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
if(!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
{
|
||||
return;
|
||||
};
|
||||
|
||||
if (!component.TryGetData<float>(SharedFoodComponent.FoodVisuals.MaxUses, out var maxUses))
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Content.Shared.GameObjects.Components.Singularity;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Reflection;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
public class ParticleAcceleratorPartVisualizer : AppearanceVisualizer
|
||||
{
|
||||
private Dictionary<ParticleAcceleratorVisualState, string> _states = new Dictionary<ParticleAcceleratorVisualState, string>();
|
||||
|
||||
public override void LoadData(YamlMappingNode node)
|
||||
{
|
||||
base.LoadData(node);
|
||||
|
||||
var serializer = YamlObjectSerializer.NewReader(node);
|
||||
if (!serializer.TryReadDataField<string>("baseState", out var baseState))
|
||||
{
|
||||
throw new PrototypeLoadException("No baseState property specified for ParticleAcceleratorPartVisualizer");
|
||||
}
|
||||
|
||||
_states.Add(ParticleAcceleratorVisualState.Powered, baseState+"p");
|
||||
_states.Add(ParticleAcceleratorVisualState.Level0, baseState+"p0");
|
||||
_states.Add(ParticleAcceleratorVisualState.Level1, baseState+"p1");
|
||||
_states.Add(ParticleAcceleratorVisualState.Level2, baseState+"p2");
|
||||
_states.Add(ParticleAcceleratorVisualState.Level3, baseState+"p3");
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
if (!entity.TryGetComponent<SpriteComponent>(out var sprite))
|
||||
{
|
||||
throw new EntityCreationException("No sprite component found in entity that has ParticleAcceleratorPartVisualizer");
|
||||
}
|
||||
|
||||
if (!sprite.AllLayers.Any())
|
||||
{
|
||||
throw new EntityCreationException("No Layer set for entity that has ParticleAcceleratorPartVisualizer");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
if (component.Owner.Deleted)
|
||||
return;
|
||||
|
||||
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite)) return;
|
||||
if (!component.TryGetData(ParticleAcceleratorVisuals.VisualState, out ParticleAcceleratorVisualState state))
|
||||
{
|
||||
state = ParticleAcceleratorVisualState.Unpowered;
|
||||
}
|
||||
|
||||
if (state != ParticleAcceleratorVisualState.Unpowered)
|
||||
{
|
||||
sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, true);
|
||||
sprite.LayerSetState(ParticleAcceleratorVisualLayers.Unlit, _states[state]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using Content.Client.GameObjects.Components.Doors;
|
||||
using Content.Client.GameObjects.Components.Wires;
|
||||
using Content.Shared.GameObjects.Components.Doors;
|
||||
using Content.Shared.GameObjects.Components.Singularity;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.GameObjects.Components.Animations;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
public class RadiationCollectorVisualizer : AppearanceVisualizer
|
||||
{
|
||||
private const string AnimationKey = "radiationcollector_animation";
|
||||
|
||||
private Animation ActivateAnimation;
|
||||
private Animation DeactiveAnimation;
|
||||
|
||||
public override void LoadData(YamlMappingNode node)
|
||||
{
|
||||
ActivateAnimation = new Animation {Length = TimeSpan.FromSeconds(0.8f)};
|
||||
{
|
||||
var flick = new AnimationTrackSpriteFlick();
|
||||
ActivateAnimation.AnimationTracks.Add(flick);
|
||||
flick.LayerKey = RadiationCollectorVisualLayers.Main;
|
||||
flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("ca_active", 0f));
|
||||
|
||||
/*var sound = new AnimationTrackPlaySound();
|
||||
CloseAnimation.AnimationTracks.Add(sound);
|
||||
sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(closeSound, 0));*/
|
||||
}
|
||||
|
||||
DeactiveAnimation = new Animation {Length = TimeSpan.FromSeconds(0.8f)};
|
||||
{
|
||||
var flick = new AnimationTrackSpriteFlick();
|
||||
DeactiveAnimation.AnimationTracks.Add(flick);
|
||||
flick.LayerKey = RadiationCollectorVisualLayers.Main;
|
||||
flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("ca_deactive", 0f));
|
||||
|
||||
/*var sound = new AnimationTrackPlaySound();
|
||||
CloseAnimation.AnimationTracks.Add(sound);
|
||||
sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(closeSound, 0));*/
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
if (!entity.HasComponent<AnimationPlayerComponent>())
|
||||
{
|
||||
entity.AddComponent<AnimationPlayerComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
if (component.Owner.Deleted)
|
||||
return;
|
||||
|
||||
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite)) return;
|
||||
if (!component.Owner.TryGetComponent<AnimationPlayerComponent>(out var animPlayer)) return;
|
||||
if (!component.TryGetData(RadiationCollectorVisuals.VisualState, out RadiationCollectorVisualState state))
|
||||
{
|
||||
state = RadiationCollectorVisualState.Deactive;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case RadiationCollectorVisualState.Active:
|
||||
sprite.LayerSetState(RadiationCollectorVisualLayers.Main, "ca_on");
|
||||
break;
|
||||
case RadiationCollectorVisualState.Activating:
|
||||
if (!animPlayer.HasRunningAnimation(AnimationKey))
|
||||
{
|
||||
animPlayer.Play(ActivateAnimation, AnimationKey);
|
||||
animPlayer.AnimationCompleted += _ =>
|
||||
component.SetData(RadiationCollectorVisuals.VisualState,
|
||||
RadiationCollectorVisualState.Active);
|
||||
}
|
||||
break;
|
||||
case RadiationCollectorVisualState.Deactivating:
|
||||
if (!animPlayer.HasRunningAnimation(AnimationKey))
|
||||
{
|
||||
animPlayer.Play(DeactiveAnimation, AnimationKey);
|
||||
animPlayer.AnimationCompleted += _ =>
|
||||
component.SetData(RadiationCollectorVisuals.VisualState,
|
||||
RadiationCollectorVisualState.Deactive);
|
||||
}
|
||||
break;
|
||||
case RadiationCollectorVisualState.Deactive:
|
||||
sprite.LayerSetState(RadiationCollectorVisualLayers.Main, "ca_off");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum RadiationCollectorVisualLayers
|
||||
{
|
||||
Main
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Singularity
|
||||
{
|
||||
public class ContainmentFieldComponent : Component
|
||||
{
|
||||
public override string Name => "Containment Field";
|
||||
|
||||
private SpriteComponent _spriteComponent;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (!Owner.TryGetComponent(out _spriteComponent))
|
||||
{
|
||||
Logger.Error("Containmentfieldcomponent created without spritecomponent");
|
||||
}
|
||||
else
|
||||
{
|
||||
_spriteComponent.Directional = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Singularity;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Singularity
|
||||
{
|
||||
public class EmitterVisualizer : AppearanceVisualizer
|
||||
{
|
||||
private const string OverlayBeam = "emitter-beam";
|
||||
private const string OverlayUnderPowered = "emitter-underpowered";
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!component.TryGetData(EmitterVisuals.Locked, out bool locked))
|
||||
locked = false;
|
||||
|
||||
|
||||
if (!component.TryGetData(EmitterVisuals.VisualState, out EmitterVisualState state))
|
||||
state = EmitterVisualState.Off;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case EmitterVisualState.On:
|
||||
sprite.LayerSetVisible(1, true);
|
||||
sprite.LayerSetState(1, OverlayBeam);
|
||||
break;
|
||||
case EmitterVisualState.Underpowered:
|
||||
sprite.LayerSetVisible(1, true);
|
||||
sprite.LayerSetState(1, OverlayUnderPowered);
|
||||
break;
|
||||
case EmitterVisualState.Off:
|
||||
sprite.LayerSetVisible(1, false);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
sprite.LayerSetVisible(2, locked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.Components.Sound;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Client.GameObjects.EntitySystems;
|
||||
@@ -55,7 +57,15 @@ namespace Content.Client.GameObjects.Components.Sound
|
||||
{
|
||||
if (!schedule.Play) return; // We make sure this hasn't changed.
|
||||
if (_audioSystem == null) _audioSystem = EntitySystem.Get<AudioSystem>();
|
||||
_audioStreams.Add(schedule,_audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams));
|
||||
|
||||
if (!_audioStreams.ContainsKey(schedule))
|
||||
{
|
||||
_audioStreams.Add(schedule,_audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams));
|
||||
}
|
||||
else
|
||||
{
|
||||
_audioStreams[schedule] = _audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams);
|
||||
}
|
||||
|
||||
if (schedule.Times == 0) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user