/// <summary>
 /// A generic add component
 /// </summary>
 private void AddComponentGeneric(Entity entity, IComponentData component)
 {
     MethodInfo methodInfo        = typeof(EntityManager).GetMethod("AddComponentData");
     MethodInfo genericMethodInfo = methodInfo.MakeGenericMethod(component.GetType());
     var        parameters        = new object[] { entity, component };
     object     componentData     = genericMethodInfo.Invoke(this.entityManager, parameters);
 }
示例#2
0
 public EntityBuilder AddComponent <T>(IComponentData <T> data, WorkerRequirementSet writeAcl)
     where T : IComponentMetaclass
 {
     entity.Add(data);
     entityAcl.SetWriteAccess <T>(writeAcl);
     return(this);
 }
示例#3
0
 public Dynamic.IComponentPresentation BuildComponentPresentation(IComponentData component, ITemplateData componentTemplate)
 {
     return new Dynamic.ComponentPresentation //Locking in to default DD4T implementation
     {
         Component = component.BaseData as Dynamic.Component, //Assuming default DD4T implementation
         ComponentTemplate = componentTemplate.BaseData as Dynamic.ComponentTemplate //Assuming default DD4T implementation
     };
 }
示例#4
0
 public unsafe void CopyToSnapshot(ref Snapshot snapshot, ref IComponentData component)
 {
     if (true)
     {
         #region __GHOST_COPY_TO_SNAPSHOT__
         snapshot.__GHOST_FIELD_NAME__ = (int)math.round(component.__GHOST_FIELD_REFERENCE__ * __GHOST_QUANTIZE_SCALE__);
         #endregion
     }
 }
示例#5
0
 public unsafe void CopyToSnapshot(ref Snapshot snapshot, ref IComponentData component)
 {
     if (true)
     {
         #region __GHOST_COPY_TO_SNAPSHOT__
         snapshot.__GHOST_FIELD_NAME__ = (uint)component.__GHOST_FIELD_REFERENCE__;
         #endregion
     }
 }
示例#6
0
 public unsafe void CopyFromSnapshot(ref Snapshot snapshot, ref IComponentData component)
 {
     if (true)
     {
         #region __GHOST_COPY_FROM_SNAPSHOT__
         component.__GHOST_FIELD_REFERENCE__ = (__GHOST_FIELD_TYPE_NAME__)snapshotBefore.__GHOST_FIELD_NAME__;
         #endregion
     }
 }
