partial void InitProjSpecific(XElement element) { foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "crosshair": { string texturePath = subElement.GetAttributeString("texture", ""); crosshairSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.FilePath)); } break; case "crosshairpointer": { string texturePath = subElement.GetAttributeString("texture", ""); crosshairPointerSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.FilePath)); } break; case "particleemitter": particleEmitters.Add(new ParticleEmitter(subElement)); break; case "particleemittercharge": particleEmitterCharges.Add(new ParticleEmitter(subElement)); break; case "chargesound": chargeSound = Submarine.LoadRoundSound(subElement, false); break; } } }
partial void InitProjectSpecific(XElement element) { foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "poweronsound": powerOnSound = Submarine.LoadRoundSound(subElement, false); break; } } }
partial void InitProjSpecific(XElement element) { foreach (XElement subElement in element.Elements()) { string texturePath = subElement.GetAttributeString("texture", ""); switch (subElement.Name.ToString().ToLowerInvariant()) { case "crosshair": crosshairSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.FilePath)); break; case "crosshairpointer": crosshairPointerSprite = new Sprite(subElement, texturePath.Contains("/") ? "" : Path.GetDirectoryName(item.Prefab.FilePath)); break; case "startmovesound": startMoveSound = Submarine.LoadRoundSound(subElement, false); break; case "endmovesound": endMoveSound = Submarine.LoadRoundSound(subElement, false); break; case "movesound": moveSound = Submarine.LoadRoundSound(subElement, false); break; case "chargesound": chargeSound = Submarine.LoadRoundSound(subElement, false); break; case "particleemitter": particleEmitters.Add(new ParticleEmitter(subElement)); break; case "particleemittercharge": particleEmitterCharges.Add(new ParticleEmitter(subElement)); break; } } powerIndicator = new GUIProgressBar(new RectTransform(new Vector2(0.18f, 0.03f), GUI.Canvas, Anchor.BottomCenter) { MinSize = new Point(100, 20), RelativeOffset = new Vector2(0.0f, 0.01f) }, barSize: 0.0f, style: "DeviceProgressBar") { CanBeFocused = false }; }
partial void InitProjectSpecific(XElement element) { sparkSounds = new List <RoundSound>(); foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "poweronsound": powerOnSound = Submarine.LoadRoundSound(subElement, false); break; case "sparksound": sparkSounds.Add(Submarine.LoadRoundSound(subElement, false)); break; } } }
private bool LoadElemProjSpecific(XElement subElement) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "guiframe": if (subElement.Attribute("rect") != null) { DebugConsole.ThrowError("Error in item config \"" + item.ConfigFile + "\" - GUIFrame defined as rect, use RectTransform instead."); break; } Color?color = null; if (subElement.Attribute("color") != null) { color = subElement.GetAttributeColor("color", Color.White); } string style = subElement.Attribute("style") == null ? null : subElement.GetAttributeString("style", ""); GuiFrame = new GUIFrame(RectTransform.Load(subElement, GUI.Canvas), style, color); DefaultLayout = GUILayoutSettings.Load(subElement); break; case "alternativelayout": AlternativeLayout = GUILayoutSettings.Load(subElement); break; case "itemsound": case "sound": string filePath = subElement.GetAttributeString("file", ""); if (filePath == "") { filePath = subElement.GetAttributeString("sound", ""); } if (filePath == "") { DebugConsole.ThrowError("Error when instantiating item \"" + item.Name + "\" - sound with no file path set"); break; } if (!filePath.Contains("/") && !filePath.Contains("\\") && !filePath.Contains(Path.DirectorySeparatorChar)) { filePath = Path.Combine(Path.GetDirectoryName(item.Prefab.ConfigFile), filePath); } ActionType type; try { type = (ActionType)Enum.Parse(typeof(ActionType), subElement.GetAttributeString("type", ""), true); } catch (Exception e) { DebugConsole.ThrowError("Invalid sound type in " + subElement + "!", e); break; } RoundSound sound = Submarine.LoadRoundSound(subElement); if (sound == null) { break; } ItemSound itemSound = new ItemSound(sound, type, subElement.GetAttributeBool("loop", false)) { VolumeProperty = subElement.GetAttributeString("volumeproperty", "").ToLowerInvariant() }; if (soundSelectionModes == null) { soundSelectionModes = new Dictionary <ActionType, SoundSelectionMode>(); } if (!soundSelectionModes.ContainsKey(type) || soundSelectionModes[type] == SoundSelectionMode.Random) { SoundSelectionMode selectionMode = SoundSelectionMode.Random; Enum.TryParse(subElement.GetAttributeString("selectionmode", "Random"), out selectionMode); soundSelectionModes[type] = selectionMode; } List <ItemSound> soundList = null; if (!sounds.TryGetValue(itemSound.Type, out soundList)) { soundList = new List <ItemSound>(); sounds.Add(itemSound.Type, soundList); } soundList.Add(itemSound); break; default: return(false); //unknown element } return(true); //element processed }
public ItemSound(RoundSound sound, ActionType type, bool loop = false) { this.RoundSound = sound; this.Type = type; this.Loop = loop; }