public override void _Ready() { bool _autostart = Autostart; Autostart = false; base._Ready(); if (syncedRandomDelay || pickOne) { parent = GetParent <GDKnyttBaseObject>(); } if (syncedRandomDelay) { firstDelay = parent.GDArea.Selector.GetRandomValue(parent, WaitTime); } if (pickOne && !manualRegister) { parent.GDArea.Selector.Register(parent); } if (_autostart) { RunTimer(); } }
public bool IsObjectSelected(GDKnyttBaseObject obj, bool by_type = false) { var type = getKey(obj, by_type); // Reset might be called sooner than an object is disposed, or object may be not registered if (!IsOpen || !allObjects.ContainsKey(type) || !allObjects[type].Contains(obj)) { return(false); } if (selections[type] == null) { counters[type] = 0; selections[type] = GDKnyttDataStore.random.NextElement(allObjects[type]); } counters[type]++; bool is_selected = selections[type] == obj; if (counters[type] >= allObjects[type].Count) { counters[type] = 0; selections[type] = GDKnyttDataStore.random.NextElement(allObjects[type]); } return(is_selected); }
public override void _Ready() { parent = GetParent <GDKnyttBaseObject>(); if (!parent.Juni.Powers.getPower(YKnyttLib.JuniValues.PowerNames.Eye)) { parent.QueueFree(); } }
public float GetRandomValue(GDKnyttBaseObject obj, float maxValue, bool by_type = false) { var type = getKey(obj, by_type); if (!randomValues.ContainsKey(type)) { randomValues.Add(type, GDKnyttDataStore.random.NextFloat(maxValue)); } return(randomValues[type]); }
public int GetIndex(GDKnyttBaseObject obj, bool by_type = false) { var type = getKey(obj, by_type); if (!allObjects.ContainsKey(type)) { return(0); } return(allObjects[type].IndexOf(obj)); }
public void Unregister(GDKnyttBaseObject obj, bool by_type = false) { var type = getKey(obj, by_type); if (!allObjects.ContainsKey(type)) { return; } allObjects[type].Remove(obj); counters[type] = 0; selections[type] = null; }
// Do not call Register and Unregister in IsObjectSelected series! public void Register(GDKnyttBaseObject obj, bool by_type = false) { var type = getKey(obj, by_type); if (!allObjects.ContainsKey(type)) { allObjects[type] = new List <object>(); counters[type] = 0; selections[type] = null; } allObjects[type].Add(obj); }
public override void _Ready() { Node candidate = GetParent(); while (!(candidate is GDKnyttBaseObject)) { candidate = candidate.GetParent(); } parent = candidate as GDKnyttBaseObject; if (parent.Juni.Powers.getCollectable(parent.ObjectID.y)) { parent.QueueFree(); return; } var area = GetNode <Area2D>("Area2D"); area.AddChild(GetNode <Node2D>(collisionPath).Duplicate()); }
public override void _Ready() { parent = GetParent <GDKnyttBaseObject>(); globalJuni = parent.Juni; sprite = spritePath != null?GetNode <AnimatedSprite>(spritePath) : null; }
public int GetSize(GDKnyttBaseObject obj, bool by_type = false) { var type = getKey(obj, by_type); return(allObjects.ContainsKey(type) ? allObjects[type].Count : 0); }
private object getKey(GDKnyttBaseObject obj, bool by_type) { return(by_type ? (object)obj.GetType() : obj.ObjectID); }