示例#7
0
 public unsafe void CopyToSnapshot(ref Snapshot snapshot, ref IComponentData component)
 {
     if (true)
     {
         #region __GHOST_COPY_TO_SNAPSHOT__
         snapshot.__GHOST_FIELD_NAME__W = (int)(component.__GHOST_FIELD_REFERENCE__.value.z > 0.0f
             ? component.__GHOST_FIELD_REFERENCE__.value.w * __GHOST_QUANTIZE_SCALE__
             : -component.__GHOST_FIELD_REFERENCE__.value.w * __GHOST_QUANTIZE_SCALE__);
         #endregion
     }
 }
        public unsafe void CopyFromSnapshot(ref Snapshot snapshot, ref IComponentData component)
        {
            if (true)
            {
                #region __GHOST_COPY_FROM_SNAPSHOT__
                component.__GHOST_FIELD_REFERENCE__ = snapshotBefore.__GHOST_FIELD_NAME__;
                #endregion

                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE__
                component.__GHOST_FIELD_REFERENCE__ = math.lerp(snapshotBefore.__GHOST_FIELD_NAME__,
                                                                snapshotAfter.__GHOST_FIELD_NAME__, snapshotInterpolationFactor);
                #endregion
            }
        }
        public static Entity CreatePlayerCreatorTemplate(IComponentData <PlatformPosition> platformPosiionData)
        {
            var playerCreatorEntityTemplate = EntityBuilder.Begin()
                                              .AddPositionComponent(Coordinates.ZERO.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                              .AddMetadataComponent(entityType: SimulationSettings.PlayerCreatorPrefabName)
                                              .SetPersistence(true)
                                              .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                              .AddComponent(new Rotation.Data(UnityEngine.Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(new PlayerCreation.Data(), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(new ClientEntityStore.Data(new Map <string, EntityId>()), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(platformPosiionData, CommonRequirementSets.PhysicsOnly)
                                              .Build();

            return(playerCreatorEntityTemplate);
        }
示例#10
0
        public void BindComponentTo(Entity entity, IComponentData componentData, bool isAttach = true)
        {
            var componentType = componentData.GetType();
            var processing    = entitySystemsController.SystemInfos.Values.Where(e =>
                                                                                 e.NeededComponents.Any(x => x.TypeComponent.GetElementType() == componentType));

            foreach (var processingInfo in processing)
            {
                if (processingInfo.NeededComponents.All(e =>
                                                        EntityContainer.HasComponent(entity, e.TypeComponent.GetElementType())))
                {
                    processingInfo.AttachedEntity.Add(entity);
                    if (isAttach)
                    {
                        AttachComponents(processingInfo, processingInfo.AttachedEntity);
                    }
                }
            }
        }
        public unsafe void CopyFromSnapshot(ref Snapshot snapshot, ref IComponentData component)
        {
            if (true)
            {
                #region __GHOST_COPY_FROM_SNAPSHOT__
                component.__GHOST_FIELD_REFERENCE__ = snapshotBefore.__GHOST_FIELD_NAME__ * __GHOST_DEQUANTIZE_SCALE__;
                #endregion

                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE_SETUP__
                var __GHOST_FIELD_NAME___Before = snapshotBefore.__GHOST_FIELD_NAME__ * __GHOST_DEQUANTIZE_SCALE__;
                var __GHOST_FIELD_NAME___After  = snapshotAfter.__GHOST_FIELD_NAME__ * __GHOST_DEQUANTIZE_SCALE__;
                #endregion
                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE_DISTSQ__
                var __GHOST_FIELD_NAME___DistSq = math.distancesq(__GHOST_FIELD_NAME___Before, __GHOST_FIELD_NAME___After);
                #endregion
                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE__
                component.__GHOST_FIELD_REFERENCE__ = math.lerp(__GHOST_FIELD_NAME___Before, __GHOST_FIELD_NAME___After, snapshotInterpolationFactor);
                #endregion
            }
        }
示例#12
0
 static public JsonData GetJson(IComponentData component)
 {
     return(component.ToJson());
 }
示例#13
0
 public ComponentPresentation(IComponentData component, ITemplateData template)
 {
     this.component = component;
     this.template = template;
     this.cp = Helper.BuildComponentPresentation(component.BaseData as IComponent, template.BaseData as IComponentTemplate);
 }
 private static void ReportPredictionErrors(ref IComponentData component, in IComponentData backup, ref UnsafeList <float> errors, ref int errorIndex)
        public unsafe void CopyFromSnapshot(ref GhostDeserializerState deserializerState, ref Snapshot snapshotBefore, ref Snapshot snapshotAfter, float snapshotInterpolationFactor, ref IComponentData component)
        {
            if (true)
            {
                #region __GHOST_COPY_FROM_SNAPSHOT__
                component.__GHOST_FIELD_REFERENCE__ = math.normalize(new quaternion(snapshotBefore.__GHOST_FIELD_NAME__X * __GHOST_DEQUANTIZE_SCALE__, snapshotBefore.__GHOST_FIELD_NAME__Y * __GHOST_DEQUANTIZE_SCALE__, snapshotBefore.__GHOST_FIELD_NAME__Z * __GHOST_DEQUANTIZE_SCALE__, snapshotBefore.__GHOST_FIELD_NAME__W * __GHOST_DEQUANTIZE_SCALE__));
                #endregion

                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE__
                component.__GHOST_FIELD_REFERENCE__ = math.slerp(
                    math.normalize(new quaternion(snapshotBefore.__GHOST_FIELD_NAME__X * __GHOST_DEQUANTIZE_SCALE__, snapshotBefore.__GHOST_FIELD_NAME__Y * __GHOST_DEQUANTIZE_SCALE__, snapshotBefore.__GHOST_FIELD_NAME__Z * __GHOST_DEQUANTIZE_SCALE__, snapshotBefore.__GHOST_FIELD_NAME__W * __GHOST_DEQUANTIZE_SCALE__)),
                    math.normalize(new quaternion(snapshotAfter.__GHOST_FIELD_NAME__X * __GHOST_DEQUANTIZE_SCALE__, snapshotAfter.__GHOST_FIELD_NAME__Y * __GHOST_DEQUANTIZE_SCALE__, snapshotAfter.__GHOST_FIELD_NAME__Z * __GHOST_DEQUANTIZE_SCALE__, snapshotAfter.__GHOST_FIELD_NAME__W * __GHOST_DEQUANTIZE_SCALE__)),
                    snapshotInterpolationFactor);
                #endregion
            }
        }
示例#16
0
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     IEnumerable result = null;
     if (component != null && component.MultimediaData != null)
     {
         result = new string[] { component.MultimediaData.Url };
     }
     return result;
 }
示例#17
0
 //Example of using the BaseData object
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     Dynamic.IMultimedia[] result = null;
     if (component != null && component.MultimediaData != null)
     {
         result = new Dynamic.IMultimedia[] { component.MultimediaData.BaseData as Dynamic.IMultimedia };
     }
     return result;
 }
 public unsafe void CopyToSnapshot(ref GhostSerializerState serializerState, ref Snapshot snapshot, ref IComponentData component)
 {
     if (true)
     {
         #region __GHOST_COPY_TO_SNAPSHOT__
         snapshot.__GHOST_FIELD_NAME__          = 0;
         snapshot.__GHOST_FIELD_NAME__SpawnTick = 0;
         if (serializerState.GhostFromEntity.HasComponent(component.__GHOST_FIELD_REFERENCE__))
         {
             var ghostComponent = serializerState.GhostFromEntity[component.__GHOST_FIELD_REFERENCE__];
             snapshot.__GHOST_FIELD_NAME__          = ghostComponent.ghostId;
             snapshot.__GHOST_FIELD_NAME__SpawnTick = ghostComponent.spawnTick;
         }
         #endregion
     }
 }
示例#19
0
        public unsafe void CopyFromSnapshot(ref GhostDeserializerState deserializerState, ref Snapshot snapshotBefore, ref Snapshot snapshotAfter, float snapshotInterpolationFactor, ref IComponentData component)
        {
            if (true)
            {
                #region __GHOST_COPY_FROM_SNAPSHOT__
                var wb = snapshotBefore.__GHOST_FIELD_NAME__W * __GHOST_DEQUANTIZE_SCALE__;
                component.__GHOST_FIELD_REFERENCE__ = new quaternion(new float4(0f, 0f, wb > 1.0f - 1e-9f?0.0f:math.sqrt(1f - wb * wb), wb));
                #endregion

                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE__
                var wb = snapshotBefore.__GHOST_FIELD_NAME__W * __GHOST_DEQUANTIZE_SCALE__;
                var wa = snapshotAfter.__GHOST_FIELD_NAME__W * __GHOST_DEQUANTIZE_SCALE__;
                component.__GHOST_FIELD_REFERENCE__ = math.slerp(
                    new quaternion(new float4(0f, 0f, wb > 1.0f - 1e-9f?0.0f:math.sqrt(1f - wb * wb), wb)),
                    new quaternion(new float4(0f, 0f, wa > 1.0f - 1e-9f?0.0f:math.sqrt(1f - wa * wa), wa)),
                    snapshotInterpolationFactor);
                #endregion
            }
        }
 public ComponentsController(IComponentData pCompData)
 {
     this._compData = pCompData;
 }
 public void AddComponentData(EntityManager dstManager, Entity entity, IComponentData iComponentData)
 {
     dstManager.AddComponentData(entity, (T)iComponentData);
 }
 public unsafe void CopyFromSnapshot(ref GhostDeserializerState deserializerState, ref Snapshot snapshotBefore, ref Snapshot snapshotAfter, float snapshotInterpolationFactor, ref IComponentData component)
 {
     if (true)
     {
         #region __GHOST_COPY_FROM_SNAPSHOT__
         component.__GHOST_FIELD_REFERENCE__ = Entity.Null;
         if (snapshotBefore.__GHOST_FIELD_NAME__ != 0)
         {
             if (deserializerState.GhostMap.TryGetValue(new SpawnedGhost {
                 ghostId = snapshotBefore.__GHOST_FIELD_NAME__, spawnTick = snapshotBefore.__GHOST_FIELD_NAME__SpawnTick
             }, out var ghostEnt))
             {
                 component.__GHOST_FIELD_REFERENCE__ = ghostEnt;
             }
         }
         #endregion
     }
 }
示例#23
0
 public ComponentPresentation(IComponentPresentation cp)
 {
     this.cp = cp;
     component = new Component(cp.Component);
     template = new ComponentTemplate(cp.ComponentTemplate);
 }
示例#24
0
 /// <summary>
 /// When overriden in a derived class, this gets the value of the Property for a given Component
 /// </summary>
 /// <param name="component">Component for the View Model</param>
 /// <param name="propertyType">Actual return type for the Property</param>
 /// <param name="template">Component Template</param>
 /// <param name="factory">View Model factory</param>
 /// <returns>The Property value</returns>
 public abstract IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory);
示例#25
0
 public unsafe void CopyFromSnapshot(ref GhostDeserializerState deserializerState, ref Snapshot snapshotBefore, ref Snapshot snapshotAfter, float snapshotInterpolationFactor, ref IComponentData component)
 {
     if (true)
     {
         #region __GHOST_COPY_FROM_SNAPSHOT__
         component.__GHOST_FIELD_REFERENCE__ = snapshotBefore.__GHOST_FIELD_NAME__;
         #endregion
     }
 }
示例#26
0
 public void AddComponent(Entity entity, IComponentData componentData)
 {
     ComponentsContainer[entity].Add(componentData.GetType(), componentData);
 }
示例#27
0
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     IMultimediaData result = null;
     if (component != null && component.MultimediaData != null)
     {
         result = component.MultimediaData;
     }
     return new IMultimediaData[] { result };
 }
示例#28
0
 public static void UpdateEntity(Entity entity, IComponentData componentData)
 {
     EntityManager.SetComponentData(entity, (dynamic)componentData);
 }
示例#29
0
 public override IEnumerable GetPropertyValues(IComponentData component, IModelProperty property, ITemplateData template, IViewModelFactory factory)
 {
     return component == null ? null : new string[] { component.Title };
 }
示例#30
0
 public static void UpdateEntity(EntityCommandBuffer commandBuffer, Entity entity, IComponentData componentData)
 {
     commandBuffer.SetComponent(entity, (dynamic)componentData);
 }
示例#31
0
 /// <inheritdoc cref="IComponentAdder.AddComponent" />
 public IComponentAdder AddComponent <C>(IComponentData <C> data, WorkerRequirementSet writeAcl) where C : IComponentMetaclass
 {
     entity.Add(data);
     entityAcl.SetWriteAccess <C>(writeAcl);
     return(this);
 }
        public unsafe void CopyFromSnapshot(ref GhostDeserializerState deserializerState, ref Snapshot snapshotBefore, ref Snapshot snapshotAfter, float snapshotInterpolationFactor, ref IComponentData component)
        {
            if (true)
            {
                #region __GHOST_COPY_FROM_SNAPSHOT__
                component.__GHOST_FIELD_REFERENCE__ = new float4(snapshotBefore.__GHOST_FIELD_NAME___x, snapshotBefore.__GHOST_FIELD_NAME___y, snapshotBefore.__GHOST_FIELD_NAME___z, snapshotBefore.__GHOST_FIELD_NAME___w);
                #endregion

                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE__
                component.__GHOST_FIELD_REFERENCE__ = math.lerp(
                    new float4(snapshotBefore.__GHOST_FIELD_NAME___x, snapshotBefore.__GHOST_FIELD_NAME___y, snapshotBefore.__GHOST_FIELD_NAME___z, snapshotBefore.__GHOST_FIELD_NAME___w),
                    new float4(snapshotAfter.__GHOST_FIELD_NAME___x, snapshotAfter.__GHOST_FIELD_NAME___y, snapshotAfter.__GHOST_FIELD_NAME___z, snapshotAfter.__GHOST_FIELD_NAME___w),
                    snapshotInterpolationFactor);
                #endregion
            }
        }
        public static Entity CreatePlayerTemplate(string clientId, EntityId playerCreatorId, IComponentData <PlatformPosition> platformPosiionData)
        {
            var playerTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(Coordinates.ZERO.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.PlayerPrefabName)
                                 .SetPersistence(false)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(UnityEngine.Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new ClientAuthorityCheck.Data(), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout, clientId, playerCreatorId), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new WalkControls.Data(new Vector3f(0.0f, 0.0f, 0.0f)), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new PilotControls.Data(0.0f, 0.0f, false), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(platformPosiionData, CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(playerTemplate);
        }
 public static void UpdateEntity(Entity entity, IComponentData componentData)
 {
 }
示例#35
0
 public unsafe void RestoreFromBackup(ref IComponentData component, in IComponentData backup)
示例#36
0
 public bool TryGetValue(EntityId id, out IComponentData <T> component)
 {
     return(_components.TryGetValue(id, out component));
 }
        public unsafe void CopyFromSnapshot(ref GhostDeserializerState deserializerState, ref Snapshot snapshotBefore, ref Snapshot snapshotAfter, float snapshotInterpolationFactor, ref IComponentData component)
        {
            if (true)
            {
                #region __GHOST_COPY_FROM_SNAPSHOT__
                component.__GHOST_FIELD_REFERENCE__ = new float2(snapshotBefore.__GHOST_FIELD_NAME___x, snapshotBefore.__GHOST_FIELD_NAME___y);
                #endregion

                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE_SETUP__
                var __GHOST_FIELD_NAME___Before = new float2(snapshotBefore.__GHOST_FIELD_NAME___x, snapshotBefore.__GHOST_FIELD_NAME___y);
                var __GHOST_FIELD_NAME___After  = new float2(snapshotAfter.__GHOST_FIELD_NAME___x, snapshotAfter.__GHOST_FIELD_NAME___y);
                #endregion
                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE_DISTSQ__
                var __GHOST_FIELD_NAME___DistSq = math.distancesq(__GHOST_FIELD_NAME___Before, __GHOST_FIELD_NAME___After);
                #endregion
                #region __GHOST_COPY_FROM_SNAPSHOT_INTERPOLATE__
                component.__GHOST_FIELD_REFERENCE__ = math.lerp(__GHOST_FIELD_NAME___Before, __GHOST_FIELD_NAME___After, snapshotInterpolationFactor);
                #endregion
            }
        }
示例#38
0
 public ComponentPresentation(IComponent component, IComponentTemplate template)
 {
     this.cp = Helper.BuildComponentPresentation(component, template); //Helps get around naming conflicts
     this.component = new Component(component);
     this.template = new ComponentTemplate(template);
 }