private void RpcFireCloneHook(GameObject clonedFrom) { var comps = GetComponents <IOnStageClient>(); if (comps != null) { foreach (var comp in comps) { comp.GoingOnStageClient(OnStageInfo.Cloned(clonedFrom)); } } }
private void RpcFireGoingOnStageHook() { var comps = GetComponents <IOnStageClient>(); if (comps != null) { foreach (var comp in comps) { comp.GoingOnStageClient(OnStageInfo.Default()); } } }
/// <summary> /// Spawn the item locally without syncing it over the network. Only client-side lifecycle hooks will be called. /// </summary> /// <param name="prefab">Prefab to spawn an instance of. </param> /// <param name="position">world position to appear at. Defaults to HiddenPos (hidden / invisible)</param> /// <param name="rotation">rotation to spawn with, defaults to Quaternion.identity</param> /// <param name="parent">Parent to spawn under, defaults to no parent. Most things /// should always be spawned under the Objects transform in their matrix. Many objects (due to RegisterTile) /// usually take care of properly parenting themselves when spawned so in many cases you can leave it null.</param> /// <returns>the newly created GameObject</returns> public static GameObject PoolClientInstantiate(GameObject prefab, Vector3?position = null, Transform parent = null, Quaternion?rotation = null) { if (!IsInstanceInit()) { return(null); } bool isPooled; // not used for Client-only instantiation var go = Instance.PoolInstantiate(prefab, position ?? TransformState.HiddenPos, rotation ?? Quaternion.identity, parent, out isPooled); //fire client side lifecycle hooks var hooks = go.GetComponents <IOnStageClient>(); if (hooks != null) { foreach (var hook in hooks) { hook.GoingOnStageClient(OnStageInfo.Default()); } } return(go); }
public void GoingOnStageServer(OnStageInfo info) { ServerEnsureMag(); if (info.IsCloned) { //set initial ammo from cloned var otherMag = info.ClonedFrom.GetComponent <Gun>().CurrentMagazine; if (otherMag == null) { CurrentMagazine.ServerSetAmmoRemains(0); } else { CurrentMagazine.ServerSetAmmoRemains(otherMag.ServerAmmoRemains); } } else { //reinit ammo to max CurrentMagazine.ServerSetAmmoRemains(CurrentMagazine.magazineSize); } }
public void FireCloneHooks(GameObject clonedFrom) { var comps = GetComponents <IOnStageServer>(); if (comps != null) { foreach (var comp in comps) { comp.GoingOnStageServer(OnStageInfo.Cloned(clonedFrom)); } } var clientComps = GetComponents <IOnStageClient>(); if (clientComps != null) { foreach (var comp in clientComps) { comp.GoingOnStageClient(OnStageInfo.Cloned(clonedFrom)); } } RpcFireCloneHook(clonedFrom); }
public void FireGoingOnStageHooks() { var comps = GetComponents <IOnStageServer>(); if (comps != null) { foreach (var comp in comps) { comp.GoingOnStageServer(OnStageInfo.Default()); } } var clientComps = GetComponents <IOnStageClient>(); if (clientComps != null) { foreach (var comp in clientComps) { comp.GoingOnStageClient(OnStageInfo.Default()); } } RpcFireGoingOnStageHook(); }
public void GoingOnStageServer(OnStageInfo info) { if (info.IsCloned) { //cloned var clonedIntegrity = info.ClonedFrom.GetComponent <Integrity>(); integrity = clonedIntegrity.integrity; timeSinceLastBurn = clonedIntegrity.timeSinceLastBurn; destroyed = clonedIntegrity.destroyed; SyncOnFire(clonedIntegrity.onFire); } else { //spawned integrity = initialIntegrity; timeSinceLastBurn = 0; destroyed = false; if (burningObjectOverlay != null) { burningObjectOverlay.StopBurning(); } SyncOnFire(false); } }
public void GoingOnStageServer(OnStageInfo info) { ServerInit(); }
public void GoingOnStageServer(OnStageInfo info) { GetComponent <ClosetControl>().ToggleLocker(false); }
public void GoingOnStageServer(OnStageInfo info) { SetupInitialValues(); }
public void GoingOnStageServer(OnStageInfo info) { timesUsed = 0; }
public void GoingOnStageClient(OnStageInfo info) { // Set grenade to locked state by default UpdateSprite(LOCKED_SPRITE); }
public void GoingOnStageServer(OnStageInfo info) { SyncItemName(itemName); }