Ejemplo n.º 1
0
        public static NetcodeConversionTarget GetConversionTarget(GameObjectConversionSystem system)
        {
            // Detect target using build settings (This is used from sub scenes)
#if UNITY_EDITOR
            {
                var settings = system.GetBuildConfigurationComponent <NetCodeConversionSettings>();
                if (settings != null)
                {
                    //Debug.LogWarning("BuildSettings conversion for: " + settings.Target);
                    return(settings.Target);
                }
            }
#endif

            if (system.DstEntityManager.World.GetExistingSystem <ClientSimulationSystemGroup>() != null)
            {
                return(NetcodeConversionTarget.Client);
            }
            if (system.DstEntityManager.World.GetExistingSystem <ServerSimulationSystemGroup>() != null)
            {
                return(NetcodeConversionTarget.Server);
            }

            return(NetcodeConversionTarget.Undefined);
        }
Ejemplo n.º 2
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        GameDebug.Log(string.Format("Convert DotsAnimStateController:{0}", this));

        var settings = AnimSourceController.Settings.Default;

        settings.RootAnimSource = AnimSourceRoot;
        dstManager.AddComponentData(entity, settings);

        var rigDataBuffer = dstManager.AddBuffer <AnimSourceController.RigData>(entity);

        for (int i = 0; i < Rigs.Count; i++)
        {
            var rigData = new AnimSourceController.RigData
            {
                Rig     = RigDefinitionAsset.ConvertRig(Rigs[i].Rig),
                MaxDist = Rigs[i].MaxDist,
            };
            rigDataBuffer.Add(rigData);
        }

        var conversionSettings = conversionSystem.GetBuildConfigurationComponent <NetCodeConversionSettings>();
        var server             = conversionSettings != null ? conversionSettings.Target == NetcodeConversionTarget.Server :
                                 dstManager.World.GetExistingSystem <Unity.NetCode.ServerSimulationSystemGroup>() != null;
        var color = server ? Color.gray : Color.green;

        dstManager.AddComponentData(entity, new SkeletonRenderer {
            Color = color,
        });
    }
Ejemplo n.º 3
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var rotationSpeedSetting = conversionSystem.GetBuildConfigurationComponent <RotationSpeedSetting>();

        // Change rotation speed
        var data = new RotationSpeed_IJobEntityBatch {
            RadiansPerSecond = math.radians(rotationSpeedSetting.RotationSpeed)
        };

        dstManager.AddComponentData(entity, data);

        // Offset the translation of the generated object
        var translation = dstManager.GetComponentData <Translation>(entity);

        translation.Value.y += rotationSpeedSetting.Offset;
        dstManager.SetComponentData(entity, translation);
    }