예제 #1
0
    public override IEnumerator Process()
    {
        yield return(WaitFor(SpawnedObject, ClonedFrom));

        if (NetworkObjects[0] == null)
        {
            Logger.LogWarning("Couldn't resolve SpawnedObject!", Category.NetMessage);
            yield break;
        }
        if (NetworkObjects[1] == null)
        {
            Logger.LogWarning("Couldn't resolve ClonedFrom!", Category.NetMessage);
            yield break;
        }

        //call all the hooks!
        var comps     = NetworkObjects[0].GetComponents <IClientSpawn>();
        var spawnInfo = ClientSpawnInfo.Create(NetworkObjects[1]);

        if (comps != null)
        {
            foreach (var comp in comps)
            {
                comp.OnSpawnClient(spawnInfo);
            }
        }
    }
예제 #2
0
    public override void Process()
    {
        LoadMultipleObjects(new uint[] { SpawnedObject, ClonedFrom });

        if (NetworkObjects[0] == null)
        {
            Logger.LogWarning("Couldn't resolve SpawnedObject!", Category.NetMessage);
            return;
        }
        if (NetworkObjects[1] == null)
        {
            Logger.LogWarning("Couldn't resolve ClonedFrom!", Category.NetMessage);
            return;
        }

        //call all the hooks!
        var comps     = NetworkObjects[0].GetComponents <IClientSpawn>();
        var spawnInfo = ClientSpawnInfo.Create(NetworkObjects[1]);

        if (comps != null)
        {
            foreach (var comp in comps)
            {
                comp.OnSpawnClient(spawnInfo);
            }
        }
    }
예제 #3
0
 public static void _CallAllClientSpawnHooksInScene()
 {
     //client side, just call the hooks
     foreach (var clientSpawn in FindUtils.FindInterfaceImplementersInScene <IClientSpawn>())
     {
         clientSpawn.OnSpawnClient(ClientSpawnInfo.Default());
     }
 }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clonedFrom">object cloned from, null if not a clone</param>
 /// <returns></returns>
 public static ClientSpawnInfo Create(GameObject clonedFrom)
 {
     if (clonedFrom)
     {
         return(ClientSpawnInfo.Cloned(clonedFrom));
     }
     else
     {
         return(ClientSpawnInfo.Default());
     }
 }
예제 #5
0
 public void OnSpawnClient(ClientSpawnInfo info)
 {
     if (!CustomNetworkManager.IsServer)
     {
         inputNode               = new HackingNode();
         inputNode.HiddenLabel   = "Input";
         inputNode.IsInput       = true;
         inputNode.IsDeviceNode  = true;
         outputNode              = new HackingNode();
         outputNode.HiddenLabel  = "Output";
         outputNode.IsOutput     = true;
         outputNode.IsDeviceNode = true;
     }
 }
예제 #6
0
    public override IEnumerator Process()
    {
        yield return(WaitFor(SpawnedObject, ClonedFrom));

        //call all the hooks!
        var comps     = NetworkObjects[0].GetComponents <IClientSpawn>();
        var spawnInfo = ClientSpawnInfo.Create(NetworkObjects[1]);

        if (comps != null)
        {
            foreach (var comp in comps)
            {
                comp.OnSpawnClient(spawnInfo);
            }
        }
    }
예제 #7
0
    /// <summary>
    /// Performs the specified spawn locally, for this client only.
    /// </summary>
    /// <returns></returns>
    public static SpawnResult Client(SpawnInfo info)
    {
        if (info == null)
        {
            Logger.LogError("Cannot spawn, info is null", Category.ItemSpawn);
            return(SpawnResult.Fail(info));
        }

        if (info.SpawnableToSpawn is IClientSpawnable clientSpawnable)
        {
            List <GameObject> spawnedObjects = new List <GameObject>();
            for (var i = 0; i < info.Count; i++)
            {
                var result = clientSpawnable.ClientSpawnAt(info.SpawnDestination);
                if (result.Successful)
                {
                    spawnedObjects.Add(result.GameObject);
                }
            }

            //fire client side lifecycle hooks
            foreach (var spawnedObject in spawnedObjects)
            {
                var hooks = spawnedObject.GetComponents <IClientSpawn>();
                if (hooks != null)
                {
                    foreach (var hook in hooks)
                    {
                        hook.OnSpawnClient(ClientSpawnInfo.Default());
                    }
                }
            }

            if (spawnedObjects.Count == 1)
            {
                return(SpawnResult.Single(info, spawnedObjects[0]));
            }

            return(SpawnResult.Multiple(info, spawnedObjects));
        }
        else
        {
            Logger.LogErrorFormat("Cannot spawn {0} client side, spawnable does not" +
                                  " implement IClientSpawnable", Category.ItemSpawn, info);
            return(SpawnResult.Fail(info));
        }
    }
예제 #8
0
    /// <summary>
    /// Performs the specified spawn locally, for this client only.
    /// </summary>
    /// <returns></returns>
    public static SpawnResult Client(SpawnInfo info)
    {
        if (info == null)
        {
            Logger.LogError("Cannot spawn, info is null", Category.ItemSpawn);
            return(SpawnResult.Fail(info));
        }
        List <GameObject> spawnedObjects = new List <GameObject>();

        for (var i = 0; i < info.Count; i++)
        {
            if (info.SpawnableType == SpawnableType.Cloth)
            {
                Logger.LogErrorFormat("Spawning cloths on client side is not currently supported. {0}", Category.ItemSpawn, info);
                return(SpawnResult.Fail(info));
            }

            bool isPooled;             // not used for Client-only instantiation
            var  go = PoolInstantiate(info.PrefabUsed, info.WorldPosition, info.Rotation, info.Parent, out isPooled);

            spawnedObjects.Add(go);
        }

        //fire client side lifecycle hooks
        foreach (var spawnedObject in spawnedObjects)
        {
            var hooks = spawnedObject.GetComponents <IClientSpawn>();
            if (hooks != null)
            {
                foreach (var hook in hooks)
                {
                    hook.OnSpawnClient(ClientSpawnInfo.Default());
                }
            }
        }

        if (spawnedObjects.Count == 1)
        {
            return(SpawnResult.Single(info, spawnedObjects[0]));
        }

        return(SpawnResult.Multiple(info, spawnedObjects));
    }
예제 #9
0
 public void OnSpawnClient(ClientSpawnInfo info)
 {
     // Set grenade to locked state by default
     UpdateSprite(LOCKED_SPRITE);
 }