Exemplo n.º 1
0
    /// <summary>
    /// Registers the <see cref="ExampleNetworkedEntityView"/> with the manager for tracking.
    /// <para>Initializes the <see cref="ExampleNetworkedEntityView"/> if it has not yet been initialized.</para>
    /// </summary>
    /// <param name="model"></param>
    /// <param name="view"></param>
    public void RegisterNetworkedEntityView(ExampleNetworkedEntity model, ColyseusNetworkedEntityView view)
    {
        if (string.IsNullOrEmpty(model.id) || view == null || _entities.ContainsKey(model.id) == false)
        {
            LSLog.LogError("Cannot Find Entity in Room");
            return;
        }

        ExampleNetworkedEntityView entityView = (ExampleNetworkedEntityView)view;

        if (entityView && !entityView.HasInit)
        {
            entityView.InitiView(model);
        }

        _entityViews.Add(model.id, (ExampleNetworkedEntityView)view);
        view.SendMessage("OnEntityViewRegistered", SendMessageOptions.DontRequireReceiver);
    }
 private void RemoveView(ColyseusNetworkedEntityView view)
 {
     view.SendMessage("OnEntityRemoved", SendMessageOptions.DontRequireReceiver);
 }