/// Create a new instance /// @param template The template GameObject to spawn instances of /// @param spawnObjectEvery Spawn a new instance this often /// @param maxPoolSize Allow at most this many objects to exist /// @param callback Callback to provide animation curve, etc. public ObjectStream(GameObject template, float spawnObjectEvery, int maxPoolSize, SpawnCallback <TStream> factory) { this.SpawnObjectEvery = spawnObjectEvery; this._factory = factory; _pool = new SpawnedObjectPool(Option.Some(template), maxPoolSize); Elapsed = spawnObjectEvery; }
private static IEnumerator delayedSpawn(SpawnCallback callback, Action <SpawnCallback, Vector3> spawnAction, float duration, Vector3 pos) { // wait yield return(new WaitForSecondsRealtime(duration)); // spawn spawnAction(callback, pos); }
public void SpawnPreviewModel(string meshName, Vector3 position, bool valid, SpawnCallback callback) { SpawnModel(meshName, position, (obj) => { BackupMaterials(obj); obj.GetComponent <MeshRenderer>().SetAllMaterial(valid ? PreviewMaterial : InvalidPreviewMaterial); callback.Invoke(obj); }); }
public override void spawnAction(SpawnCallback callback, Vector3 pos) { base.spawnAction(callback, pos); Light2D newLight = newGameObject.GetComponent <Light2D>(); if (newLight) { newLight.color = new Color(Mathf.Clamp(newLight.color.r + Random.Range(-variance, variance), 0, 1), Mathf.Clamp(newLight.color.g + Random.Range(-variance, variance), 0, 1), Mathf.Clamp(newLight.color.b + Random.Range(-variance, variance), 0, 1)); } }
public void spawn(SpawnCallback callback, Vector3 pos) { // wait X seconds before spawning if (delay != 0) { StartCoroutine(delayedSpawn(callback, spawnAction, delay, pos)); } // spawm immediately else { spawnAction(callback, pos); } }
public virtual void spawnAction(SpawnCallback callback, Vector3 pos) { // spawn and positionned newly object TryGetNextObject(transform.position, transform.rotation, out newGameObject); newGameObject.transform.localPosition = pos; // do callback callback?.Invoke(newGameObject); // play spawn sound if (spawnSound != "") { AudioCtrl.Instance.playSoundEvent.Invoke(spawnSound); } }
public static DisposeCallback RegisterSpawning(DemoOpenInfo info, Key key, SpawnCallback callback) { EventHandler <KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e) { if (e.Key == key) { callback(info.Viewport.MousePosition); } }; Events.KeyboardDown += downHandler; return(delegate() { Events.KeyboardDown -= downHandler; }); }
public static extern int startHaggle(SpawnCallback callback);
public Spawner(SpawnCallback spawnCallback) { _onSpawnMonster += spawnCallback; }
public void SpawnModel(string address, Vector3 position, SpawnCallback callback) { var obj = ActivatePoolObject(address, position, transform); callback.Invoke(obj); }
private void InitModel(string address, Vector3 position, SpawnCallback callback) { var op = Addressables.InstantiateAsync(address, position, Quaternion.identity, transform); op.Completed += (AsyncOperationHandle <GameObject> obj) => callback.Invoke(obj.Result); }
public override void spawnAction(SpawnCallback callback, Vector3 pos) { base.spawnAction(callback, pos); //GameCtrl.Instance.player.control.animator = GameObject.FindGameObjectWithTag("Player").GetComponent<Animator>(); }
public static DisposeCallback RegisterMaintainSpawning(DemoOpenInfo info, Key key, SpawnCallback callback) { IPhysicsEntity current = null; EventHandler <KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e) { if (e.Key == key) { current = callback(info.Viewport.MousePosition); } }; EventHandler <KeyboardEventArgs> upHandler = delegate(object sender, KeyboardEventArgs e) { if (e.Key == key) { if (current != null) { current.Lifetime.IsExpired = true; current = null; } } }; Events.KeyboardDown += downHandler; Events.KeyboardUp += upHandler; return(delegate() { Events.KeyboardDown -= downHandler; Events.KeyboardUp -= upHandler; }); }
public static DisposeCallback RegisterMaintainSpawning(DemoOpenInfo info, Key key, SpawnCallback callback) { IPhysicsEntity current = null; EventHandler<KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e) { if (e.Key == key) { current = callback(info.Viewport.MousePosition); } }; EventHandler<KeyboardEventArgs> upHandler = delegate(object sender, KeyboardEventArgs e) { if (e.Key == key) { if (current != null) { current.Lifetime.IsExpired = true; current = null; } } }; Events.KeyboardDown += downHandler; Events.KeyboardUp += upHandler; return delegate() { Events.KeyboardDown -= downHandler; Events.KeyboardUp -= upHandler; }; }
public static DisposeCallback RegisterSpawning(DemoOpenInfo info, Key key, SpawnCallback callback) { EventHandler<KeyboardEventArgs> downHandler = delegate(object sender, KeyboardEventArgs e) { if (e.Key == key) { callback(info.Viewport.MousePosition); } }; Events.KeyboardDown += downHandler; return delegate() { Events.KeyboardDown -= downHandler; }; }
public void SpawnPreviewModel(StructureDefinition.StructureType type, Vector3 position, bool valid, SpawnCallback callback) { SpawnPreviewModel(_structureDefinitionManager.GetAssetNameForStructureType(type), position, valid, callback); }
static public extern int startHaggle(SpawnCallback callback);
public void SpawnUIElement(string name, Transform parent, SpawnCallback callback) { var op = Addressables.InstantiateAsync(name, parent.transform.position, Quaternion.identity, parent); op.Completed += (AsyncOperationHandle <GameObject> obj) => callback.Invoke(obj.Result); }