public virtual void invoke(EntityRef entity, Event @event) { try { object[] @params = new object[2 + componentParams.size()]; @params[0] = @event; @params[1] = entity; for (int i = 0; i < componentParams.size(); ++i) { @params[i + 2] = entity.getComponent(componentParams.get(i)); } method.invoke(handler, @params); } catch (IllegalAccessException ex) { logger.error("Failed to invoke event", ex); } catch (System.ArgumentException ex) { logger.error("Failed to invoke event", ex); } catch (InvocationTargetException ex) { logger.error("Failed to invoke event", ex); } }
private void sendEventToServer(EntityRef entity, Event @event) { if (networkSystem.Mode == NetworkMode.CLIENT) { NetworkComponent netComp = entity.getComponent(typeof(NetworkComponent)); if (netComp != null) { networkSystem.Server.send(@event, entity); } } }
private void broadcastEvent(EntityRef entity, Event @event, EventMetadata metadata) { if (networkSystem.Mode.Server) { NetworkComponent netComp = entity.getComponent(typeof(NetworkComponent)); BlockComponent blockComp = entity.getComponent(typeof(BlockComponent)); if (netComp != null || blockComp != null) { Client instigatorClient = null; if (metadata.SkipInstigator && @event is NetworkEvent) { instigatorClient = networkSystem.getOwner(((NetworkEvent)@event).Instigator); } foreach (Client client in networkSystem.Players) { if (!client.Equals(instigatorClient)) { client.send(@event, entity); } } } } }
private void sendEventToOwner(EntityRef entity, Event @event) { if (networkSystem.Mode.Server) { NetworkComponent netComp = entity.getComponent(typeof(NetworkComponent)); if (netComp != null) { Client client = networkSystem.getOwner(entity); if (client != null) { client.send(@event, entity); } } } }
/// <summary> /// Produces a collection of entities that are owned by the provided entity. /// This is immediate ownership only - it does not recursively follow ownership. /// </summary> /// <param name="entity"> The owning entity </param> /// <returns> A collection of owned entities of the given entity </returns> public ICollection <EntityRef> listOwnedEntities(EntityRef entity) { Set <EntityRef> entityRefList = Sets.newHashSet(); //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET: //ORIGINAL LINE: for (org.terasology.entitySystem.metadata.ComponentMetadata<?> componentMetadata : componentLibrary.iterateComponentMetadata()) foreach (ComponentMetadata <?> componentMetadata in componentLibrary.iterateComponentMetadata()) { if (componentMetadata.ReferenceOwner) { Component comp = entity.getComponent(componentMetadata.Type); if (comp != null) { addOwnedEntitiesFor(comp, componentMetadata, entityRefList); } } } return(entityRefList); }