protected override void Start() { base.Start(); launchArrowData = new SquadProjectileLaunchDataSharedComponentData() { data = new SquadProjectileLaunchDataWrapper() { renderScaleData = new RenderScaleComponentdata() { value = projectilesData.RenderScale }, spriteData = new SpriteRendererComponentData() { uv = projectilesData.Animation.RandomUV, usePivot = true, pivot = projectilesData.Animation.Pivot }, animaionData = DataToComponentData.ToComponentData(projectilesData.Animation), renderData = new RenderSharedComponentData() { material = projectilesData.Animation.Material, mesh = projectilesData.Animation.Mesh, }, collisionData = projectilesData.Collision, launchData = projectilesData.Launch, castShadows = castProjectileShadows, calcShadowsShifts = calsProjectileShadowsShifts, } }; if (castProjectileShadows) { launchArrowData.data.shadowSettings = DataToComponentData.ToComponentData(projectileShadowSettings); } }
public void ConvertToEntity(Entity entity, EntityManager manager) { var transform = this.transform; manager.AddComponentData(entity, new Translation() { Value = transform.position }); manager.AddComponentData(entity, new Scale() { Value = transform.lossyScale.Average2D() }); manager.AddComponentData(entity, new Rotation() { Value = transform.rotation }); if (scaleSettings != null) { manager.AddComponentData(entity, DataToComponentData.ToComponentData(scaleSettings)); } if (ZbyYSettings != null) { manager.AddComponentData(entity, DataToComponentData.ToComponentData(ZbyYSettings)); } }
public SpriteSheetAnimationComponentData GetAnimationData(TrailSpriteDataNamedId id) { if (!animationData.ContainsKey(id)) { var spriteData = datas.Where(d => d.id == id).First(); animationData.Add(id, DataToComponentData.ToComponentData(spriteData.spriteData)); } return(animationData[id]); }
public void UpdateProjectiles(object caller) { lastCaller = caller; Init(); if (updateAnimation != null) { spawner.LaunchArrowData.data.animaionData = DataToComponentData.ToComponentData(updateAnimation); } }
protected virtual void Start() { manager = World.Active.EntityManager; archetype = manager.CreateArchetype( typeof(Translation), typeof(LinearMovementComponentData), typeof(VelocityAbsoluteComponentData), typeof(SpriteSheetAnimationComponentData), typeof(SpriteRendererComponentData), typeof(SpriteTintComponentData), typeof(Scale), typeof(RenderScaleComponentdata), typeof(ScaleByPositionComponentData), typeof(SquadTagSharedComponentData), typeof(SquadComponentData), typeof(RenderSharedComponentData), typeof(FactionComponentData), typeof(CacheByQuadrandSystemTag), typeof(ProcessProjectileCollisionTag), typeof(AnimationListSharedComponentData), typeof(AnimationPauseComponentData), typeof(ActionOnAnimationFrameComponentData), typeof(DestroyWithHealthComponentData), typeof(HealthComponentData), typeof(AnimatorStatesComponentData), typeof(FlibHorisontalByMoveDirTagComponentData), typeof(FlibHorisontalByTargetTagComponentData), typeof(ZbyYComponentData), typeof(AudioClipComponentData), typeof(DeathAudioClipComponentData), typeof(CastSpritesShadowComponentData) ); squadTag = DataToComponentData.ToComponentData(squadData, squadId, squadPosition.position); renderData = new RenderSharedComponentData() { material = animationProvider.Material, mesh = animationProvider.Mesh, }; animationData = new AnimationListSharedComponentData() { animations = animationProvider.Animations, pauses = animationProvider.PausesData, actions = animationProvider.ActionsData }; }
protected virtual void SetEntityComponentsData(Entity entity, EntityManager manager) { var translation = this.transform.position; manager.SetComponentData(entity, new Translation() { Value = new float3( translation.x + UnityEngine.Random.Range(-spawnRandRange, spawnRandRange), translation.y + UnityEngine.Random.Range(-spawnRandRange, spawnRandRange), 0f ) }); manager.SetComponentData(entity, new VelocityAbsoluteComponentData() { value = velocity }); manager.SetComponentData(entity, new Scale() { Value = 1f }); manager.SetComponentData(entity, new RenderScaleComponentdata() { value = new float2(flipHorisontalScale ? -1 : 1, 1) }); manager.SetComponentData(entity, DataToComponentData.ToComponentData(scaleByPosSettings)); manager.SetComponentData(entity, new FactionComponentData() { value = faction }); manager.SetComponentData(entity, new LinearMovementComponentData() { doMoving = true }); manager.SetComponentData(entity, new HealthComponentData() { value = health }); manager.SetComponentData(entity, new DestroyWithHealthComponentData() { delay = 1f }); manager.SetComponentData(entity, new SpriteTintComponentData() { color = tint }); manager.SetComponentData(entity, DataToComponentData.ToComponentData(ZbyYSettings)); manager.SetComponentData(entity, new SpriteRendererComponentData() { usePivot = true, pivot = new Vector2(0.5f, 0) }); manager.SetComponentData(entity, new FlibHorisontalByMoveDirTagComponentData() { defaultFlipped = flipHorisontalScale }); manager.SetComponentData(entity, new FlibHorisontalByTargetTagComponentData() { defaultFlipped = flipHorisontalScale }); if (updateAnimationStatesBuTriggers) { manager.AddComponent <AnimatorStateLastTriggeredAnimationComponentData>(entity); } CastSpritesShadowComponentData shd; if (!useLocalDefauldShadowSetting && shadowSettings != null) { shd = DataToComponentData.ToComponentData(shadowSettings); } else { shd = shadowData; } shd.disableCastShadow = !castSpriteShadows; manager.SetComponentData(entity, shd); if (shiftShadows) { manager.AddComponentData(entity, new ShiftCastShadowsTagComponentData() { positionUnitsOffsetDefaultValue = shd.positionUnitsOffset }); } manager.SetComponentData(entity, new AudioClipComponentData() { audioSourcePoolId = squadId, randRangeId = randClipId, maxClipId = actionSoundMaxClipId, clipId = actionSoundClipId }); manager.SetComponentData(entity, new DeathAudioClipComponentData() { audio = new AudioClipComponentData() { audioSourcePoolId = squadId, randRangeId = deathRandClipId, maxClipId = deathSoundMaxClipId, clipId = deathSoundClipId } }); }