public static IDirectionalTextureProvider DirFrame0(this SpriteSpecifier specifier) { var resc = IoCManager.Resolve <IResourceCache>(); switch (specifier) { case SpriteSpecifier.Texture tex: return(resc.GetResource <TextureResource>(SpriteComponent.TextureRoot / tex.TexturePath).Texture); case SpriteSpecifier.Rsi rsi: if (resc.TryGetResource <RSIResource>(SpriteComponent.TextureRoot / rsi.RsiPath, out var theRsi)) { if (theRsi.RSI.TryGetState(rsi.RsiState, out var state)) { return(state); } } return(resc.GetFallback <TextureResource>().Texture); case SpriteSpecifier.EntityPrototype prototypeIcon: var protMgr = IoCManager.Resolve <IPrototypeManager>(); if (!protMgr.TryIndex <EntityPrototype>(prototypeIcon.EntityPrototypeId, out var prototype)) { Logger.Error("Failed to load PrototypeIcon {0}", prototypeIcon.EntityPrototypeId); return(resc.GetFallback <TextureResource>().Texture); } return(SpriteComponent.GetPrototypeIcon(prototype, resc) ?? resc.GetFallback <TextureResource>().Texture); default: throw new NotImplementedException(); } }
public ConditionInfo(string title, string description, SpriteSpecifier spriteSpecifier, float progress) { Title = title; Description = description; SpriteSpecifier = spriteSpecifier; Progress = progress; }
public static IRsiStateLike RsiStateLike(this SpriteSpecifier specifier) { var resC = IoCManager.Resolve <IResourceCache>(); switch (specifier) { case SpriteSpecifier.Texture tex: return(tex.GetTexture(resC)); case SpriteSpecifier.Rsi rsi: return(rsi.GetState(resC)); case SpriteSpecifier.EntityPrototype prototypeIcon: var protMgr = IoCManager.Resolve <IPrototypeManager>(); if (!protMgr.TryIndex <EntityPrototype>(prototypeIcon.EntityPrototypeId, out var prototype)) { Logger.Error("Failed to load PrototypeIcon {0}", prototypeIcon.EntityPrototypeId); return(SpriteComponent.GetFallbackState(resC)); } return(SpriteComponent.GetPrototypeIcon(prototype, resC)); default: throw new NotSupportedException(); } }
public void SetFromSpriteSpecifier(SpriteSpecifier specifier) { _curFrame = 0; _state = specifier.RsiStateLike(); _curFrameTime = _state.GetDelay(0); DisplayRect.Texture = _state.GetFrame(RsiDirection, 0); }
public NetVerbData(VerbData data, string key) { Text = data.Text; Key = key; Category = data.Category; CategoryIcon = data.CategoryIcon; Icon = data.Icon; Available = data.Visibility == VerbVisibility.Visible; }
protected override void Startup() { base.Startup(); RecalculateColor(); if (!string.IsNullOrEmpty(_fillInitState)) { _spriteComponent = Owner.GetComponent <SpriteComponent>(); _fillPath = new ResourcePath(_fillPathString); _fillSprite = new SpriteSpecifier.Rsi(_fillPath, _fillInitState + (_fillInitSteps - 1)); _spriteComponent.AddLayerWithSprite(_fillSprite); UpdateFillIcon(); } }
public DataNode Write(ISerializationManager serializationManager, SpriteSpecifier value, bool alwaysWrite = false, ISerializationContext?context = null) { return(value switch { Rsi rsi => Write(serializationManager, rsi, alwaysWrite, context), Texture texture => Write(serializationManager, texture, alwaysWrite, context), EntityPrototype entityPrototype => Write(serializationManager, entityPrototype, alwaysWrite, context), _ => throw new InvalidOperationException("Invalid SpriteSpecifier specified!") });
public void LoadFrom(YamlMappingNode mapping) { var ser = YamlObjectSerializer.NewReader(mapping); _name = ser.ReadDataField <string>("name"); ser.DataField(ref _id, "id", string.Empty); ser.DataField(ref _description, "description", string.Empty); ser.DataField(ref _icon, "icon", SpriteSpecifier.Invalid); ser.DataField(ref _type, "objectType", ConstructionType.Structure); ser.DataField(ref _result, "result", null); ser.DataField(ref _placementMode, "placementMode", "PlaceFree"); ser.DataField(ref _canBuildInImpassable, "canBuildInImpassable", false); _keywords = ser.ReadDataField <List <string> >("keywords", new List <string>()); { var cat = ser.ReadDataField <string>("category"); var split = cat.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); _categorySegments = split.ToList(); } { SpriteSpecifier nextIcon = null; ConstructionStep nextBackward = null; foreach (var stepMap in mapping.GetNode <YamlSequenceNode>("steps").Cast <YamlMappingNode>()) { var step = ReadStepPrototype(stepMap); _stages.Add(new ConstructionStage(step, nextIcon, nextBackward)); if (stepMap.TryGetNode("icon", out var node)) { nextIcon = SpriteSpecifier.FromYaml(node); } if (stepMap.TryGetNode("reverse", out YamlMappingNode revMap)) { nextBackward = ReadStepPrototype(revMap); } } _stages.Add(new ConstructionStage(null, nextIcon, nextBackward)); } }
public static Texture[] FrameArr(this SpriteSpecifier specifier) { var resc = IoCManager.Resolve <IResourceCache>(); switch (specifier) { case SpriteSpecifier.Rsi rsi: if (resc.TryGetResource <RSIResource>(SpriteComponent.TextureRoot / rsi.RsiPath, out var theRsi)) { if (theRsi.RSI.TryGetState(rsi.RsiState, out var state)) { return(state.Icons[0]); } } Logger.Error("Failed to load RSI {0}", rsi.RsiPath); return(new Texture[0]); default: throw new NotImplementedException(); } }
protected void UpdateFillIcon() { if (string.IsNullOrEmpty(_fillInitState)) { return; } var percentage = (CurrentVolume / MaxVolume).Double(); var level = ContentHelpers.RoundToLevels(percentage * 100, 100, _fillInitSteps); //Transformed glass uses special fancy sprites so we don't bother if (level == 0 || (Owner.TryGetComponent <TransformableContainerComponent>(out var transformComp) && transformComp.Transformed)) { _spriteComponent.LayerSetColor(1, Color.Transparent); return; } _fillSprite = new SpriteSpecifier.Rsi(_fillPath, _fillInitState + level); _spriteComponent.LayerSetSprite(1, _fillSprite); _spriteComponent.LayerSetColor(1, SubstanceColor); }
public IRsiStateLike RsiStateLike(SpriteSpecifier specifier) { switch (specifier) { case SpriteSpecifier.Texture tex: return(tex.GetTexture(_resourceCache)); case SpriteSpecifier.Rsi rsi: return(GetState(rsi)); case SpriteSpecifier.EntityPrototype prototypeIcon: if (!_proto.TryIndex <EntityPrototype>(prototypeIcon.EntityPrototypeId, out var prototype)) { Logger.Error("Failed to load PrototypeIcon {0}", prototypeIcon.EntityPrototypeId); return(SpriteComponent.GetFallbackState(_resourceCache)); } return(SpriteComponent.GetPrototypeIcon(prototype, _resourceCache)); default: throw new NotSupportedException(); } }
static Atmospherics() { var protoMan = IoCManager.Resolve <IPrototypeManager>(); GasPrototypes = new GasPrototype[TotalNumberOfGases]; GasOverlays = new SpriteSpecifier[TotalNumberOfGases]; for (var i = 0; i < TotalNumberOfGases; i++) { var gasPrototype = protoMan.Index <GasPrototype>(i.ToString()); GasPrototypes[i] = gasPrototype; if (string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayTexture)) { GasOverlays[i] = new SpriteSpecifier.Texture(new ResourcePath(gasPrototype.GasOverlayTexture)); } if (!string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayState)) { GasOverlays[i] = new SpriteSpecifier.Rsi(new ResourcePath(gasPrototype.GasOverlaySprite), gasPrototype.GasOverlayState); } } }
public static IDirectionalTextureProvider DirFrame0(this SpriteSpecifier specifier) { var resc = IoCManager.Resolve <IResourceCache>(); switch (specifier) { case SpriteSpecifier.Texture tex: return((Texture)resc.GetResource <TextureResource>(SpriteComponent.TextureRoot / tex.TexturePath)); case SpriteSpecifier.Rsi rsi: if (resc.TryGetResource <RSIResource>(SpriteComponent.TextureRoot / rsi.RsiPath, out var theRsi)) { if (theRsi.RSI.TryGetState(rsi.RsiState, out var state)) { return(state); } } return((Texture)resc.GetFallback <TextureResource>()); default: throw new NotImplementedException(); } }
public Texture Frame0(SpriteSpecifier specifier) { return(RsiStateLike(specifier).Default); }
public override object NodeToType(Type type, YamlNode node, YamlObjectSerializer serializer) { return(SpriteSpecifier.FromYaml(node)); }
public ConstructionStage(ConstructionStep forward, SpriteSpecifier icon = null, ConstructionStep backward = null) { Icon = icon; Forward = forward; Backward = backward; }
public VerbCategoryData(string name, SpriteSpecifier icon) { Name = name; Icon = icon; }
public static IDirectionalTextureProvider DirFrame0(this SpriteSpecifier specifier) { return(specifier.RsiStateLike()); }
public static Texture Frame0(this SpriteSpecifier specifier) { return(specifier.RsiStateLike().Default); }