public LimbParams(XElement element, RagdollParams ragdoll) : base(element, ragdoll) { var spriteElement = element.Element("sprite"); if (spriteElement != null) { normalSpriteParams = new SpriteParams(spriteElement, ragdoll); SubParams.Add(normalSpriteParams); } var damagedElement = element.Element("damagedsprite"); if (damagedElement != null) { damagedSpriteParams = new SpriteParams(damagedElement, ragdoll); // Hide the damaged sprite params in the editor for now. //SubParams.Add(damagedSpriteParams); } var deformElement = element.Element("deformablesprite"); if (deformElement != null) { deformSpriteParams = new SpriteParams(deformElement, ragdoll); SubParams.Add(deformSpriteParams); } }
private SubParams getOrNewDecaySubParams(int idx, bool bRenew = false) { lock (syncObj) { int dataIdx = myDataIdx(idx); if (dataIdx >= _subParamsCache.Length) { _subParamsCache = _subParamsCache._extend(dataIdx + 1); } SubParams subParam = _subParamsCache[dataIdx]; var infData = NthInfectData(idx); if (infData != null && (bRenew || subParam == null || subParam.UpdateDt < _dailyData.LastUpdateDt)) { //int duration = CurrentSettings.localMaxRtDuration ?? -1; int duration = CurrentSettings.extremeRtDetectDuration ?? -1; var dt = CurrentSettings.myParamStartDate(idx)._parseDateTime(); int days = CurrentSettings.myParamDaysToOne(idx); if (days > 0 && dt._notValid()) { dt = getInitailParamStartDate(idx); } _subParamsCache[dataIdx] = subParam = infData.CalcDecaySubParamsEx(duration, dt._isValid() ? (DateTime?)dt : null, days, idx == -1 ? DebugLevel : 0); } if (subParam != null) { return(subParam); } logger.Warn("No effective SubParams. Return new SubParams()."); return(new SubParams()); } }
public virtual bool Serialize(bool recursive = true) { SerializableProperty.SerializeProperties(this, Element, true); if (recursive) { SubParams.ForEach(sp => sp.Serialize(true)); } return(true); }
public virtual bool Deserialize(bool recursive = true) { SerializableProperties = SerializableProperty.DeserializeProperties(this, Element); if (recursive) { SubParams.ForEach(sp => sp.Deserialize(true)); } return(SerializableProperties != null); }
public InventoryParams(XElement element, CharacterParams character) : base(element, character) { foreach (var itemElement in element.GetChildElements("item")) { var item = new InventoryItem(itemElement, character); SubParams.Add(item); Items.Add(item); } }
public virtual bool Serialize(XElement element = null, bool recursive = true) { element = element ?? Element; SerializableProperty.SerializeProperties(this, element, true); if (recursive) { SubParams.ForEach(sp => sp.Serialize()); } return(true); }
public void AddItem(string identifier = null) { identifier = identifier ?? ""; var element = new XElement("item", new XAttribute("identifier", identifier)); Element.Add(element); var item = new InventoryItem(element, Character); SubParams.Add(item); Items.Add(item); }
public virtual void AddToEditor(ParamsEditor editor, bool recursive = true, int space = 0, ScalableFont titleFont = null) { SerializableEntityEditor = new SerializableEntityEditor(editor.EditorBox.Content.RectTransform, this, inGame: false, showName: true, titleFont: titleFont ?? GUI.LargeFont); if (recursive) { SubParams.ForEach(sp => sp.AddToEditor(editor, true, titleFont: titleFont ?? GUI.SmallFont)); } if (space > 0) { new GUIFrame(new RectTransform(new Point(editor.EditorBox.Rect.Width, space), editor.EditorBox.Content.RectTransform), style: null, color: new Color(20, 20, 20, 255)) { CanBeFocused = false }; } }
private bool TryAddTarget(XElement targetElement, out TargetParams target) { string tag = targetElement.GetAttributeString("tag", null); if (HasTag(tag)) { target = null; DebugConsole.ThrowError($"Multiple targets with the same tag ('{tag}') defined! Only the first will be used!"); return(false); } else { target = new TargetParams(targetElement, Character); targets.Add(target); SubParams.Add(target); return(true); } }
protected bool RemoveSubParam <T>(T subParam, IList <T> collection = null) where T : SubParam { if (subParam == null || subParam.Element == null || subParam.Element.Parent == null) { return(false); } if (collection != null && !collection.Contains(subParam)) { return(false); } if (!SubParams.Contains(subParam)) { return(false); } collection?.Remove(subParam); SubParams.Remove(subParam); subParam.Element.Remove(); return(true); }
public virtual void Reset() { // Don't use recursion, because the reset method might be overriden Deserialize(false); SubParams.ForEach(sp => sp.Reset()); }
public virtual void AddToEditor(ParamsEditor editor) { SerializableEntityEditor = new SerializableEntityEditor(editor.EditorBox.Content.RectTransform, this, inGame: false, showName: true); SubParams.ForEach(sp => sp.AddToEditor(editor)); }
public void Reset() { Deserialize(OriginalElement, false); SubParams.ForEach(sp => sp.Reset()); }
public void SetCurrentElementAsOriginalElement() { OriginalElement = Element; SubParams.ForEach(sp => sp.SetCurrentElementAsOriginalElement()); }